Skip to content

Commit

Permalink
* re.c (match_select): should propagate taintness.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matz committed Jan 11, 2002
1 parent 5915dc2 commit 85e32dd
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 45 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ Thu Jan 10 11:42:47 2002 Usaku Nakamura <[email protected]>

* win32/resource.rb: Modify copyright in resource script.

Thu Jan 10 07:15:44 2002 takuma ozawa <[email protected]>

* re.c (match_select): should propagate taintness.

Thu Jan 10 00:54:57 2002 Yukihiro Matsumoto <[email protected]>

* hash.c (rb_hash_set_default): Hash#default= should return the
new value.

Wed Jan 9 20:21:09 2002 Nobuyoshi Nakada <[email protected]>

* misc/ruby-mode.el (ruby-calculate-indent): indentation after
Expand All @@ -56,6 +65,13 @@ Wed Jan 9 20:21:09 2002 Nobuyoshi Nakada <[email protected]>
* 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 <[email protected]>

* 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 <[email protected]>

* eval.c (rb_add_method): clear replaced method from the cache.
Expand Down
1 change: 1 addition & 0 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********************************************************************/

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********************************************************************/

Expand Down
12 changes: 8 additions & 4 deletions doc/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
: String#to_i

Accepts optional base argument.

: Integer#to_s

Accepts optional base argument.

: TCPServer#listen, UNIXServer#listen

Added.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********************************************************************/

Expand Down
6 changes: 3 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/tcltklib/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 1 addition & 8 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********************************************************************/

Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion range.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********************************************************************/

Expand Down
12 changes: 5 additions & 7 deletions re.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 19 additions & 4 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions version.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********************************************************************/

Expand Down Expand Up @@ -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);
}

0 comments on commit 85e32dd

Please sign in to comment.