ruby-changes:3798
From: ko1@a...
Date: Mon, 28 Jan 2008 12:33:22 +0900 (JST)
Subject: [ruby-changes:3798] matz - Ruby:r15287 (ruby_1_8): * io.c (rb_open_file): should check NUL in path.
matz 2008-01-28 12:33:05 +0900 (Mon, 28 Jan 2008) New Revision: 15287 Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/io.c branches/ruby_1_8/version.h Log: * io.c (rb_open_file): should check NUL in path. <http://www.rubyist.net/~matz/20080125.html#c01>. * io.c (rb_io_s_popen): ditto. * io.c (rb_io_reopen): ditto. * io.c (next_argv): ditto. * io.c (rb_io_s_foreach): ditto. * io.c (rb_io_s_readlines): ditto. * io.c (rb_io_s_read): ditto. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=15287&r2=15286&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/io.c?r1=15287&r2=15286&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/version.h?r1=15287&r2=15286&diff_format=u Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 15286) +++ ruby_1_8/ChangeLog (revision 15287) @@ -1,3 +1,26 @@ +Sun Jan 27 03:48:40 2008 Yukihiro Matsumoto <matz@r...> + +Sun Jan 27 03:48:07 2008 Yukihiro Matsumoto <matz@r...> + +Sun Jan 27 03:47:51 2008 Yukihiro Matsumoto <matz@r...> + +Mon Jan 28 01:21:15 2008 Yukihiro Matsumoto <matz@r...> + + * io.c (rb_open_file): should check NUL in path. + <http://www.rubyist.net/~matz/20080125.html#c01>. + + * io.c (rb_io_s_popen): ditto. + + * io.c (rb_io_reopen): ditto. + + * io.c (next_argv): ditto. + + * io.c (rb_io_s_foreach): ditto. + + * io.c (rb_io_s_readlines): ditto. + + * io.c (rb_io_s_read): ditto. + Fri Jan 25 22:33:38 2008 Yusuke Endoh <mame@t...> * math.c: fix comment. [ruby-dev:33276] Index: ruby_1_8/version.h =================================================================== --- ruby_1_8/version.h (revision 15286) +++ ruby_1_8/version.h (revision 15287) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.6" -#define RUBY_RELEASE_DATE "2008-01-25" +#define RUBY_RELEASE_DATE "2008-01-28" #define RUBY_VERSION_CODE 186 -#define RUBY_RELEASE_CODE 20080125 +#define RUBY_RELEASE_CODE 20080128 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 6 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 25 +#define RUBY_RELEASE_DAY 28 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8/io.c =================================================================== --- ruby_1_8/io.c (revision 15286) +++ ruby_1_8/io.c (revision 15287) @@ -3266,7 +3266,7 @@ mode = rb_io_modenum_mode(FIX2INT(pmode)); } else { - mode = rb_io_flags_mode(rb_io_mode_flags(StringValuePtr(pmode))); + mode = rb_io_flags_mode(rb_io_mode_flags(StringValueCStr(pmode))); } SafeStringValue(pname); port = pipe_open(pname, 0, mode); @@ -3294,12 +3294,13 @@ VALUE io; { VALUE fname, vmode, perm; - char *mode; + char *path, *mode; int flags, fmode; rb_scan_args(argc, argv, "12", &fname, &vmode, &perm); SafeStringValue(fname); + path = StringValueCStr(fname); if (FIXNUM_P(vmode) || !NIL_P(perm)) { if (FIXNUM_P(vmode)) { flags = FIX2INT(vmode); @@ -3310,11 +3311,11 @@ } fmode = NIL_P(perm) ? 0666 : NUM2INT(perm); - rb_file_sysopen_internal(io, RSTRING(fname)->ptr, flags, fmode); + rb_file_sysopen_internal(io, path, flags, fmode); } else { - mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode); - rb_file_open_internal(io, RSTRING(fname)->ptr, mode); + mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode); + rb_file_open_internal(io, path, mode); } return io; } @@ -3667,7 +3668,7 @@ } if (!NIL_P(nmode)) { - fptr->mode = rb_io_mode_flags(StringValuePtr(nmode)); + fptr->mode = rb_io_mode_flags(StringValueCStr(nmode)); } if (fptr->path) { @@ -3675,7 +3676,7 @@ fptr->path = 0; } - fptr->path = strdup(RSTRING(fname)->ptr); + fptr->path = strdup(StringValueCStr(fname)); mode = rb_io_flags_mode(fptr->mode); if (!fptr->f) { fptr->f = rb_fopen(fptr->path, mode); @@ -3686,16 +3687,16 @@ return file; } - if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == 0) { + if (freopen(fptr->path, mode, fptr->f) == 0) { rb_sys_fail(fptr->path); } #ifdef USE_SETVBUF if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0) - rb_warn("setvbuf() can't be honoured for %s", RSTRING(fname)->ptr); + rb_warn("setvbuf() can't be honoured for %s", fptr->path); #endif if (fptr->f2) { - if (freopen(RSTRING(fname)->ptr, "w", fptr->f2) == 0) { + if (freopen(fptr->path, "w", fptr->f2) == 0) { rb_sys_fail(fptr->path); } } @@ -4244,7 +4245,7 @@ } else { SafeStringValue(mode); - flags = rb_io_mode_modenum(RSTRING(mode)->ptr); + flags = rb_io_mode_modenum(StringValueCStr(mode)); } } else { @@ -4414,7 +4415,7 @@ retry: if (RARRAY(rb_argv)->len > 0) { filename = rb_ary_shift(rb_argv); - fn = StringValuePtr(filename); + fn = StringValueCStr(filename); if (strlen(fn) == 1 && fn[0] == '-') { current_file = rb_stdin; if (ruby_inplace_mode) { @@ -5075,7 +5076,7 @@ if (!NIL_P(v)) { StringValue(v); rb_str_modify(v); - arg[i] = (unsigned long)RSTRING(v)->ptr; + arg[i] = (unsigned long)StringValueCStr(v); } else { arg[i] = (unsigned long)NUM2LONG(*argv); @@ -5283,7 +5284,7 @@ else if (!NIL_P(arg.sep)) { StringValue(arg.sep); } - arg.io = rb_io_open(RSTRING(fname)->ptr, "r"); + arg.io = rb_io_open(StringValueCStr(fname), "r"); if (NIL_P(arg.io)) return Qnil; return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io); @@ -5322,7 +5323,7 @@ SafeStringValue(fname); arg.argc = argc - 1; - arg.io = rb_io_open(RSTRING(fname)->ptr, "r"); + arg.io = rb_io_open(StringValueCStr(fname), "r"); if (NIL_P(arg.io)) return Qnil; return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io); } @@ -5360,7 +5361,7 @@ SafeStringValue(fname); arg.argc = argc ? 1 : 0; - arg.io = rb_io_open(RSTRING(fname)->ptr, "r"); + arg.io = rb_io_open(StringValueCStr(fname), "r"); if (NIL_P(arg.io)) return Qnil; if (!NIL_P(offset)) { rb_io_seek(arg.io, offset, SEEK_SET); @@ -5636,7 +5637,7 @@ StringValue(val); if (ruby_inplace_mode) free(ruby_inplace_mode); ruby_inplace_mode = 0; - ruby_inplace_mode = strdup(RSTRING(val)->ptr); + ruby_inplace_mode = strdup(StringValueCStr(val)); } /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/