From 2c1140b3e0b72c9e33780a24706bc5757dff226b Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 11 Nov 2003 13:48:51 +0000 Subject: [PATCH] * io.c (appendline): file may not end with newline. a bug if READ_DATA_PENDING_PTR is defined. [ruby-talk:84925] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 14 +++++++++++--- lib/drb/drb.rb | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d2c41c5de..57b79dfbf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Nov 11 22:44:08 2003 Yukihiro Matsumoto + + * io.c (appendline): file may not end with newline. a bug if + READ_DATA_PENDING_PTR is defined. [ruby-talk:84925] + Tue Nov 11 10:42:41 2003 Hidetoshi NAGAI * ext/tk/lib/tk.rb: raise an exception when creating TkWindow diff --git a/io.c b/io.c index 75c0227a1c..7d6637e1f3 100644 --- a/io.c +++ b/io.c @@ -873,7 +873,7 @@ appendline(fptr, delim, strp) #ifndef READ_DATA_PENDING_PTR char buf[8192]; char *bp = buf, *bpe = buf + sizeof buf - 3; - int cnt; + int update = Qfalse; #endif do { @@ -925,11 +925,13 @@ appendline(fptr, delim, strp) rb_sys_fail(fptr->path); continue; } +#ifdef READ_DATA_PENDING_PTR return c; +#endif } #ifndef READ_DATA_PENDING_PTR - if ((*bp++ = c) == delim || bp == bpe) { - cnt = bp - buf; + if (c == EOF || (*bp++ = c) == delim || bp == bpe) { + int cnt = bp - buf; if (cnt > 0) { if (!NIL_P(str)) @@ -937,8 +939,14 @@ appendline(fptr, delim, strp) else *strp = str = rb_str_new(buf, cnt); } + if (c == EOF) { + if (update) + return (int)RSTRING(str)->ptr[RSTRING(str)->len-1]; + return c; + } bp = buf; } + update = Qtrue; #endif } while (c != delim); diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 5eb7345e1b..fda18401dd 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -1295,7 +1295,6 @@ module DRb end def run - raise if Thread.critical Thread.start do begin while true