mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
023fd910dd
commit
5074a2003f
3 changed files with 44 additions and 20 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
||||||
|
Sun Jan 27 03:48:40 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
Sun Jan 27 03:48:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
Sun Jan 27 03:47:51 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
Mon Jan 28 01:21:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@tsg.ne.jp>
|
Fri Jan 25 22:33:38 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* math.c: fix comment. [ruby-dev:33276]
|
* math.c: fix comment. [ruby-dev:33276]
|
||||||
|
|
35
io.c
35
io.c
|
@ -3266,7 +3266,7 @@ rb_io_s_popen(argc, argv, klass)
|
||||||
mode = rb_io_modenum_mode(FIX2INT(pmode));
|
mode = rb_io_modenum_mode(FIX2INT(pmode));
|
||||||
}
|
}
|
||||||
else {
|
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);
|
SafeStringValue(pname);
|
||||||
port = pipe_open(pname, 0, mode);
|
port = pipe_open(pname, 0, mode);
|
||||||
|
@ -3294,12 +3294,13 @@ rb_open_file(argc, argv, io)
|
||||||
VALUE io;
|
VALUE io;
|
||||||
{
|
{
|
||||||
VALUE fname, vmode, perm;
|
VALUE fname, vmode, perm;
|
||||||
char *mode;
|
char *path, *mode;
|
||||||
int flags, fmode;
|
int flags, fmode;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||||
SafeStringValue(fname);
|
SafeStringValue(fname);
|
||||||
|
|
||||||
|
path = StringValueCStr(fname);
|
||||||
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
|
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
|
||||||
if (FIXNUM_P(vmode)) {
|
if (FIXNUM_P(vmode)) {
|
||||||
flags = FIX2INT(vmode);
|
flags = FIX2INT(vmode);
|
||||||
|
@ -3310,11 +3311,11 @@ rb_open_file(argc, argv, io)
|
||||||
}
|
}
|
||||||
fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
|
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 {
|
else {
|
||||||
mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
|
mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode);
|
||||||
rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
|
rb_file_open_internal(io, path, mode);
|
||||||
}
|
}
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
@ -3667,7 +3668,7 @@ rb_io_reopen(argc, argv, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NIL_P(nmode)) {
|
if (!NIL_P(nmode)) {
|
||||||
fptr->mode = rb_io_mode_flags(StringValuePtr(nmode));
|
fptr->mode = rb_io_mode_flags(StringValueCStr(nmode));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fptr->path) {
|
if (fptr->path) {
|
||||||
|
@ -3675,7 +3676,7 @@ rb_io_reopen(argc, argv, file)
|
||||||
fptr->path = 0;
|
fptr->path = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fptr->path = strdup(RSTRING(fname)->ptr);
|
fptr->path = strdup(StringValueCStr(fname));
|
||||||
mode = rb_io_flags_mode(fptr->mode);
|
mode = rb_io_flags_mode(fptr->mode);
|
||||||
if (!fptr->f) {
|
if (!fptr->f) {
|
||||||
fptr->f = rb_fopen(fptr->path, mode);
|
fptr->f = rb_fopen(fptr->path, mode);
|
||||||
|
@ -3686,16 +3687,16 @@ rb_io_reopen(argc, argv, file)
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == 0) {
|
if (freopen(fptr->path, mode, fptr->f) == 0) {
|
||||||
rb_sys_fail(fptr->path);
|
rb_sys_fail(fptr->path);
|
||||||
}
|
}
|
||||||
#ifdef USE_SETVBUF
|
#ifdef USE_SETVBUF
|
||||||
if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0)
|
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
|
#endif
|
||||||
|
|
||||||
if (fptr->f2) {
|
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);
|
rb_sys_fail(fptr->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4244,7 +4245,7 @@ rb_io_initialize(argc, argv, io)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SafeStringValue(mode);
|
SafeStringValue(mode);
|
||||||
flags = rb_io_mode_modenum(RSTRING(mode)->ptr);
|
flags = rb_io_mode_modenum(StringValueCStr(mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -4414,7 +4415,7 @@ next_argv()
|
||||||
retry:
|
retry:
|
||||||
if (RARRAY(rb_argv)->len > 0) {
|
if (RARRAY(rb_argv)->len > 0) {
|
||||||
filename = rb_ary_shift(rb_argv);
|
filename = rb_ary_shift(rb_argv);
|
||||||
fn = StringValuePtr(filename);
|
fn = StringValueCStr(filename);
|
||||||
if (strlen(fn) == 1 && fn[0] == '-') {
|
if (strlen(fn) == 1 && fn[0] == '-') {
|
||||||
current_file = rb_stdin;
|
current_file = rb_stdin;
|
||||||
if (ruby_inplace_mode) {
|
if (ruby_inplace_mode) {
|
||||||
|
@ -5075,7 +5076,7 @@ rb_f_syscall(argc, argv)
|
||||||
if (!NIL_P(v)) {
|
if (!NIL_P(v)) {
|
||||||
StringValue(v);
|
StringValue(v);
|
||||||
rb_str_modify(v);
|
rb_str_modify(v);
|
||||||
arg[i] = (unsigned long)RSTRING(v)->ptr;
|
arg[i] = (unsigned long)StringValueCStr(v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arg[i] = (unsigned long)NUM2LONG(*argv);
|
arg[i] = (unsigned long)NUM2LONG(*argv);
|
||||||
|
@ -5283,7 +5284,7 @@ rb_io_s_foreach(argc, argv)
|
||||||
else if (!NIL_P(arg.sep)) {
|
else if (!NIL_P(arg.sep)) {
|
||||||
StringValue(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;
|
if (NIL_P(arg.io)) return Qnil;
|
||||||
|
|
||||||
return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io);
|
return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io);
|
||||||
|
@ -5322,7 +5323,7 @@ rb_io_s_readlines(argc, argv, io)
|
||||||
SafeStringValue(fname);
|
SafeStringValue(fname);
|
||||||
|
|
||||||
arg.argc = argc - 1;
|
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;
|
if (NIL_P(arg.io)) return Qnil;
|
||||||
return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io);
|
return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io);
|
||||||
}
|
}
|
||||||
|
@ -5360,7 +5361,7 @@ rb_io_s_read(argc, argv, io)
|
||||||
SafeStringValue(fname);
|
SafeStringValue(fname);
|
||||||
|
|
||||||
arg.argc = argc ? 1 : 0;
|
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(arg.io)) return Qnil;
|
||||||
if (!NIL_P(offset)) {
|
if (!NIL_P(offset)) {
|
||||||
rb_io_seek(arg.io, offset, SEEK_SET);
|
rb_io_seek(arg.io, offset, SEEK_SET);
|
||||||
|
@ -5636,7 +5637,7 @@ opt_i_set(val)
|
||||||
StringValue(val);
|
StringValue(val);
|
||||||
if (ruby_inplace_mode) free(ruby_inplace_mode);
|
if (ruby_inplace_mode) free(ruby_inplace_mode);
|
||||||
ruby_inplace_mode = 0;
|
ruby_inplace_mode = 0;
|
||||||
ruby_inplace_mode = strdup(RSTRING(val)->ptr);
|
ruby_inplace_mode = strdup(StringValueCStr(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#define RUBY_VERSION "1.8.6"
|
#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_VERSION_CODE 186
|
||||||
#define RUBY_RELEASE_CODE 20080125
|
#define RUBY_RELEASE_CODE 20080128
|
||||||
#define RUBY_PATCHLEVEL 5000
|
#define RUBY_PATCHLEVEL 5000
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define RUBY_VERSION_TEENY 6
|
#define RUBY_VERSION_TEENY 6
|
||||||
#define RUBY_RELEASE_YEAR 2008
|
#define RUBY_RELEASE_YEAR 2008
|
||||||
#define RUBY_RELEASE_MONTH 1
|
#define RUBY_RELEASE_MONTH 1
|
||||||
#define RUBY_RELEASE_DAY 25
|
#define RUBY_RELEASE_DAY 28
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue