summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-09 04:39:52 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-09 04:39:52 +0000
commit783b5e40d8d040b3bce4f61a15267418571e063c (patch)
tree29089d125c216857aa99269ceef01b5e91c63fab
parentcde7c409825440bad9b177c72524cd5803dabc4f (diff)
merge revision(s) 20151:
* ext/stringio/stringio.c (strio_ungetc): should allow ungetc at the top of the buffer. ref #701 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@22161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/stringio/stringio.c25
-rw-r--r--version.h8
3 files changed, 26 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index c23ae20248..4ab513fec4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Feb 9 13:39:14 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c (h_conv): can't guess UTF-8 input in
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 86ff56534c..b7c67f2aad 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -771,15 +771,24 @@ strio_ungetc(self, ch)
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);
+ }
+ else {
+ if (len < pos-- ||
+ (unsigned char)RSTRING(ptr->string)->ptr[pos] !=
+ (unsigned char)cc) {
+ strio_extend(ptr, pos, 1);
+ }
+ --ptr->pos;
}
- --ptr->pos;
+ RSTRING(ptr->string)->ptr[pos] = cc;
+ OBJ_INFECT(ptr->string, self);
ptr->flags &= ~STRIO_EOF;
}
return Qnil;
diff --git a/version.h b/version.h
index f84a234516..440525dd12 100644
--- a/version.h
+++ b/version.h
@@ -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[];