1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

2000-03-17

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-03-17 08:58:21 +00:00
parent d8f981b972
commit 5c13dd59db
18 changed files with 129 additions and 62 deletions

View file

@ -1,3 +1,27 @@
Fri Mar 17 15:02:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* variable.c (rb_autoload_id): defining new autoload should be
prohibited for $SAFE > 4.
* variable.c (rb_autoload_load): autoload should be possible for
$SAFE > 4.
* eval.c (call_trace_func): should handle T_ICLASS properly.
Fri Mar 17 14:34:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (str_gsub): forgot to initialize str->orig.
Fri Mar 17 01:24:59 2000 Dave Thomas <Dave@thomases.com>
* string.c (rb_str_clone): forgot to copy str->orig if STR_NO_ORIG
is set by Array#pack.
Wed Mar 15 21:25:04 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* array.c (rb_ary_join): 'result' is always duplicated
before concat string.
Wed Mar 15 17:26:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp> Wed Mar 15 17:26:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* hash.c (rb_hash_s_create): unexpected recursive call removed. * hash.c (rb_hash_s_create): unexpected recursive call removed.

View file

@ -704,7 +704,7 @@ rb_ary_join(ary, sep)
} }
break; break;
default: default:
result = rb_obj_as_string(tmp); result = rb_str_dup(rb_obj_as_string(tmp));
break; break;
} }

2
configure vendored
View file

@ -4934,7 +4934,7 @@ case "$target_os" in
CFLAGS="$CFLAGS -pipe -no-precomp" CFLAGS="$CFLAGS -pipe -no-precomp"
;; ;;
osf*) osf*)
if $without_gcc = "yes" ; then if test "$without_gcc" = "no" ; then
CFLAGS="$CFLAGS -ansi" CFLAGS="$CFLAGS -ansi"
else else
# compile something small: taint.c is fine for this. # compile something small: taint.c is fine for this.

View file

@ -775,7 +775,7 @@ case "$target_os" in
CFLAGS="$CFLAGS -pipe -no-precomp" CFLAGS="$CFLAGS -pipe -no-precomp"
;; ;;
osf*) osf*)
if [ $without_gcc = "yes" ]; then if test "$without_gcc" = "no" ; then
CFLAGS="$CFLAGS -ansi" CFLAGS="$CFLAGS -ansi"
else else
# compile something small: taint.c is fine for this. # compile something small: taint.c is fine for this.

14
eval.c
View file

@ -1804,7 +1804,10 @@ call_trace_func(event, file, line, self, id, klass)
ruby_frame->file = ruby_sourcefile = file; ruby_frame->file = ruby_sourcefile = file;
} }
if (klass) { if (klass) {
if (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) { if (TYPE(klass) == T_ICLASS) {
klass = RBASIC(klass)->klass;
}
else if (FL_TEST(klass, FL_SINGLETON)) {
klass = self; klass = self;
} }
} }
@ -1814,7 +1817,7 @@ call_trace_func(event, file, line, self, id, klass)
proc_call(trace_func, rb_ary_new3(6, rb_str_new2(event), proc_call(trace_func, rb_ary_new3(6, rb_str_new2(event),
srcfile, srcfile,
INT2FIX(ruby_sourceline), INT2FIX(ruby_sourceline),
INT2FIX(id), id?ID2SYM(id):Qnil,
self?rb_f_binding(self):Qnil, self?rb_f_binding(self):Qnil,
klass)); klass));
} }
@ -4002,7 +4005,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
line = ruby_sourceline; line = ruby_sourceline;
} }
call_trace_func("c-call", 0, 0, 0, id, klass); call_trace_func("c-call", 0, 0, recv, id, klass);
PUSH_TAG(PROT_FUNC); PUSH_TAG(PROT_FUNC);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv); result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
@ -4563,7 +4566,12 @@ rb_f_eval(argc, argv, self)
line = NUM2INT(vline); line = NUM2INT(vline);
} }
if (ruby_safe_level >= 3) {
Check_Type(src, T_STRING);
}
else {
Check_SafeStr(src); Check_SafeStr(src);
}
if (NIL_P(scope) && ruby_frame->prev) { if (NIL_P(scope) && ruby_frame->prev) {
struct FRAME *prev; struct FRAME *prev;
VALUE val; VALUE val;

View file

@ -1062,15 +1062,13 @@ module TkSelection
tk_call 'selection', 'get', type tk_call 'selection', 'get', type
end end
def TkSelection.handle(win, func, type=None, format=None) def TkSelection.handle(win, func, type=None, format=None)
id = install_cmd(func) tk_call 'selection', 'handle', win.path, func, type, format
tk_call 'selection', 'handle', win.path, id, type, format
end end
def handle(func, type=None, format=None) def handle(func, type=None, format=None)
TkSelection.handle self, func, type, format TkSelection.handle self, func, type, format
end end
def TkSelection.own(win, func=None) def TkSelection.own(win=None, func=None)
id = install_cmd(func) window(tk_call 'selection', 'own', win, func)
tk_call 'selection', 'own', win.path, id
end end
def own(func=None) def own(func=None)
TkSelection.own self, func TkSelection.own self, func

View file

@ -132,7 +132,7 @@ class TkText<TkTextWin
WidgetClassName WidgetClassName
end end
def self.new(*args) def self.new(*args, &block)
obj = super(*args){} obj = super(*args){}
obj.init_instance_variable obj.init_instance_variable
obj.instance_eval &block if defined? yield obj.instance_eval &block if defined? yield

1
file.c
View file

@ -1961,6 +1961,7 @@ path_check_1(path)
#else #else
if (getwd(buf) == 0) return 0; if (getwd(buf) == 0) return 0;
#endif #endif
strncat(buf, "/", MAXPATHLEN);
strncat(buf, path, MAXPATHLEN); strncat(buf, path, MAXPATHLEN);
buf[MAXPATHLEN] = '\0'; buf[MAXPATHLEN] = '\0';
return path_check_1(buf); return path_check_1(buf);

View file

@ -292,6 +292,7 @@ int rb_str_cmp _((VALUE, VALUE));
VALUE rb_str_upto _((VALUE, VALUE, int)); VALUE rb_str_upto _((VALUE, VALUE, int));
VALUE rb_str_inspect _((VALUE)); VALUE rb_str_inspect _((VALUE));
VALUE rb_str_split _((VALUE, const char*)); VALUE rb_str_split _((VALUE, const char*));
void rb_str_associate _((VALUE, VALUE));
/* struct.c */ /* struct.c */
VALUE rb_struct_new __((VALUE, ...)); VALUE rb_struct_new __((VALUE, ...));
VALUE rb_struct_define __((const char*, ...)); VALUE rb_struct_define __((const char*, ...));

View file

@ -445,9 +445,9 @@ class DEBUGGER__
n += 1 n += 1
break unless bind break unless bind
if pos == n if pos == n
stdout.printf "--> #%d %s:%s%s\n", n, file, line, id != 0 ? ":in `#{id.id2name}'":"" stdout.printf "--> #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
else else
stdout.printf " #%d %s:%s%s\n", n, file, line, id != 0 ? ":in `#{id.id2name}'":"" stdout.printf " #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
end end
end end
end end

View file

@ -420,6 +420,7 @@ class Matrix
vij = 0 vij = 0
0.upto(column_size - 1) do 0.upto(column_size - 1) do
|k| |k|
p [k,j,m[k,j]]
vij += self[i, k] * m[k, j] vij += self[i, k] * m[k, j]
end end
vij vij

View file

@ -3,7 +3,7 @@ module Profiler__
Start = Float(Time.times[0]) Start = Float(Time.times[0])
top = "toplevel".intern top = "toplevel".intern
Stack = [[0, 0, top]] Stack = [[0, 0, top]]
MAP = {top => [1, 0, 0, "#toplevel"]} MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]}
p = proc{|event, file, line, id, binding, klass| p = proc{|event, file, line, id, binding, klass|
case event case event
@ -13,8 +13,6 @@ module Profiler__
when "return", "c-return" when "return", "c-return"
now = Float(Time.times[0]) now = Float(Time.times[0])
tick = Stack.pop tick = Stack.pop
data = MAP[id]
unless data
name = klass.to_s name = klass.to_s
if name.nil? then name = '' end if name.nil? then name = '' end
if klass.kind_of? Class if klass.kind_of? Class
@ -22,8 +20,11 @@ module Profiler__
else else
name += "." name += "."
end end
data = [0.0, 0.0, 0.0, name+id.id2name] name += id.id2name
MAP[id] = data data = MAP[name]
unless data
data = [0.0, 0.0, 0.0, name]
MAP[name] = data
end end
data[0] += 1 data[0] += 1
cost = now - tick[0] cost = now - tick[0]
@ -36,7 +37,7 @@ module Profiler__
set_trace_func nil set_trace_func nil
total = Float(Time.times[0]) - Start total = Float(Time.times[0]) - Start
if total == 0 then total = 0.01 end if total == 0 then total = 0.01 end
MAP[:toplevel][1] = total MAP["#toplevel"][1] = total
# f = open("./rmon.out", "w") # f = open("./rmon.out", "w")
f = STDERR f = STDERR
data = MAP.values.sort!{|a,b| b[2] <=> a[2]} data = MAP.values.sort!{|a,b| b[2] <=> a[2]}

View file

@ -63,10 +63,14 @@ class Mutex
def unlock def unlock
return unless @locked return unless @locked
Thread.critical = true Thread.critical = true
t = @waiting.shift
@locked = false @locked = false
begin
t = @waiting.shift
t.wakeup if t
rescue ThreadError
retry
end
Thread.critical = false Thread.critical = false
t.run if t
self self
end end
@ -82,9 +86,13 @@ class Mutex
def exclusive_unlock def exclusive_unlock
return unless @locked return unless @locked
Thread.exclusive do Thread.exclusive do
t = @waiting.shift
@locked = false @locked = false
begin
t = @waiting.shift
t.wakeup if t t.wakeup if t
rescue ThreadError
retry
end
yield yield
end end
self self
@ -105,8 +113,12 @@ class ConditionVariable
end end
def signal def signal
begin
t = @waiters.shift t = @waiters.shift
t.run if t t.run if t
rescue ThreadError
retry
end
end end
def broadcast def broadcast
@ -116,7 +128,10 @@ class ConditionVariable
@waiters.clear @waiters.clear
end end
for t in waiters0 for t in waiters0
begin
t.run t.run
rescue ThreadError
end
end end
end end
end end
@ -133,9 +148,13 @@ class Queue
def push(obj) def push(obj)
Thread.critical = true Thread.critical = true
@que.push obj @que.push obj
begin
t = @waiting.shift t = @waiting.shift
t.wakeup if t
rescue ThreadError
retry
end
Thread.critical = false Thread.critical = false
t.run if t
end end
alias enq push alias enq push
@ -201,8 +220,12 @@ class SizedQueue<Queue
@max = max @max = max
Thread.critical = false Thread.critical = false
diff.times do diff.times do
begin
t = @queue_wait.shift t = @queue_wait.shift
t.run if t t.run if t
rescue ThreadError
retry
end
end end
end end
max max
@ -221,8 +244,12 @@ class SizedQueue<Queue
def pop(*args) def pop(*args)
Thread.critical = true Thread.critical = true
if @que.length < @max if @que.length < @max
begin
t = @queue_wait.shift t = @queue_wait.shift
t.run if t t.run if t
rescue ThreadError
retry
end
end end
super super
end end

14
pack.c
View file

@ -301,18 +301,6 @@ static void qpencode _((VALUE,VALUE,int));
static int uv_to_utf8 _((char*,unsigned long)); static int uv_to_utf8 _((char*,unsigned long));
static unsigned long utf8_to_uv _((char*,int*)); static unsigned long utf8_to_uv _((char*,int*));
static void
pack_add_ptr(str, add)
VALUE str, add;
{
#define STR_NO_ORIG FL_USER2 /* copied from string.c */
if (!RSTRING(str)->orig) {
RSTRING(str)->orig = rb_ary_new();
FL_SET(str, STR_NO_ORIG);
}
rb_ary_push(RSTRING(str)->orig, add);
}
static VALUE static VALUE
pack_pack(ary, fmt) pack_pack(ary, fmt)
VALUE ary, fmt; VALUE ary, fmt;
@ -849,7 +837,7 @@ pack_pack(ary, fmt)
if (NIL_P(from)) t = ""; if (NIL_P(from)) t = "";
else { else {
t = STR2CSTR(from); t = STR2CSTR(from);
pack_add_ptr(res, from); rb_str_associate(res, from);
} }
rb_str_cat(res, (char*)&t, sizeof(char*)); rb_str_cat(res, (char*)&t, sizeof(char*));
} }

View file

@ -141,6 +141,20 @@ rb_str_become(str, str2)
if (OBJ_TAINTED(str2)) OBJ_TAINT(str); if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
} }
void
rb_str_associate(str, add)
VALUE str, add;
{
if (!FL_TEST(str, STR_NO_ORIG)) {
if (RSTRING(str)->orig) {
rb_str_modify(str);
}
RSTRING(str)->orig = rb_ary_new();
FL_SET(str, STR_NO_ORIG);
}
rb_ary_push(RSTRING(str)->orig, add);
}
static ID to_str; static ID to_str;
VALUE VALUE
@ -163,6 +177,8 @@ VALUE
rb_str_dup(str) rb_str_dup(str)
VALUE str; VALUE str;
{ {
VALUE shadow;
if (TYPE(str) != T_STRING) str = rb_str_to_str(str); if (TYPE(str) != T_STRING) str = rb_str_to_str(str);
if (OBJ_FROZEN(str)) return rb_str_new3(str); if (OBJ_FROZEN(str)) return rb_str_new3(str);
if (FL_TEST(str, STR_NO_ORIG)) { if (FL_TEST(str, STR_NO_ORIG)) {
@ -171,14 +187,11 @@ rb_str_dup(str)
return s; return s;
} }
if (RSTRING(str)->orig) return rb_str_new3(RSTRING(str)->orig); if (RSTRING(str)->orig) return rb_str_new3(RSTRING(str)->orig);
else {
VALUE shadow;
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
shadow = rb_str_new4(str); shadow = rb_str_new4(str);
{
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
dup->len = RSTRING(shadow)->len; dup->len = RSTRING(shadow)->len;
dup->ptr = RSTRING(shadow)->ptr; dup->ptr = RSTRING(shadow)->ptr;
dup->orig = shadow; dup->orig = shadow;
@ -195,8 +208,9 @@ rb_str_clone(str)
{ {
VALUE clone = rb_str_dup(str); VALUE clone = rb_str_dup(str);
if (FL_TEST(str, STR_NO_ORIG)) if (FL_TEST(str, STR_NO_ORIG))
RSTRING(str)->orig = RSTRING(str)->orig; RSTRING(clone)->orig = RSTRING(str)->orig;
CLONESETUP(clone, str); CLONESETUP(clone, str);
return clone; return clone;
} }
@ -334,6 +348,7 @@ rb_str_modify(str)
if (!OBJ_TAINTED(str) && rb_safe_level() >= 4) if (!OBJ_TAINTED(str) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify string"); rb_raise(rb_eSecurityError, "Insecure: can't modify string");
if (!RSTRING(str)->orig || FL_TEST(str, STR_NO_ORIG)) return; if (!RSTRING(str)->orig || FL_TEST(str, STR_NO_ORIG)) return;
if (TYPE(RSTRING(str)->orig) != T_STRING) abort();
ptr = ALLOC_N(char, RSTRING(str)->len+1); ptr = ALLOC_N(char, RSTRING(str)->len+1);
if (RSTRING(str)->ptr) { if (RSTRING(str)->ptr) {
memcpy(ptr, RSTRING(str)->ptr, RSTRING(str)->len); memcpy(ptr, RSTRING(str)->ptr, RSTRING(str)->len);
@ -1214,6 +1229,7 @@ str_gsub(argc, argv, str, bang)
OBJSETUP(dup, rb_cString, T_STRING); OBJSETUP(dup, rb_cString, T_STRING);
OBJ_INFECT(dup, str); OBJ_INFECT(dup, str);
str = (VALUE)dup; str = (VALUE)dup;
dup->orig = 0;
} }
RSTRING(str)->ptr = buf; RSTRING(str)->ptr = buf;
RSTRING(str)->len = len = bp - buf; RSTRING(str)->len = len = bp - buf;

View file

@ -226,6 +226,7 @@ rb_autoload_id(id, filename)
ID id; ID id;
const char *filename; const char *filename;
{ {
rb_secure(4);
if (!rb_is_const_id(id)) { if (!rb_is_const_id(id)) {
rb_raise(rb_eNameError, "autoload must be constant name", rb_raise(rb_eNameError, "autoload must be constant name",
rb_id2name(id)); rb_id2name(id));
@ -1036,6 +1037,7 @@ rb_autoload_load(id)
st_delete(autoload_tbl, &id, &modname); st_delete(autoload_tbl, &id, &modname);
module = rb_str_new2(modname); module = rb_str_new2(modname);
FL_UNSET(module, FL_TAINT);
free(modname); free(modname);
rb_f_require(Qnil, module); rb_f_require(Qnil, module);
} }

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.3" #define RUBY_VERSION "1.5.3"
#define RUBY_RELEASE_DATE "2000-03-15" #define RUBY_RELEASE_DATE "2000-03-17"
#define RUBY_VERSION_CODE 153 #define RUBY_VERSION_CODE 153
#define RUBY_RELEASE_CODE 20000315 #define RUBY_RELEASE_CODE 20000317

View file

@ -28,7 +28,7 @@ RUBY_INSTALL_NAME=ruby
EXEEXT = .exe EXEEXT = .exe
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT) PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
STACK = 0x200000 STACK = 0x2000000
ORGLIBPATH = $(LIB) ORGLIBPATH = $(LIB)
#### End of system configuration section. #### #### End of system configuration section. ####