ruby-changes:10604
From: shyouhei <ko1@a...>
Date: Mon, 9 Feb 2009 13:40:00 +0900 (JST)
Subject: [ruby-changes:10604] Ruby:r22161 (ruby_1_8_6): merge revision(s) 20151:
shyouhei 2009-02-09 13:39:52 +0900 (Mon, 09 Feb 2009) New Revision: 22161 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22161 Log: merge revision(s) 20151: * ext/stringio/stringio.c (strio_ungetc): should allow ungetc at the top of the buffer. ref #701 Modified files: branches/ruby_1_8_6/ChangeLog branches/ruby_1_8_6/ext/stringio/stringio.c branches/ruby_1_8_6/version.h Index: ruby_1_8_6/ext/stringio/stringio.c =================================================================== --- ruby_1_8_6/ext/stringio/stringio.c (revision 22160) +++ ruby_1_8_6/ext/stringio/stringio.c (revision 22161) @@ -771,15 +771,24 @@ int cc = NUM2INT(ch); long len, pos = ptr->pos; - if (cc != EOF && pos > 0) { - if ((len = RSTRING(ptr->string)->len) < pos-- || - (unsigned char)RSTRING(ptr->string)->ptr[pos] != - (unsigned char)cc) { - strio_extend(ptr, pos, 1); - RSTRING(ptr->string)->ptr[pos] = cc; - OBJ_INFECT(ptr->string, self); + if (cc != EOF) { + len = RSTRING(ptr->string)->len; + if (pos == 0) { + char *p; + rb_str_resize(ptr->string, len + 1); + p = RSTRING(ptr->string)->ptr; + memmove(p + 1, p, len); } - --ptr->pos; + else { + if (len < pos-- || + (unsigned char)RSTRING(ptr->string)->ptr[pos] != + (unsigned char)cc) { + strio_extend(ptr, pos, 1); + } + --ptr->pos; + } + RSTRING(ptr->string)->ptr[pos] = cc; + OBJ_INFECT(ptr->string, self); ptr->flags &= ~STRIO_EOF; } return Qnil; Index: ruby_1_8_6/ChangeLog =================================================================== --- ruby_1_8_6/ChangeLog (revision 22160) +++ ruby_1_8_6/ChangeLog (revision 22161) @@ -1,3 +1,8 @@ +Mon Feb 9 13:39:14 2009 Yukihiro Matsumoto <matz@r...> + + * ext/stringio/stringio.c (strio_ungetc): should allow ungetc at + the top of the buffer. ref #701 + Thu Feb 5 09:37:39 2009 NARUSE, Yui <naruse@r...> * ext/nkf/nkf-utf8/nkf.c (h_conv): can't guess UTF-8 input in Index: ruby_1_8_6/version.h =================================================================== --- ruby_1_8_6/version.h (revision 22160) +++ ruby_1_8_6/version.h (revision 22161) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.6" -#define RUBY_RELEASE_DATE "2009-02-05" +#define RUBY_RELEASE_DATE "2009-02-09" #define RUBY_VERSION_CODE 186 -#define RUBY_RELEASE_CODE 20090205 -#define RUBY_PATCHLEVEL 322 +#define RUBY_RELEASE_CODE 20090209 +#define RUBY_PATCHLEVEL 323 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 6 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 9 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/