diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-11 09:18:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-11 09:18:54 +0000 |
commit | 85e32dd2212bc6e5bb2b48c5b6c94e048e84afeb (patch) | |
tree | 09c1328183e4ac51711b93522b53b7f0c62d5b4d | |
parent | 5915dc245e5efac34d676ad29ebd38d6b46f16cf (diff) |
* re.c (match_select): should propagate taintness.
* hash.c (rb_hash_set_default): Hash#default= should return the
new value.
* string.c (rb_str_to_i): accepts optional base argument. [new]
* numeric.c (rb_fix2str): should not handle negative fixnum values
int32 via calling sprintf() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | ToDo | 1 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | bignum.c | 4 | ||||
-rw-r--r-- | class.c | 2 | ||||
-rw-r--r-- | doc/NEWS | 12 | ||||
-rw-r--r-- | error.c | 2 | ||||
-rw-r--r-- | eval.c | 6 | ||||
-rw-r--r-- | ext/tcltklib/extconf.rb | 4 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | intern.h | 2 | ||||
-rw-r--r-- | io.c | 2 | ||||
-rw-r--r-- | numeric.c | 9 | ||||
-rw-r--r-- | object.c | 9 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | process.c | 2 | ||||
-rw-r--r-- | range.c | 2 | ||||
-rw-r--r-- | re.c | 12 | ||||
-rw-r--r-- | string.c | 23 | ||||
-rw-r--r-- | version.c | 4 |
21 files changed, 77 insertions, 45 deletions
@@ -48,6 +48,15 @@ Thu Jan 10 11:42:47 2002 Usaku Nakamura <usa@ruby-lang.org> * win32/resource.rb: Modify copyright in resource script. +Thu Jan 10 07:15:44 2002 takuma ozawa <metal@mine.ne.jp> + + * re.c (match_select): should propagate taintness. + +Thu Jan 10 00:54:57 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * hash.c (rb_hash_set_default): Hash#default= should return the + new value. + Wed Jan 9 20:21:09 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * misc/ruby-mode.el (ruby-calculate-indent): indentation after @@ -56,6 +65,13 @@ Wed Jan 9 20:21:09 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * misc/ruby-mode.el (font-lock-defaults): unless XEmacs, set font-lock variables in ruby-mode-hook. +Tue Jan 8 15:56:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * string.c (rb_str_to_i): accepts optional base argument. [new] + + * numeric.c (rb_fix2str): should not handle negative fixnum values + int32 via calling sprintf() directly. + Tue Jan 8 15:54:02 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * eval.c (rb_add_method): clear replaced method from the cache. @@ -33,6 +33,7 @@ Language Spec. * property - for methods, or for objects in general. * "in" modifier, to annotate, or to encourage assertion. * selector namespace - something like generic-flet in CLOS, to help RubyBehevior +* private instance variable (as in Python?) @_foo in class Foo => @_Foo_foo Hacking Interpreter @@ -6,7 +6,7 @@ $Date$ created at: Fri Aug 6 09:46:12 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -6,7 +6,7 @@ $Date$ created at: Fri Jun 10 00:48:55 JST 1994 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto **********************************************************************/ @@ -351,7 +351,7 @@ rb_str2inum(str, base) p[len] = '\0'; s = p; } - if (len != strlen(s)) { + if (base == 0 && len != strlen(s)) { rb_raise(rb_eArgError, "string for Integer contains null byte"); } return rb_cstr2inum(s, base); @@ -6,7 +6,7 @@ $Date$ created at: Tue Aug 10 15:05:44 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto **********************************************************************/ @@ -1,3 +1,11 @@ +: String#to_i + + Accepts optional base argument. + +: Integer#to_s + + Accepts optional base argument. + : TCPServer#listen, UNIXServer#listen Added. @@ -14,10 +22,6 @@ if $/ == '\n', chops off last newlines (any of \n, \r, \r\n). -: IO#puts - - do not treat Array specially. - : Module::new/Class::new takes block. @@ -6,7 +6,7 @@ $Date$ created at: Mon Aug 9 16:11:34 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto **********************************************************************/ @@ -6,7 +6,7 @@ $Date$ created at: Thu Jun 10 14:22:17 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -317,8 +317,7 @@ remove_method(klass, mid) } rb_clear_cache_by_id(mid); if (FL_TEST(klass, FL_SINGLETON)) { - rb_funcall(rb_iv_get(klass, "__attached__"), - singleton_removed, 1, ID2SYM(mid)); + rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1, ID2SYM(mid)); } else { rb_funcall(klass, removed, 1, ID2SYM(mid)); @@ -680,6 +679,7 @@ dvar_asgn_internal(id, value, curr) while (vars) { if (curr && vars->id == 0) { + /* first null is a dvar header */ n++; if (n == 2) break; } diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb index f732c165dc..fd98b1e7da 100644 --- a/ext/tcltklib/extconf.rb +++ b/ext/tcltklib/extconf.rb @@ -18,7 +18,7 @@ tcllib = with_config("tcllib") stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs") def find_tcl(tcllib, stubs) - paths = ["/usr/local/lib", "/usr/pkg", "/usr/lib"] + paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"] func = stubs ? "Tcl_InitStubs" : "Tcl_FindExecutable" if tcllib find_library(tcllib, func, *paths) @@ -40,7 +40,7 @@ def find_tcl(tcllib, stubs) end def find_tk(tklib, stubs) - paths = ["/usr/local/lib", "/usr/pkg", "/usr/lib"] + paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"] func = stubs ? "Tk_InitStubs" : "Tk_Init" if tklib find_library(tklib, func, *paths) @@ -6,7 +6,7 @@ $Date$ created at: Tue Oct 5 09:44:46 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -347,7 +347,7 @@ rb_hash_set_default(hash, ifnone) rb_hash_modify(hash); RHASH(hash)->ifnone = ifnone; FL_UNSET(hash, HASH_PROC_DEFAULT); - return hash; + return ifnone; } static int @@ -6,7 +6,7 @@ $Date$ created at: Thu Jun 10 14:22:17 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -6,7 +6,7 @@ $Date$ created at: Fri Oct 15 18:08:59 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -954,15 +954,20 @@ rb_fix2str(x, base) VALUE x; int base; { - char fmt[4], buf[22]; + char fmt[4], buf[22], *b = buf; + long val = FIX2LONG(x); fmt[0] = '%'; fmt[1] = 'l'; fmt[3] = '\0'; if (base == 10) fmt[2] = 'd'; else if (base == 16) fmt[2] = 'x'; else if (base == 8) fmt[2] = 'o'; else rb_raise(rb_eArgError, "illegal radix %d", base); + if (val < 0) { + val = -val; + *b++ = '-'; + } - sprintf(buf, fmt, FIX2LONG(x)); + sprintf(b, fmt, val); return rb_str_new2(buf); } @@ -6,7 +6,7 @@ $Date$ created at: Thu Jul 15 12:01:24 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -831,19 +831,12 @@ rb_obj_private_methods(obj) return rb_class_private_instance_methods(1, argv, CLASS_OF(obj)); } -struct arg_to { - VALUE val; - const char *s; - ID m; -}; - static VALUE convert_type(val, tname, method, raise) VALUE val; const char *tname, *method; int raise; { - struct arg_to arg1, arg2; ID m; m = rb_intern(method); @@ -6,7 +6,7 @@ $Date$ created at: Fri May 28 18:02:42 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto **********************************************************************/ @@ -4280,7 +4280,7 @@ gettable(id) else if (id == k__FILE__) { VALUE f = rb_str_new2(ruby_sourcefile); OBJ_FREEZE(f); - return NEW_STR(f); + return NEW_LIT(f); } else if (id == k__LINE__) { return NEW_LIT(INT2FIX(ruby_sourceline)); @@ -6,7 +6,7 @@ $Date$ created at: Tue Aug 10 14:30:50 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -6,7 +6,7 @@ $Date$ created at: Thu Aug 19 17:46:47 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto **********************************************************************/ @@ -829,6 +829,7 @@ match_select(argc, argv, match) VALUE result = rb_ary_new(); int i; long idx; + int taint = OBJ_TAINTED(match); for (i=0; i<argc; i++) { idx = NUM2LONG(argv[i]); @@ -837,8 +838,9 @@ match_select(argc, argv, match) rb_ary_push(result, Qnil); } else { - rb_ary_push(result, rb_str_new(ptr+regs->beg[idx], - regs->end[idx]-regs->beg[idx])); + VALUE str = rb_str_new(ptr+regs->beg[i], regs->end[i]-regs->beg[i]); + if (taint) OBJ_TAINT(str); + rb_ary_push(result, str); } } return result; @@ -981,15 +983,11 @@ static VALUE rb_reg_equal(re1, re2) VALUE re1, re2; { - int min; - if (re1 == re2) return Qtrue; if (TYPE(re2) != T_REGEXP) return Qfalse; rb_reg_check(re1); rb_reg_check(re2); if (RREGEXP(re1)->len != RREGEXP(re2)->len) return Qfalse; - min = RREGEXP(re1)->len; - if (min > RREGEXP(re2)->len) min = RREGEXP(re2)->len; - if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, min) == 0 && + if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, RREGEXP(re1)->len) == 0 && rb_reg_cur_kcode(re1) == rb_reg_cur_kcode(re2) && RREGEXP(re1)->ptr->options == RREGEXP(re2)->ptr->options) { return Qtrue; @@ -6,7 +6,7 @@ $Date$ created at: Mon Aug 9 17:12:58 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Information-technology Promotion Agency, Japan @@ -1748,10 +1748,25 @@ rb_str_include(str, arg) } static VALUE -rb_str_to_i(str) +rb_str_to_i(argc, argv, str) + int argc; + VALUE *argv; VALUE str; { - return rb_str2inum(str, 10); + VALUE b; + int base; + + rb_scan_args(argc, argv, "01", &b); + if (argc == 0) base = 10; + else base = NUM2INT(b); + + switch (base) { + case 2: case 8: case 10: case 16: + break; + default: + rb_raise(rb_eArgError, "illegal radix %d", base); + } + return rb_str2inum(str, base); } static VALUE @@ -3158,7 +3173,7 @@ Init_String() rb_define_method(rb_cString, "rindex", rb_str_rindex, -1); rb_define_method(rb_cString, "replace", rb_str_replace, 1); - rb_define_method(rb_cString, "to_i", rb_str_to_i, 0); + rb_define_method(rb_cString, "to_i", rb_str_to_i, -1); rb_define_method(rb_cString, "to_f", rb_str_to_f, 0); rb_define_method(rb_cString, "to_s", rb_str_to_s, 0); rb_define_method(rb_cString, "to_str", rb_str_to_s, 0); @@ -6,7 +6,7 @@ $Date$ created at: Thu Sep 30 20:08:01 JST 1993 - Copyright (C) 1993-2001 Yukihiro Matsumoto + Copyright (C) 1993-2002 Yukihiro Matsumoto **********************************************************************/ @@ -40,6 +40,6 @@ ruby_show_version() void ruby_show_copyright() { - printf("ruby - Copyright (C) 1993-2001 Yukihiro Matsumoto\n"); + printf("ruby - Copyright (C) 1993-2002 Yukihiro Matsumoto\n"); exit(0); } |