1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/stringio/stringio.c (strio_getc): rb_enc_mbclen() fix.

* ext/stringio/stringio.c (strio_ungetc): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-09-06 15:42:53 +00:00
parent ae11bc70f1
commit 080605efb1
3 changed files with 8 additions and 3 deletions

View file

@ -2,6 +2,10 @@ Fri Sep 7 00:28:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_getc): forgot to commit rb_enc_mbclen() fix.
* ext/stringio/stringio.c (strio_getc): rb_enc_mbclen() fix.
* ext/stringio/stringio.c (strio_ungetc): ditto.
Thu Sep 6 22:57:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/fileutils.rb (FileUtils::Entry_::copy): prevent self copy of

View file

@ -1,2 +1,3 @@
stringio.o: stringio.c $(hdrdir)/ruby/ruby.h $(arch_hdrdir)/ruby/config.h \
$(hdrdir)/ruby/defines.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/io.h
$(hdrdir)/ruby/defines.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/io.h \
$(hdrdir)/ruby/encoding.h

View file

@ -631,7 +631,7 @@ strio_getc(VALUE self)
return Qnil;
}
p = RSTRING_PTR(ptr->string)+ptr->pos;
len = rb_enc_mbclen(p, enc);
len = rb_enc_mbclen(p, RSTRING_END(ptr->string), enc);
ptr->pos += len;
return rb_enc_str_new(p, len, rb_enc_get(ptr->string));
}
@ -705,7 +705,7 @@ strio_ungetc(VALUE self, VALUE c)
/* get logical position */
lpos = 0; p = RSTRING_PTR(ptr->string); pend = p + ptr->pos - 1;
for (;;) {
clen = rb_enc_mbclen(p, enc);
clen = rb_enc_mbclen(p, pend, enc);
if (p+clen >= pend) break;
p += clen;
lpos++;