diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | eval.c | 26 | ||||
-rw-r--r-- | ext/readline/readline.c | 9 | ||||
-rw-r--r-- | gc.c | 4 | ||||
-rw-r--r-- | lib/date.rb | 5 | ||||
-rw-r--r-- | lib/mkmf.rb | 24 | ||||
-rw-r--r-- | mkconfig.rb | 9 | ||||
-rw-r--r-- | object.c | 11 | ||||
-rw-r--r-- | parse.y | 21 |
10 files changed, 71 insertions, 58 deletions
@@ -1,8 +1,26 @@ +Mon May 7 15:58:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * parse.y (arg): "||=" should not warn for uninitialized instance + variables. + + * eval.c (rb_eval): ditto. + + * eval.c (eval): preserve and restore ruby_cref as well. + Mon May 7 15:45:48 2001 WATANABE Hirofumi <eban@ruby-lang.org> * lib/ftools.rb (syscopy): chmod destination file only if it does not exist. +Mon May 7 14:35:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * object.c (rb_obj_is_instance_of): takes only class/module as an + argument. + +Sun May 6 16:27:29 2001 Koji Arai <JCA02266@nifty.ne.jp> + + * eval.c (is_defined): rb_reg_nth_defined() may return Qnil. + Thu May 3 03:15:06 2001 SHIROYAMA Takayuki <psi@fortune.nest.or.jp> * configure.in: get --enable-shared to work on MacOS X. diff --git a/Makefile.in b/Makefile.in index 3e906182cb..fab157327b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -125,7 +125,7 @@ realclean: distclean test: miniruby$(EXEEXT) @./miniruby$(EXEEXT) $(srcdir)/rubytest.rb -rbconfig.rb: miniruby$(EXEEXT) +rbconfig.rb: miniruby$(EXEEXT) $(srcdir)/mkconfig.rb config.status @@MINIRUBY@ $(srcdir)/mkconfig.rb rbconfig.rb fake.rb: miniruby$(EXEEXT) @@ -1847,14 +1847,14 @@ is_defined(self, node, buf) break; case NODE_NTH_REF: - if (rb_reg_nth_defined(node->nd_nth, MATCH_DATA)) { + if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) { sprintf(buf, "$%d", node->nd_nth); return buf; } break; case NODE_BACK_REF: - if (rb_reg_nth_defined(0, MATCH_DATA)) { + if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) { sprintf(buf, "$%c", node->nd_nth); return buf; } @@ -2637,10 +2637,12 @@ rb_eval(self, n) goto again; case NODE_OP_ASGN_OR: - result = rb_eval(self, node->nd_head); - if (RTEST(result)) break; - node = node->nd_value; - goto again; + if ((node->nd_aid && !rb_ivar_defined(self, node->nd_aid)) || + !RTEST(result = rb_eval(self, node->nd_head))) { + node = node->nd_value; + goto again; + } + break; case NODE_MASGN: result = massign(self, node, rb_eval(self, node->nd_value),0); @@ -4737,6 +4739,7 @@ eval(self, src, scope, file, line) struct SCOPE * volatile old_scope; struct BLOCK * volatile old_block; struct RVarmap * volatile old_dyna_vars; + VALUE volatile old_cref; int volatile old_vmode; struct FRAME frame; char *filesave = ruby_sourcefile; @@ -4767,6 +4770,8 @@ eval(self, src, scope, file, line) ruby_dyna_vars = data->dyna_vars; old_vmode = scope_vmode; scope_vmode = data->vmode; + old_cref = (VALUE)ruby_cref; + ruby_cref = (NODE*)ruby_frame->cbase; self = data->self; ruby_frame->iter = data->iter; @@ -4802,6 +4807,7 @@ eval(self, src, scope, file, line) if (!NIL_P(scope)) { int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE; + ruby_cref = (NODE*)old_cref; ruby_frame = frame.tmp; ruby_scope = old_scope; ruby_block = old_block; @@ -5023,17 +5029,16 @@ specific_eval(argc, argv, klass, self) else { char *file = "(eval)"; int line = 1; - VALUE src = argv[0]; if (argc == 0) { rb_raise(rb_eArgError, "block not supplied"); } else { if (ruby_safe_level >= 4) { - StringValue(src); + StringValue(argv[0]); } else { - SafeStringValue(src); + SafeStringValue(argv[0]); } if (argc > 3) { rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}", @@ -5041,8 +5046,7 @@ specific_eval(argc, argv, klass, self) rb_id2name(ruby_frame->last_func)); } if (argc > 1) { - src = argv[1]; - file = StringValuePtr(src); + file = StringValuePtr(argv[1]); } if (argc > 2) line = NUM2INT(argv[2]); } diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 765a00280c..c8ed81ac51 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -18,6 +18,7 @@ static VALUE mReadline; #ifndef READLINE_42_OR_LATER # define rl_filename_completion_function filename_completion_function # define rl_username_completion_function username_completion_function +# define rl_completion_matches completion_matches #endif static int @@ -327,8 +328,8 @@ filename_completion_proc_call(self, str) char **matches; int i; - matches = completion_matches(StringValuePtr(str), - rl_filename_completion_function); + matches = rl_completion_matches(StringValuePtr(str), + rl_filename_completion_function); if (matches) { result = rb_ary_new(); for (i = 0; matches[i]; i++) { @@ -354,8 +355,8 @@ username_completion_proc_call(self, str) char **matches; int i; - matches = completion_matches(StringValuePtr(str), - rl_username_completion_function); + matches = rl_completion_matches(StringValuePtr(str), + rl_username_completion_function); if (matches) { result = rb_ary_new(); for (i = 0; matches[i]; i++) { @@ -1220,12 +1220,12 @@ run_final(obj) args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */ for (i=0; i<RARRAY(finalizers)->len; i++) { args[0] = RARRAY(finalizers)->ptr[i]; - rb_protect(run_single_final, (VALUE)args, &status); + rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status); } if (finalizer_table && st_delete(finalizer_table, &obj, &table)) { for (i=0; i<RARRAY(table)->len; i++) { args[0] = RARRAY(table)->ptr[i]; - rb_protect(run_single_final, (VALUE)args, &status); + rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status); } } } diff --git a/lib/date.rb b/lib/date.rb index cd0b997179..3422121298 100644 --- a/lib/date.rb +++ b/lib/date.rb @@ -202,10 +202,7 @@ class Date alias_method :__#{id.to_i}__, :#{id.id2name} private :__#{id.to_i}__ def #{id.id2name}(*args, &block) - unless defined? @__#{id.to_i}__ - @__#{id.to_i}__ = __#{id.to_i}__(*args, &block) - end - @__#{id.to_i}__ + (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0] end end; end diff --git a/lib/mkmf.rb b/lib/mkmf.rb index d1f830aca6..0d308d9dc7 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -12,12 +12,13 @@ SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"] $config_cache = CONFIG["compile_dir"]+"/ext/config.cache" $srcdir = CONFIG["srcdir"] -$libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"] -$archdir = $libdir+"/"+CONFIG["arch"] -$sitelibdir = CONFIG["sitedir"]+"/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"] -$sitearchdir = $sitelibdir+"/"+CONFIG["arch"] +$libdir = CONFIG["libdir"] +$rubylibdir = CONFIG["rubylibdir"] +$archdir = CONFIG["archdir"] +$sitelibdir = CONFIG["sitelibdir"] +$sitearchdir = CONFIG["sitearchdir"] -if File.exist? $archdir + "/ruby.h" +if File.exist? Config::CONFIG["archdir"] + "/ruby.h" $hdrdir = $archdir elsif File.exist? $srcdir + "/ruby.h" $hdrdir = $srcdir @@ -438,6 +439,8 @@ LIBPATH = #{libpath} RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]} RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]} +arch = #{CONFIG["arch"]} +ruby_version = #{Config::CONFIG["ruby_version"]} #{ if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty? "\nDESTDIR = " + destdir @@ -446,11 +449,12 @@ else end } prefix = $(DESTDIR)#{CONFIG["prefix"].sub(drive, '')} -exec_prefix = $(DESTDIR)#{CONFIG["exec_prefix"].sub(drive, '')} -libdir = $(DESTDIR)#{$libdir.sub(drive, '')}#{target_prefix} -archdir = $(DESTDIR)#{$archdir.sub(drive, '')}#{target_prefix} -sitelibdir = $(DESTDIR)#{$sitelibdir.sub(drive, '')}#{target_prefix} -sitearchdir = $(DESTDIR)#{$sitearchdir.sub(drive, '')}#{target_prefix} +exec_prefix = #{CONFIG["exec_prefix"].sub(drive, '')} +libdir = #{$libdir.sub(drive, '')}#{target_prefix} +rubylibdir = #{$rubylibdir.sub(drive, '')}#{target_prefix} +archdir = #{$archdir.sub(drive, '')}#{target_prefix} +sitelibdir = #{$sitelibdir.sub(drive, '')}#{target_prefix} +sitearchdir = #{$sitearchdir.sub(drive, '')}#{target_prefix} #### End of system configuration section. #### diff --git a/mkconfig.rb b/mkconfig.rb index 7deb6cef15..721cd3f67d 100644 --- a/mkconfig.rb +++ b/mkconfig.rb @@ -40,7 +40,7 @@ File.foreach "config.status" do |line| next if $so_name and /^RUBY_SO_NAME$/ =~ name v = " CONFIG[\"" + name + "\"] = " + val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) { - "\#{CONFIG[\\\"#{$1}\\\"]}" + "$(#{$1})" } + "\n" if fast[name] v_fast << v @@ -89,6 +89,11 @@ end print v_fast, v_others print <<EOS + CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)" + CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)" + CONFIG["archdir"] = "$(rubylibdir)/$(arch)" + CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)" + CONFIG["sitearchdir"] = "$(sitelibdir)/$(arch)" CONFIG["compile_dir"] = "#{Dir.pwd}" MAKEFILE_CONFIG = {} CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup} @@ -96,7 +101,7 @@ print <<EOS val.gsub!(/\\$\\(([^()]+)\\)/) do |var| key = $1 if CONFIG.key? key - "\#{Config::expand(CONFIG[\\\"\#{key}\\\"])}" + Config::expand(CONFIG[key]) else var end @@ -220,17 +220,6 @@ rb_obj_is_instance_of(obj, c) case T_CLASS: case T_ICLASS: break; - - case T_NIL: - if (NIL_P(obj)) return Qtrue; - return Qfalse; - - case T_FALSE: - return RTEST(obj) ? Qfalse : Qtrue; - - case T_TRUE: - return RTEST(obj) ? Qtrue : Qfalse; - default: rb_raise(rb_eTypeError, "class or module required"); } @@ -411,15 +411,15 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem { $$ = node_assign($1, $3); } - | expr - -expr : mlhs '=' mrhs + | mlhs '=' mrhs { value_expr($3); $1->nd_value = $3; $$ = $1; } - | kRETURN ret_args + | expr + +expr : kRETURN ret_args { if (!compile_for_eval && !in_def && !in_single) yyerror("return appeared outside of method"); @@ -671,6 +671,9 @@ arg : lhs '=' arg if ($2 == tOROP) { $<node>3->nd_value = $4; $$ = NEW_OP_ASGN_OR(gettable($1), $<node>3); + if (is_instance_id($1)) { + $$->nd_aid = $1; + } } else if ($2 == tANDOP) { $<node>3->nd_value = $4; @@ -903,14 +906,10 @@ arg : lhs '=' arg } aref_args : none - | command_call opt_nl + | command opt_nl { $$ = NEW_LIST($1); } - | args ',' command_call opt_nl - { - $$ = list_append($1, $3); - } | args trailer { $$ = $1; @@ -954,10 +953,6 @@ call_args : command { $$ = NEW_LIST($1); } - | args ',' command - { - $$ = list_append($1, $3); - } | args opt_block_arg { $$ = arg_blk_pass($1, $2); |