aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-14 15:07:49 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-14 15:07:49 +0000
commitfa246559d2c1206e3f3d4b409c2e161671821905 (patch)
tree719f2b4bb8b2f330a39ea68e8dfd20af13b103bd
parentdfca247f666821d41176737a89186cecf4a7a1fa (diff)
downloadruby-fa246559d2c1206e3f3d4b409c2e161671821905.tar.gz
* io.c (appendline): specifying limit should not generate broken
byte sequence. strings should be rounded. [ruby-dev:33088] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c12
-rw-r--r--version.h6
3 files changed, 20 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c872696f73..bb8a2145e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jan 15 00:05:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (appendline): specifying limit should not generate broken
+ byte sequence. strings should be rounded. [ruby-dev:33088]
+
Mon Jan 14 23:33:02 2008 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/lib/kconv.rb (Kconv.tolocale): argument is str.
diff --git a/io.c b/io.c
index 6ff3abd5d0..7d48f90f82 100644
--- a/io.c
+++ b/io.c
@@ -1712,6 +1712,18 @@ appendline(rb_io_t *fptr, int delim, const char *rsptr, int rslen, VALUE *strp,
if (c != EOF) {
RSTRING_PTR(str)[last++] = c;
}
+ if (limit > 0 && limit == pending) {
+ char *p = fptr->rbuf+fptr->rbuf_off;
+ char *pp = p + limit;
+ char *pl = rb_enc_left_char_head(p, pp, io_read_encoding(fptr));
+
+ if (pl < pp) {
+ int diff = pp - pl;
+ pending -= diff;
+ limit = pending;
+ rb_str_set_len(str, RSTRING_LEN(str)-diff);
+ }
+ }
read_buffered_data(RSTRING_PTR(str) + last, pending, fptr); /* must not fail */
limit -= pending;
*lp = limit;
diff --git a/version.h b/version.h
index 0865aa91c7..8f18511be0 100644
--- a/version.h
+++ b/version.h
@@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-01-14"
+#define RUBY_RELEASE_DATE "2008-01-15"
#define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080114
+#define RUBY_RELEASE_CODE 20080115
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 14
+#define RUBY_RELEASE_DAY 15
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];