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

* io.c (rb_f_readline): should raise EOFError at the end of

files.  [ruby-dev:22458]

* io.c (argf_read): should concatenate input files when length
  argument is nil. [ruby-dev:22450]

* io.c (argf_read): should update supplied string buffer (2nd
  argument) even when IO#read is called multiple times.

* io.c: should initialize lineno by zero. [ruby-dev:22460]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-12-30 19:29:56 +00:00
parent 5e78715f2c
commit 2c87fffec4
2 changed files with 29 additions and 16 deletions

View file

@ -3,6 +3,19 @@ Wed Dec 31 01:33:05 2003 Dave Thomas <dave@pragprog.com>
* array.c, error.c, eval.c, io.c, prec.c, range.c, re.c,
string.c, time.c: Add RDoc for Kernel functions, and tidy.
Tue Dec 30 19:39:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_f_readline): should raise EOFError at the end of
files. [ruby-dev:22458]
* io.c (argf_read): should concatenate input files when length
argument is nil. [ruby-dev:22450]
* io.c (argf_read): should update supplied string buffer (2nd
argument) even when IO#read is called multiple times.
* io.c: should initialize lineno by zero. [ruby-dev:22460]
Tue Dec 30 12:30:30 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/code_objects.rb (RDoc::Context::find_symbol): If a

32
io.c
View file

@ -59,7 +59,7 @@
#include <sys/stat.h>
/* EMX has sys/param.h, but.. */
#if defined(HAVE_SYS_PARAM_H) && !(defined(__EMX__) || defined(__HIUX_MPP__))
#if defined(HAVE_SYS_PAAM_H) && !(defined(__EMX__) || defined(__HIUX_MPP__))
# include <sys/param.h>
#endif
@ -110,7 +110,7 @@ struct timeval rb_time_interval _((VALUE));
static VALUE filename, current_file;
static int gets_lineno;
static int init_p = 0, next_p = 0;
static VALUE lineno;
static VALUE lineno = INT2FIX(0);
#if defined(__VMS)
#define fopen(file_spec, mode) fopen(file_spec, mode, "rfm=stmlf")
@ -4105,7 +4105,8 @@ rb_f_readline(argc, argv)
{
VALUE line;
NEXT_ARGF_FORWARD();
if (!next_argv()) rb_eof_error();
ARGF_FORWARD();
line = rb_f_gets(argc, argv);
if (NIL_P(line)) {
rb_eof_error();
@ -4913,23 +4914,22 @@ argf_read(argc, argv)
int argc;
VALUE *argv;
{
VALUE tmp, str;
VALUE tmp, str, length;
long len = 0;
if (argc == 1 && !NIL_P(argv[0]))
rb_scan_args(argc, argv, "02", &length, &str);
if (!NIL_P(length)) {
len = NUM2LONG(argv[0]);
str = Qnil;
}
if (!NIL_P(str)) {
StringValue(str);
rb_str_resize(str,0);
argv[1] = Qnil;
}
retry:
if (!next_argv()) {
if (NIL_P(str)) {
VALUE length;
rb_scan_args(argc, argv, "02", &length, &str);
if (NIL_P(str)) return rb_str_new(0,0);
StringValue(str);
rb_str_resize(str,0);
}
if (NIL_P(str)) return rb_str_new(0,0);
return str;
}
if (TYPE(current_file) != T_FILE) {
@ -4940,14 +4940,14 @@ argf_read(argc, argv)
}
if (NIL_P(str)) str = tmp;
else rb_str_append(str, tmp);
if (NIL_P(tmp) || argc == 0) {
if (NIL_P(tmp) || NIL_P(argv[0])) {
if (next_p != -1) {
argf_close(current_file);
next_p = 1;
goto retry;
}
}
else if (argc == 1) {
else if (argc >= 1) {
if (RSTRING(str)->len < len) {
len -= RSTRING(str)->len;
argv[0] = INT2NUM(len);