summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-03 17:30:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-03 17:30:09 +0000
commit4f5976cbb826df462c62a0a8e72ebe91c15a7ba4 (patch)
treee379d57a79fcd940058c53b335f5c17b605c4285 /io.c
parentad27a1413640c63310da6c25b95bb6f2fad122be (diff)
* io.c (argf_read): should not terminate on empty string; wait
until real EOF. [ruby-dev:21969] * io.c (argf_read): should adjust length to read, when length is specified and read spans command line argument files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/io.c b/io.c
index 7d6637e1f3..f0231567ba 100644
--- a/io.c
+++ b/io.c
@@ -3828,16 +3828,24 @@ argf_read(argc, argv)
else {
tmp = io_read(argc, argv, current_file);
}
- if (NIL_P(tmp) && next_p != -1) {
- argf_close(current_file);
- next_p = 1;
- if (argc == 0) goto retry;
+ if (NIL_P(tmp)) {
+ if (next_p != -1) {
+ argf_close(current_file);
+ next_p = 1;
+ goto retry;
+ }
+ return str;
}
- if (NIL_P(tmp) || RSTRING(tmp)->len == 0) return str;
else if (NIL_P(str)) str = tmp;
else rb_str_append(str, tmp);
if (argc == 0) goto retry;
-
+ if (argc == 1) {
+ if (RSTRING(str)->len < len) {
+ len -= RSTRING(str)->len;
+ argv[0] = INT2NUM(len);
+ goto retry;
+ }
+ }
return str;
}