From f02212882dac1d3c5c711ec1929967bcb010a0ff Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 6 Sep 2007 15:42:53 +0000 Subject: * ext/stringio/stringio.c (strio_getc): rb_enc_mbclen() fix. * ext/stringio/stringio.c (strio_ungetc): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/stringio/depend | 3 ++- ext/stringio/stringio.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'ext/stringio') diff --git a/ext/stringio/depend b/ext/stringio/depend index a052c73de..338ebde52 100644 --- a/ext/stringio/depend +++ b/ext/stringio/depend @@ -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 diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 08a6341b7..c4960f68a 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -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++; -- cgit