diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-24 04:54:16 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-24 04:54:16 +0000 |
commit | e3a8c626308cb8546baaf75e6133df304142f0c8 (patch) | |
tree | 4fb40e7eab065c70d5b2cdb44eb16bea01b12c15 /io.c | |
parent | b596fbbc375ea58aa2b869cb6025b2bb101f96b9 (diff) |
* io.c (rb_io_mode_flags): both 'r+b' and 'rb+' should be allowed.
* io.c (rb_io_mode_modenum): ditto.
* gc.c (rb_memerror): rename from mem_error, and exported.
* gc.c (Init_GC): pre-allocate NoMemoryError instance.
* object.c (convert_type): error message changed from "failed to
convert" to "cannot convert", since it does not try to convert
if an object does not respond to the converting method.
* eval.c (block_pass): convert Method to Proc using
rb_check_convert_type().
* object.c (rb_check_convert_type): always convert T_DATA
* eval.c (rb_thread_cleanup): should not terminate main_thread by
Fatal error.
* regex.c (is_in_list): need to not exclude NUL and NEWLINE.
* re.c (rb_reg_expr_str): wrong backslash escapement.
* re.c (rb_reg_expr_str): do not escape embedded space
characters.
* marshal.c (w_object): T_DATA process patch from Joel VanderWerf
<vjoel@PATH.Berkeley.EDU>. This is temporary hack; it remains
undocumented, and it will be removed when marshaling is
re-designed.
* marshal.c (r_object): ditto.
* numeric.c (num_step): Integer#step is moved to Numeric#step;
Fixnum#step is merged into this method.
* numeric.c (int_dotimes): Fixnum#times is merged.
* numeric.c (int_upto): Fixnum#upto is merged.
* numeric.c (int_downto): Fixnum#downto is merged.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 61 |
1 files changed, 30 insertions, 31 deletions
@@ -265,7 +265,7 @@ io_write(io, str) { OpenFile *fptr; FILE *f; - int n; + long n; rb_secure(4); if (TYPE(str) != T_STRING) @@ -284,7 +284,7 @@ io_write(io, str) #ifdef __human68k__ { register char *ptr = RSTRING(str)->ptr; - n = (int)RSTRING(str)->len; + n = RSTRING(str)->len; while (--n >= 0) if (fputc(*ptr++, f) == EOF) break; @@ -305,7 +305,7 @@ io_write(io, str) fptr->mode |= FMODE_WBUF; } - return INT2FIX(n); + return LONG2FIX(n); } VALUE @@ -613,8 +613,7 @@ remain_size(fptr) { struct stat st; off_t siz = BUFSIZ; - long bytes = 0; - int n; + off_t pos; if (feof(fptr->f)) return 0; if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode) @@ -623,8 +622,6 @@ remain_size(fptr) #endif ) { - off_t pos; - pos = ftello(fptr->f); if (st.st_size > pos && pos >= 0) { siz = st.st_size - pos + 1; @@ -643,14 +640,14 @@ read_all(fptr, siz) { VALUE str; long bytes = 0; - int n; + long n; if (feof(fptr->f)) return Qnil; READ_CHECK(fptr->f); if (!siz) siz = BUFSIZ; str = rb_tainted_str_new(0, siz); for (;;) { - n = io_fread(RSTRING(str)->ptr+bytes, (long)siz-bytes, fptr->f); + n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f); if (n == 0 && bytes == 0) { if (feof(fptr->f)) return Qnil; rb_sys_fail(fptr->path); @@ -1003,7 +1000,7 @@ rb_io_readlines(argc, argv, io) VALUE io; { VALUE line, ary; - VALUE rs, str; + VALUE rs; OpenFile *fptr; if (argc == 0) { @@ -1452,16 +1449,18 @@ rb_io_mode_flags(mode) rb_raise(rb_eArgError, "illegal access mode %s", mode); } - if (*m == 'b') { - flags |= FMODE_BINMODE; - m++; - } - - if (*m == '+') { - flags |= FMODE_READWRITE; - if (m[1] != 0) goto error; + while (*m) { + switch (*m++) { + case 'b': + flags |= FMODE_BINMODE; + break; + case '+': + flags |= FMODE_READWRITE; + break; + default: + goto error; + } } - else if (*m != 0) goto error; return flags; } @@ -1470,7 +1469,7 @@ static int rb_io_modenum_flags(mode) int mode; { - int flags; + int flags = 0; switch (mode & (O_RDONLY|O_WRONLY|O_RDWR)) { case O_RDONLY: @@ -1515,18 +1514,20 @@ rb_io_mode_modenum(mode) rb_raise(rb_eArgError, "illegal access mode %s", mode); } - if (*m == 'b') { + while (*m) { + switch (*m++) { + case 'b': #ifdef O_BINARY - flags |= O_BINARY; + flags |= O_BINARY; #endif - m++; - } - - if (*m == '+') { - flags |= O_RDWR; - if (m[1] != 0) goto error; + break; + case '+': + flags |= O_RDWR; + break; + default: + goto error; + } } - else if (*m != 0) goto error; return flags; } @@ -3554,8 +3555,6 @@ argf_readchar() static VALUE argf_eof() { - int first = first_p; - if (!next_argv()) return Qtrue; if (next_p == 1) { return Qtrue; |