diff options
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | configure | 2 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | eval.c | 16 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 8 | ||||
-rw-r--r-- | ext/tk/lib/tktext.rb | 2 | ||||
-rw-r--r-- | file.c | 1 | ||||
-rw-r--r-- | intern.h | 1 | ||||
-rw-r--r-- | lib/debug.rb | 4 | ||||
-rw-r--r-- | lib/matrix.rb | 1 | ||||
-rw-r--r-- | lib/profile.rb | 25 | ||||
-rw-r--r-- | lib/thread.rb | 53 | ||||
-rw-r--r-- | pack.c | 14 | ||||
-rw-r--r-- | string.c | 28 | ||||
-rw-r--r-- | variable.c | 2 | ||||
-rw-r--r-- | version.h | 4 | ||||
-rw-r--r-- | win32/Makefile | 2 |
18 files changed, 129 insertions, 62 deletions
@@ -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> * hash.c (rb_hash_s_create): unexpected recursive call removed. @@ -704,7 +704,7 @@ rb_ary_join(ary, sep) } break; default: - result = rb_obj_as_string(tmp); + result = rb_str_dup(rb_obj_as_string(tmp)); break; } @@ -4934,7 +4934,7 @@ case "$target_os" in CFLAGS="$CFLAGS -pipe -no-precomp" ;; osf*) - if $without_gcc = "yes" ; then + if test "$without_gcc" = "no" ; then CFLAGS="$CFLAGS -ansi" else # compile something small: taint.c is fine for this. diff --git a/configure.in b/configure.in index 54939679bc..486d0bd2ae 100644 --- a/configure.in +++ b/configure.in @@ -775,7 +775,7 @@ case "$target_os" in CFLAGS="$CFLAGS -pipe -no-precomp" ;; osf*) - if [ $without_gcc = "yes" ]; then + if test "$without_gcc" = "no" ; then CFLAGS="$CFLAGS -ansi" else # compile something small: taint.c is fine for this. @@ -1804,7 +1804,10 @@ call_trace_func(event, file, line, self, id, klass) ruby_frame->file = ruby_sourcefile = file; } 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; } } @@ -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), srcfile, INT2FIX(ruby_sourceline), - INT2FIX(id), + id?ID2SYM(id):Qnil, self?rb_f_binding(self):Qnil, klass)); } @@ -4002,7 +4005,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper) 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); if ((state = EXEC_TAG()) == 0) { result = call_cfunc(body->nd_cfnc, recv, len, argc, argv); @@ -4563,7 +4566,12 @@ rb_f_eval(argc, argv, self) line = NUM2INT(vline); } - Check_SafeStr(src); + if (ruby_safe_level >= 3) { + Check_Type(src, T_STRING); + } + else { + Check_SafeStr(src); + } if (NIL_P(scope) && ruby_frame->prev) { struct FRAME *prev; VALUE val; diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index c344a2bf8e..107165f8ba 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1062,15 +1062,13 @@ module TkSelection tk_call 'selection', 'get', type end def TkSelection.handle(win, func, type=None, format=None) - id = install_cmd(func) - tk_call 'selection', 'handle', win.path, id, type, format + tk_call 'selection', 'handle', win.path, func, type, format end def handle(func, type=None, format=None) TkSelection.handle self, func, type, format end - def TkSelection.own(win, func=None) - id = install_cmd(func) - tk_call 'selection', 'own', win.path, id + def TkSelection.own(win=None, func=None) + window(tk_call 'selection', 'own', win, func) end def own(func=None) TkSelection.own self, func diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb index 7872e6a078..9e38db5032 100644 --- a/ext/tk/lib/tktext.rb +++ b/ext/tk/lib/tktext.rb @@ -132,7 +132,7 @@ class TkText<TkTextWin WidgetClassName end - def self.new(*args) + def self.new(*args, &block) obj = super(*args){} obj.init_instance_variable obj.instance_eval &block if defined? yield @@ -1961,6 +1961,7 @@ path_check_1(path) #else if (getwd(buf) == 0) return 0; #endif + strncat(buf, "/", MAXPATHLEN); strncat(buf, path, MAXPATHLEN); buf[MAXPATHLEN] = '\0'; return path_check_1(buf); @@ -292,6 +292,7 @@ int rb_str_cmp _((VALUE, VALUE)); VALUE rb_str_upto _((VALUE, VALUE, int)); VALUE rb_str_inspect _((VALUE)); VALUE rb_str_split _((VALUE, const char*)); +void rb_str_associate _((VALUE, VALUE)); /* struct.c */ VALUE rb_struct_new __((VALUE, ...)); VALUE rb_struct_define __((const char*, ...)); diff --git a/lib/debug.rb b/lib/debug.rb index 4497fd161d..b9a1d5f1c5 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -445,9 +445,9 @@ class DEBUGGER__ n += 1 break unless bind 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 - 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 diff --git a/lib/matrix.rb b/lib/matrix.rb index 80d28148ac..a80b7dd9f1 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -420,6 +420,7 @@ class Matrix vij = 0 0.upto(column_size - 1) do |k| + p [k,j,m[k,j]] vij += self[i, k] * m[k, j] end vij diff --git a/lib/profile.rb b/lib/profile.rb index e4b1b4b189..d94b09da9e 100644 --- a/lib/profile.rb +++ b/lib/profile.rb @@ -3,7 +3,7 @@ module Profiler__ Start = Float(Time.times[0]) top = "toplevel".intern Stack = [[0, 0, top]] - MAP = {top => [1, 0, 0, "#toplevel"]} + MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]} p = proc{|event, file, line, id, binding, klass| case event @@ -13,17 +13,18 @@ module Profiler__ when "return", "c-return" now = Float(Time.times[0]) tick = Stack.pop - data = MAP[id] + name = klass.to_s + if name.nil? then name = '' end + if klass.kind_of? Class + name += "#" + else + name += "." + end + name += id.id2name + data = MAP[name] unless data - name = klass.to_s - if name.nil? then name = '' end - if klass.kind_of? Class - name += "#" - else - name += "." - end - data = [0.0, 0.0, 0.0, name+id.id2name] - MAP[id] = data + data = [0.0, 0.0, 0.0, name] + MAP[name] = data end data[0] += 1 cost = now - tick[0] @@ -36,7 +37,7 @@ module Profiler__ set_trace_func nil total = Float(Time.times[0]) - Start if total == 0 then total = 0.01 end - MAP[:toplevel][1] = total + MAP["#toplevel"][1] = total # f = open("./rmon.out", "w") f = STDERR data = MAP.values.sort!{|a,b| b[2] <=> a[2]} diff --git a/lib/thread.rb b/lib/thread.rb index 22610f2992..9edda48abe 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -63,10 +63,14 @@ class Mutex def unlock return unless @locked Thread.critical = true - t = @waiting.shift @locked = false + begin + t = @waiting.shift + t.wakeup if t + rescue ThreadError + retry + end Thread.critical = false - t.run if t self end @@ -82,9 +86,13 @@ class Mutex def exclusive_unlock return unless @locked Thread.exclusive do - t = @waiting.shift @locked = false - t.wakeup if t + begin + t = @waiting.shift + t.wakeup if t + rescue ThreadError + retry + end yield end self @@ -105,8 +113,12 @@ class ConditionVariable end def signal - t = @waiters.shift - t.run if t + begin + t = @waiters.shift + t.run if t + rescue ThreadError + retry + end end def broadcast @@ -116,7 +128,10 @@ class ConditionVariable @waiters.clear end for t in waiters0 - t.run + begin + t.run + rescue ThreadError + end end end end @@ -133,9 +148,13 @@ class Queue def push(obj) Thread.critical = true @que.push obj - t = @waiting.shift + begin + t = @waiting.shift + t.wakeup if t + rescue ThreadError + retry + end Thread.critical = false - t.run if t end alias enq push @@ -201,8 +220,12 @@ class SizedQueue<Queue @max = max Thread.critical = false diff.times do - t = @queue_wait.shift - t.run if t + begin + t = @queue_wait.shift + t.run if t + rescue ThreadError + retry + end end end max @@ -221,8 +244,12 @@ class SizedQueue<Queue def pop(*args) Thread.critical = true if @que.length < @max - t = @queue_wait.shift - t.run if t + begin + t = @queue_wait.shift + t.run if t + rescue ThreadError + retry + end end super end @@ -301,18 +301,6 @@ static void qpencode _((VALUE,VALUE,int)); static int uv_to_utf8 _((char*,unsigned long)); 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 pack_pack(ary, fmt) VALUE ary, fmt; @@ -849,7 +837,7 @@ pack_pack(ary, fmt) if (NIL_P(from)) t = ""; else { t = STR2CSTR(from); - pack_add_ptr(res, from); + rb_str_associate(res, from); } rb_str_cat(res, (char*)&t, sizeof(char*)); } @@ -141,6 +141,20 @@ rb_str_become(str, str2) 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; VALUE @@ -163,6 +177,8 @@ VALUE rb_str_dup(str) VALUE str; { + VALUE shadow; + if (TYPE(str) != T_STRING) str = rb_str_to_str(str); if (OBJ_FROZEN(str)) return rb_str_new3(str); if (FL_TEST(str, STR_NO_ORIG)) { @@ -171,14 +187,11 @@ rb_str_dup(str) return s; } if (RSTRING(str)->orig) return rb_str_new3(RSTRING(str)->orig); - else { - VALUE shadow; + shadow = rb_str_new4(str); + { NEWOBJ(dup, struct RString); OBJSETUP(dup, rb_cString, T_STRING); - - shadow = rb_str_new4(str); - dup->len = RSTRING(shadow)->len; dup->ptr = RSTRING(shadow)->ptr; dup->orig = shadow; @@ -195,8 +208,9 @@ rb_str_clone(str) { VALUE clone = rb_str_dup(str); if (FL_TEST(str, STR_NO_ORIG)) - RSTRING(str)->orig = RSTRING(str)->orig; + RSTRING(clone)->orig = RSTRING(str)->orig; CLONESETUP(clone, str); + return clone; } @@ -334,6 +348,7 @@ rb_str_modify(str) if (!OBJ_TAINTED(str) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify string"); 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); if (RSTRING(str)->ptr) { memcpy(ptr, RSTRING(str)->ptr, RSTRING(str)->len); @@ -1214,6 +1229,7 @@ str_gsub(argc, argv, str, bang) OBJSETUP(dup, rb_cString, T_STRING); OBJ_INFECT(dup, str); str = (VALUE)dup; + dup->orig = 0; } RSTRING(str)->ptr = buf; RSTRING(str)->len = len = bp - buf; diff --git a/variable.c b/variable.c index c8bcfb0393..691a0159e3 100644 --- a/variable.c +++ b/variable.c @@ -226,6 +226,7 @@ rb_autoload_id(id, filename) ID id; const char *filename; { + rb_secure(4); if (!rb_is_const_id(id)) { rb_raise(rb_eNameError, "autoload must be constant name", rb_id2name(id)); @@ -1036,6 +1037,7 @@ rb_autoload_load(id) st_delete(autoload_tbl, &id, &modname); module = rb_str_new2(modname); + FL_UNSET(module, FL_TAINT); free(modname); rb_f_require(Qnil, module); } @@ -1,4 +1,4 @@ #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_RELEASE_CODE 20000315 +#define RUBY_RELEASE_CODE 20000317 diff --git a/win32/Makefile b/win32/Makefile index 7573ef62cf..af9349a070 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -28,7 +28,7 @@ RUBY_INSTALL_NAME=ruby EXEEXT = .exe PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT) -STACK = 0x200000 +STACK = 0x2000000 ORGLIBPATH = $(LIB) #### End of system configuration section. #### |