ruby-changes:18297
From: yugui <ko1@a...>
Date: Thu, 23 Dec 2010 21:46:13 +0900 (JST)
Subject: [ruby-changes:18297] Ruby:r30321 (ruby_1_9_2): merges r30280 from trunk into ruby_1_9_2.
yugui 2010-12-23 21:45:47 +0900 (Thu, 23 Dec 2010) New Revision: 30321 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30321 Log: merges r30280 from trunk into ruby_1_9_2. -- * io.c : add an extra byte to buffer for the specification of read in Windows. see [ruby-core:33460] and r29980. and, we have to discuss how to do this one byte. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/io.c branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 30320) +++ ruby_1_9_2/ChangeLog (revision 30321) @@ -1,3 +1,9 @@ +Tue Dec 21 01:41:42 2010 Masaya Tarui <tarui@r...> + + * io.c : add an extra byte to buffer for the specification of read + in Windows. see [ruby-core:33460] and r29980. and, we have to + discuss how to do this one byte. + Wed Dec 15 04:02:00 2010 KOSAKI Motohiro <kosaki.motohiro@g...> * ext/openssl/ossl_x509ext.c (ossl_x509extfactory_set_config): Index: ruby_1_9_2/io.c =================================================================== --- ruby_1_9_2/io.c (revision 30320) +++ ruby_1_9_2/io.c (revision 30321) @@ -1211,6 +1211,9 @@ fptr->rbuf_len = 0; fptr->rbuf_capa = IO_RBUF_CAPA_FOR(fptr); fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa); +#ifdef _WIN32 + fptr->rbuf.capa--; +#endif } if (fptr->rbuf_len == 0) { retry: @@ -1734,6 +1737,32 @@ return str; } +static void +io_setstrbuf(VALUE *str,long len) +{ +#ifdef _WIN32 + if (NIL_P(*str)) { + *str = rb_str_new(0, len+1); + rb_str_set_len(*str,len); + } + else { + StringValue(*str); + rb_str_modify(*str); + rb_str_resize(*str, len+1); + rb_str_set_len(*str,len); + } +#else + if (NIL_P(*str)) { + *str = rb_str_new(0, len); + } + else { + StringValue(*str); + rb_str_modify(*str); + rb_str_resize(*str, len); + } +#endif +} + static VALUE read_all(rb_io_t *fptr, long siz, VALUE str) { @@ -1744,8 +1773,7 @@ int cr; if (NEED_READCONV(fptr)) { - if (NIL_P(str)) str = rb_str_new(NULL, 0); - else rb_str_set_len(str, 0); + io_setstrbuf(&str,0); make_readconv(fptr, 0); while (1) { VALUE v; @@ -1773,12 +1801,7 @@ cr = 0; if (siz == 0) siz = BUFSIZ; - if (NIL_P(str)) { - str = rb_str_new(0, siz); - } - else { - rb_str_resize(str, siz); - } + io_setstrbuf(&str,siz); for (;;) { READ_CHECK(fptr); n = io_fread(str, bytes, fptr); @@ -1831,14 +1854,7 @@ rb_raise(rb_eArgError, "negative length %ld given", len); } - if (NIL_P(str)) { - str = rb_str_new(0, len); - } - else { - StringValue(str); - rb_str_modify(str); - rb_str_resize(str, len); - } + io_setstrbuf(&str,len); OBJ_TAINT(str); GetOpenFile(io, fptr); @@ -2157,10 +2173,6 @@ rb_scan_args(argc, argv, "02", &length, &str); if (NIL_P(length)) { - if (!NIL_P(str)){ - StringValue(str); - rb_str_modify(str); - } GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); return read_all(fptr, remain_size(fptr), str); @@ -2170,14 +2182,7 @@ rb_raise(rb_eArgError, "negative length %ld given", len); } - if (NIL_P(str)) { - str = rb_str_new(0, len); - } - else { - StringValue(str); - rb_str_modify(str); - rb_str_resize(str,len); - } + io_setstrbuf(&str,len); GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); @@ -3882,14 +3887,7 @@ rb_scan_args(argc, argv, "11", &len, &str); ilen = NUM2LONG(len); - if (NIL_P(str)) { - str = rb_str_new(0, ilen); - } - else { - StringValue(str); - rb_str_modify(str); - rb_str_resize(str, ilen); - } + io_setstrbuf(&str,ilen); if (ilen == 0) return str; GetOpenFile(io, fptr); Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 30320) +++ ruby_1_9_2/version.h (revision 30321) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 126 +#define RUBY_PATCHLEVEL 127 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/