From 6c11709d4c2ca083d0c1f7c7041b5aec4efd9361 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 11 Oct 2000 06:29:16 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ eval.c | 35 ++++++++++++++++++++++------------- lib/pstore.rb | 1 + lib/tracer.rb | 16 +++++++++++----- misc/ruby-mode.el | 2 +- parse.y | 1 + 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc36125409..abc9d62bb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,17 @@ Wed Oct 11 14:29:51 2000 Minero Aoki * lib/net/http.rb: code refining. +Wed Oct 11 11:13:03 2000 Yukihiro Matsumoto + + * parse.y (primary): setter method (e.g. foo=) should always be + public. + + * eval.c (rb_thread_raise): should not raise SecurityError if + exception raised by the interpreter. + + * eval.c (rb_thread_cleanup): skip all THREAD_KILLED threads + before FOREACH_THREAD. + Tue Oct 10 16:11:54 2000 WATANABE Hirofumi * dln.c (dln_load): remove unused code for cygwin. diff --git a/eval.c b/eval.c index 03f822ab34..9f511cf209 100644 --- a/eval.c +++ b/eval.c @@ -7723,7 +7723,7 @@ catch_timer(sig) int rb_thread_tick = THREAD_TICK; #endif -static VALUE rb_thread_raise _((int, VALUE*, VALUE)); +static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t)); #define SCOPE_SHARED FL_USER1 @@ -7806,13 +7806,13 @@ rb_thread_start_0(fn, arg, th) } else if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) { /* delegate exception to main_thread */ - rb_thread_raise(1, &ruby_errinfo, main_thread->thread); + rb_thread_raise(1, &ruby_errinfo, main_thread); } else if (thread_abort || th->abort || RTEST(ruby_debug)) { VALUE err = rb_exc_new(rb_eSystemExit, 0, 0); error_print(); /* exit on main_thread */ - rb_thread_raise(1, &err, main_thread->thread); + rb_thread_raise(1, &err, main_thread); } else { th->errinfo = ruby_errinfo; @@ -7948,7 +7948,7 @@ rb_thread_cleanup() { rb_thread_t th; - if (curr_thread != curr_thread->next->prev) { + while (curr_thread->status == THREAD_KILLED) { curr_thread = curr_thread->prev; } @@ -8049,23 +8049,18 @@ rb_thread_trap_eval(cmd, sig) } static VALUE -rb_thread_raise(argc, argv, thread) +rb_thread_raise(argc, argv, th) int argc; VALUE *argv; - VALUE thread; + rb_thread_t th; { - rb_thread_t th = rb_thread_check(thread); - if (rb_thread_dead(th)) return Qnil; if (curr_thread == th) { rb_f_raise(argc, argv); } - if (ruby_safe_level > th->safe) { - rb_secure(4); - } if (THREAD_SAVE_CONTEXT(curr_thread)) { - return thread; + return th->thread; } rb_scan_args(argc, argv, "11", &th_raise_argv[0], &th_raise_argv[1]); @@ -8079,6 +8074,20 @@ rb_thread_raise(argc, argv, thread) return Qnil; /* not reached */ } +static VALUE +rb_thread_raise_m(argc, argv, thread) + int argc; + VALUE *argv; + VALUE thread; +{ + rb_thread_t th = rb_thread_check(thread); + + if (ruby_safe_level > th->safe) { + rb_secure(4); + } + rb_thread_raise(argc, argv, th); +} + VALUE rb_thread_local_aref(thread, id) VALUE thread; @@ -8332,7 +8341,7 @@ Init_Thread() rb_define_method(rb_cThread, "join", rb_thread_join, 0); rb_define_method(rb_cThread, "alive?", rb_thread_alive_p, 0); rb_define_method(rb_cThread, "stop?", rb_thread_stop_p, 0); - rb_define_method(rb_cThread, "raise", rb_thread_raise, -1); + rb_define_method(rb_cThread, "raise", rb_thread_raise_m, -1); rb_define_method(rb_cThread, "abort_on_exception", rb_thread_abort_exc, 0); rb_define_method(rb_cThread, "abort_on_exception=", rb_thread_abort_exc_set, 1); diff --git a/lib/pstore.rb b/lib/pstore.rb index 5eadd68306..b3e1df8284 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -108,6 +108,7 @@ class PStore begin file.rewind Marshal::dump(@table, file) + file.truncate(file.pos) rescue File::rename backup, @filename if File::exist?(backup) raise diff --git a/lib/tracer.rb b/lib/tracer.rb index 78bada9a65..859a6d5249 100644 --- a/lib/tracer.rb +++ b/lib/tracer.rb @@ -16,9 +16,11 @@ class Tracer @RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-' + @stdout = STDOUT class << self attr :verbose, true alias verbose? verbose + attr :stdout, true end verbose = true @@ -44,6 +46,10 @@ class Tracer @filters = [] end + def stdout + Tracer.stdout + end + def on if block_given? on @@ -56,13 +62,13 @@ class Tracer set_trace_func proc{|event, file, line, id, binding, klass| trace_func event, file, line, id, binding } - print "Trace on\n" if Tracer.verbose? + stdout.print "Trace on\n" if Tracer.verbose? end end def off set_trace_func nil - print "Trace off\n" if Tracer.verbose? + stdout.print "Trace off\n" if Tracer.verbose? end def add_filter(p = proc) @@ -79,7 +85,7 @@ class Tracer end unless list = LINES__[file] -# print file if $DEBUG +# stdout.print file if $DEBUG begin f = open(file) begin @@ -108,14 +114,14 @@ class Tracer def trace_func(event, file, line, id, binding) return if file == MY_FILE_NAME - #printf "Th: %s\n", Thread.current.inspect + #stdout.printf "Th: %s\n", Thread.current.inspect for p in @filters return unless p.call event, file, line, id, binding end Thread.critical = true - printf("#%d:%s:%d:%s: %s", + stdout.printf("#%d:%s:%d:%s: %s", get_thread_no, file, line, diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 33b88a2942..5e252a28ae 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -512,7 +512,7 @@ The variable ruby-indent-level controls the amount of indentation. (setq end (point)) (beginning-of-line) (if (re-search-forward "^\\s *#" end t) - (forward-line 1) + (beginning-of-line) (setq done t)))) (setq bol (point)) (end-of-line) diff --git a/parse.y b/parse.y index 3959679628..8e45980608 100644 --- a/parse.y +++ b/parse.y @@ -1271,6 +1271,7 @@ primary : literal /* NOEX_PRIVATE for toplevel */ $$ = NEW_DEFN($2, $4, $5, class_nest?NOEX_PUBLIC:NOEX_PRIVATE); + if (is_attrset_id($2)) $$->nd_noex = NOEX_PUBLIC; fixpos($$, $4); local_pop(); cur_mid = 0; -- cgit v1.2.3