From a4934a42cbb84b6679912226581c71b435671f55 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 4 Nov 2003 09:13:57 +0000 Subject: [PATCH] * io.c (read_all): fptr->f may be NULL, if IO is closed in the signal handler. * io.c (io_read): ditto. * string.c (get_pat): remove 1.8.0 warning code. * string.c (rb_str_match): extend warning until 1.8.2. * string.c (rb_str_match2): ditto. * class.c (class_instance_method_list): remove 1.8.0 warnings. method_list now recurs. [ruby-dev:21816] * class.c (rb_obj_singleton_methods): ditto. * array.c (rb_ary_select): remove select with block. [ruby-dev:21824] * hash.c (rb_hash_select): ditto. * hash.c (env_select): ditto. * re.c (match_select): ditto. * struct.c (rb_struct_select): ditto. * process.c (check_uid_switch): remove duplicated error messages. * process.c (check_gid_switch): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 35 ++++++++++++++ MANIFEST | 1 + array.c | 11 ++--- class.c | 9 ---- error.c | 1 + eval.c | 1 - file.c | 2 +- hash.c | 10 ---- io.c | 2 + process.c | 138 +++++++++++++++++------------------------------------- re.c | 4 -- string.c | 25 +++------- struct.c | 4 -- 13 files changed, 92 insertions(+), 151 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2692c1d98343d7..7a6491ee1fd634 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +Tue Nov 4 06:54:52 2003 Yukihiro Matsumoto + + * io.c (read_all): fptr->f may be NULL, if IO is closed in the + signal handler. + + * io.c (io_read): ditto. + + * string.c (get_pat): remove 1.8.0 warning code. + + * string.c (rb_str_match): extend warning until 1.8.2. + + * string.c (rb_str_match2): ditto. + + * class.c (class_instance_method_list): remove 1.8.0 warnings. + method_list now recurs. [ruby-dev:21816] + + * class.c (rb_obj_singleton_methods): ditto. + + * array.c (rb_ary_select): remove select with block. + [ruby-dev:21824] + + * hash.c (rb_hash_select): ditto. + + * hash.c (env_select): ditto. + + * re.c (match_select): ditto. + + * struct.c (rb_struct_select): ditto. + Mon Nov 3 22:53:21 2003 Minero Aoki * lib/racc/parser.rb: synchronize with Racc 1.4.4. @@ -7,6 +36,12 @@ Mon Nov 3 22:53:21 2003 Minero Aoki * ext/racc/cparse/cparse.c (parse_main): should abort when the length of LR state stack <=1, not ==0. +Mon Nov 3 08:50:47 2003 Yukihiro Matsumoto + + * process.c (check_uid_switch): remove duplicated error messages. + + * process.c (check_gid_switch): ditto. + Sun Nov 2 02:28:33 2003 GOTOU Yuuzou * lib/webrick/ssl.rb: new option :SSLExtraChainCert. diff --git a/MANIFEST b/MANIFEST index 78df503fe6cf04..ccb4eef0dba6c2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -342,6 +342,7 @@ lib/test/unit/ui/fox/testrunner.rb lib/test/unit/ui/gtk/testrunner.rb lib/test/unit/ui/testrunnermediator.rb lib/test/unit/ui/testrunnerutilities.rb +lib/test/unit/ui/tk/testrunner.rb lib/test/unit/util/backtracefilter.rb lib/test/unit/util/observable.rb lib/test/unit/util/procwrapper.rb diff --git a/array.c b/array.c index ed562060d2a25b..ac2bb7d265c88b 100644 --- a/array.c +++ b/array.c @@ -254,8 +254,8 @@ rb_ary_initialize(argc, argv, ary) if (rb_block_given_p()) { long i; - if (argc > 1) { - rb_raise(rb_eArgError, "wrong number of arguments"); + if (argc == 2) { + rb_warn("block supersedes default value argument"); } for (i=0; iptr[i] = rb_yield(LONG2NUM(i)); @@ -655,8 +655,7 @@ rb_ary_indexes(argc, argv, ary) VALUE new_ary; long i; - rb_warn("Array#%s is deprecated; use Array#values_at", - rb_id2name(rb_frame_last_func())); + rb_warn("Array#%s is deprecated; use Array#values_at", rb_id2name(rb_frame_last_func())); new_ary = rb_ary_new2(argc); for (i=0; i 0) { rb_raise(rb_eArgError, "wrong number arguments (%d for 0)", argc); } diff --git a/class.c b/class.c index f137e698b67250..8132f8c5ca8bc9 100644 --- a/class.c +++ b/class.c @@ -539,12 +539,7 @@ class_instance_method_list(argc, argv, mod, func) st_table *list; if (argc == 0) { -#if RUBY_VERSION_CODE < 181 - rb_warn("%s: parameter will default to 'true' as of 1.8.1", rb_id2name(rb_frame_last_func())); - recur = Qfalse; -#else recur = Qtrue; -#endif } else { VALUE r; @@ -613,11 +608,7 @@ rb_obj_singleton_methods(argc, argv, obj) rb_scan_args(argc, argv, "01", &recur); if (argc == 0) { -#if RUBY_VERSION_CODE < 181 - rb_warn("singleton_methods: parameter will default to 'true' as of 1.8.1"); -#else recur = Qtrue; -#endif } klass = CLASS_OF(obj); list = st_init_numtable(); diff --git a/error.c b/error.c index f2a3c8ba5fb7e4..2baf3b1ba77ce1 100644 --- a/error.c +++ b/error.c @@ -480,6 +480,7 @@ name_err_initialize(argc, argv, self) VALUE self; { VALUE name = (argc > 1) ? argv[--argc] : Qnil; + exc_initialize(argc, argv, self); rb_iv_set(self, "name", name); return self; diff --git a/eval.c b/eval.c index 56e6614c604e9e..98e75e933b1e10 100644 --- a/eval.c +++ b/eval.c @@ -4727,7 +4727,6 @@ rb_method_missing(argc, argv, obj) id = SYM2ID(argv[0]); - switch (TYPE(obj)) { case T_NIL: desc = "nil"; diff --git a/file.c b/file.c index 3fe815006519a9..4935dc1690250e 100644 --- a/file.c +++ b/file.c @@ -99,7 +99,7 @@ rb_file_path(obj) fptr = RFILE(rb_io_taint_check(obj))->fptr; if (!fptr->path) return Qnil; - return rb_str_new2(fptr->path); + return rb_tainted_str_new2(fptr->path); } static VALUE diff --git a/hash.c b/hash.c index 245f6fb4c6e461..cc9af8a4f0609c 100644 --- a/hash.c +++ b/hash.c @@ -529,12 +529,6 @@ rb_hash_select(argc, argv, hash) { VALUE result; - if (!rb_block_given_p()) { -#if RUBY_VERSION_CODE < 181 - rb_warn("Hash#select(key..) is deprecated; use Hash#values_at"); -#endif - return rb_hash_values_at(argc, argv, hash); - } if (argc > 0) { rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); } @@ -1454,10 +1448,6 @@ env_select(argc, argv) VALUE result; char **env; - if (!rb_block_given_p()) { - rb_warn("ENV.select(index..) is deprecated; use ENV.values_at"); - return env_values_at(argc, argv); - } if (argc > 0) { rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); } diff --git a/io.c b/io.c index cac35eb7e60def..28504c91972481 100644 --- a/io.c +++ b/io.c @@ -790,6 +790,7 @@ read_all(fptr, siz, str) n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f); if (pos > 0 && n == 0 && bytes == 0) { rb_str_resize(str,0); + if (!fptr->f) return Qnil; if (feof(fptr->f)) return Qnil; if (!ferror(fptr->f)) return str; rb_sys_fail(fptr->path); @@ -843,6 +844,7 @@ io_read(argc, argv, io) n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f); if (n == 0) { rb_str_resize(str,0); + if (!fptr->f) return Qnil; if (feof(fptr->f)) return Qnil; if (len > 0) rb_sys_fail(fptr->path); } diff --git a/process.c b/process.c index ed7ae86dcd114c..17ec62fc11305f 100644 --- a/process.c +++ b/process.c @@ -1238,17 +1238,31 @@ proc_setpriority(obj, which, who, prio) } static int under_uid_switch = 0; +static void +check_uid_switch() +{ + rb_secure(2); + if (under_uid_switch) { + rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); + } +} + static int under_gid_switch = 0; +static void +check_gid_switch() +{ + rb_secure(2); + if (under_gid_switch) { + rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::UID.switch method"); + } +} static VALUE p_sys_setuid(obj, id) VALUE obj, id; { #if defined HAVE_SETUID - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); if (setuid(NUM2INT(id)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1261,10 +1275,7 @@ p_sys_setruid(obj, id) VALUE obj, id; { #if defined HAVE_SETRUID - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); if (setruid(NUM2INT(id)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1277,10 +1288,7 @@ p_sys_seteuid(obj, id) VALUE obj, id; { #if defined HAVE_SETEUID - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); if (seteuid(NUM2INT(id)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1293,10 +1301,7 @@ p_sys_setreuid(obj, rid, eid) VALUE obj, rid, eid; { #if defined HAVE_SETREUID - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); if (setreuid(NUM2INT(rid),NUM2INT(eid)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1309,10 +1314,7 @@ p_sys_setresuid(obj, rid, eid, sid) VALUE obj, rid, eid, sid; { #if defined HAVE_SETRESUID - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); if (setresuid(NUM2INT(rid),NUM2INT(eid),NUM2INT(sid)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1334,10 +1336,7 @@ proc_setuid(obj, id) { int uid = NUM2INT(id); - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); #if defined(HAVE_SETRESUID) && !defined(__CHECKER__) if (setresuid(uid, -1, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREUID @@ -1368,10 +1367,7 @@ p_uid_change_privilege(obj, id) extern int errno; int uid; - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); uid = NUM2INT(id); @@ -1509,10 +1505,7 @@ p_sys_setgid(obj, id) VALUE obj, id; { #if defined HAVE_SETGID - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); if (setgid(NUM2INT(id)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1525,10 +1518,7 @@ p_sys_setrgid(obj, id) VALUE obj, id; { #if defined HAVE_SETRGID - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); if (setrgid(NUM2INT(id)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1541,10 +1531,7 @@ p_sys_setegid(obj, id) VALUE obj, id; { #if defined HAVE_SETEGID - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); if (setegid(NUM2INT(id)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1557,10 +1544,7 @@ p_sys_setregid(obj, rid, eid) VALUE obj, rid, eid; { #if defined HAVE_SETREGID - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); if (setregid(NUM2INT(rid),NUM2INT(eid)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1573,10 +1557,7 @@ p_sys_setresgid(obj, rid, eid, sid) VALUE obj, rid, eid, sid; { #if defined HAVE_SETRESGID - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); if (setresgid(NUM2INT(rid),NUM2INT(eid),NUM2INT(sid)) != 0) rb_sys_fail(0); #else rb_notimplement(); @@ -1614,10 +1595,7 @@ proc_setgid(obj, id) { int gid = NUM2INT(id); - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); #if defined(HAVE_SETRESGID) && !defined(__CHECKER__) if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREGID @@ -1763,10 +1741,7 @@ p_gid_change_privilege(obj, id) extern int errno; int gid; - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); gid = NUM2INT(id); @@ -1912,10 +1887,7 @@ static VALUE proc_seteuid(obj, euid) VALUE obj, euid; { - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); #if defined(HAVE_SETRESUID) && !defined(__CHECKER__) if (setresuid(-1, NUM2INT(euid), -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREUID @@ -1942,10 +1914,7 @@ rb_seteuid_core(euid) { int uid; - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); uid = getuid(); @@ -1994,10 +1963,8 @@ static VALUE proc_setegid(obj, egid) VALUE obj, egid; { - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); + #if defined(HAVE_SETRESGID) && !defined(__CHECKER__) if (setresgid(-1, NUM2INT(egid), -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREGID @@ -2024,10 +1991,7 @@ rb_setegid_core(egid) { int gid; - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); gid = getgid(); @@ -2081,10 +2045,7 @@ p_uid_exchange(obj) { int uid, euid; - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); uid = getuid(); euid = geteuid(); @@ -2119,10 +2080,7 @@ p_gid_exchange(obj) { int gid, egid; - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); gid = getgid(); egid = getegid(); @@ -2166,10 +2124,7 @@ p_uid_switch(obj) extern int errno; int uid, euid; - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); uid = getuid(); euid = geteuid(); @@ -2211,10 +2166,7 @@ p_uid_switch(obj) extern int errno; int uid, euid; - rb_secure(2); - if (under_uid_switch) { - rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method"); - } + check_uid_switch(); uid = getuid(); euid = geteuid(); @@ -2259,10 +2211,7 @@ p_gid_switch(obj) extern int errno; int gid, egid; - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); gid = getgid(); egid = getegid(); @@ -2303,10 +2252,7 @@ p_gid_switch(obj) extern int errno; int gid, egid; - rb_secure(2); - if (under_gid_switch) { - rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::GID.switch method"); - } + check_gid_switch(); gid = getgid(); egid = getegid(); diff --git a/re.c b/re.c index 24fc697e07b340..29f5a89d16ec83 100644 --- a/re.c +++ b/re.c @@ -992,10 +992,6 @@ match_select(argc, argv, match) VALUE *argv; VALUE match; { - if (!rb_block_given_p()) { - rb_warn("MatchData#select(index..) is deprecated; use MatchData#values_at"); - return match_values_at(argc, argv, match); - } if (argc > 0) { rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); } diff --git a/string.c b/string.c index 2d991f6e538e76..eebc61cd102866 100644 --- a/string.c +++ b/string.c @@ -1056,19 +1056,14 @@ rb_str_match(x, y) long start; switch (TYPE(y)) { - case T_REGEXP: - return rb_reg_match(y, x); - case T_STRING: -#if RUBY_VERSION_CODE < 181 +#if RUBY_VERSION_CODE < 182 rb_warn("string =~ string will be obsolete; use explicit regexp"); #endif - reg = rb_reg_regcomp(y); - start = rb_reg_search(reg, x, 0, 0); - if (start == -1) { - return Qnil; - } - return INT2NUM(start); + y = rb_reg_regcomp(y); + /* fall through */ + case T_REGEXP: + return rb_reg_match(y, x); default: return rb_funcall(y, rb_intern("=~"), 1, x); @@ -1080,7 +1075,7 @@ rb_str_match2(str) VALUE str; { StringValue(str); -#if RUBY_VERSION_CODE < 181 +#if RUBY_VERSION_CODE < 182 rb_warn("~string will be obsolete; use explicit regexp"); #endif return rb_reg_match2(rb_reg_regcomp(rb_reg_quote(str))); @@ -1501,13 +1496,7 @@ get_pat(pat, quote) } if (quote) { - val = rb_reg_quote(pat); -#if RUBY_VERSION_CODE < 181 - if (val != pat && rb_str_cmp(val, pat) != 0) { - rb_warn("string pattern instead of regexp; metacharacters no longer effective"); - } -#endif - pat = val; + pat = rb_reg_quote(pat); } return rb_reg_regcomp(pat); diff --git a/struct.c b/struct.c index 474b267cf29c98..73a7f5aeea9274 100644 --- a/struct.c +++ b/struct.c @@ -544,10 +544,6 @@ rb_struct_select(argc, argv, s) VALUE result; long i; - if (!rb_block_given_p()) { - rb_warn("Struct#select(index..) is deprecated; use Struct#values_at"); - return rb_struct_values_at(argc, argv, s); - } if (argc > 0) { rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); }