From f9747b7a571556b6b8add7cfd4e324ad316d50b3 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 19 Jun 1998 09:32:13 +0000 Subject: [PATCH] 1.1b9_27 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++ bignum.c | 2 +- configure | 130 ++++++++++++++++++++++++++++++++++--------------- configure.in | 24 +++++++++ eval.c | 71 +++++++++++++-------------- file.c | 2 +- lib/cgi-lib.rb | 2 +- lib/tk.rb | 82 +++++++++++++++++++------------ parse.y | 15 +++++- ruby.h | 5 -- sample/test.rb | 22 +++++++-- version.h | 4 +- 12 files changed, 250 insertions(+), 123 deletions(-) diff --git a/ChangeLog b/ChangeLog index 491b3e7557..98c706bdac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Jun 19 18:28:19 1998 Yukihiro Matsumoto + + * experimental release 1.1b9_27. + +Fri Jun 19 14:34:49 1998 Yukihiro Matsumoto + + * eval.c (assign): support hack for nested multiple assignment. + + * parse.y (mlhs): nested multiple assignment. + + * eval.c (rb_eval): in-block variables now honors static scope. + + * configure.in: RSHIFT check moved to configure. + Thu Jun 18 16:46:04 1998 Yukihiro Matsumoto * experimental release 1.1b9_26. diff --git a/bignum.c b/bignum.c index b09713af69..dc0c5492d1 100644 --- a/bignum.c +++ b/bignum.c @@ -176,7 +176,7 @@ str2inum(str, base) while (ISSPACE(*str)) str++; - if (*str == '|') { + if (*str == '+') { str++; } else if (*str == '-') { diff --git a/configure b/configure index 411407a9f5..aca499b3db 100644 --- a/configure +++ b/configure @@ -3166,20 +3166,67 @@ EOF fi +echo $ac_n "checking whether right shift preserve sign bit""... $ac_c" 1>&6 +echo "configure:3171: checking whether right shift preserve sign bit" >&5 +if eval "test \"`echo '$''{'rb_cv_rshift_sign'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <>1); +} + +EOF +if { (eval echo configure:3190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + rb_cv_rshift_sign=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + rb_cv_rshift_sign=no +fi +rm -fr conftest* +fi + +fi + + echo "$ac_t""$rb_cv_rshift_sign" 1>&6 +if test "$rb_cv_rshift_sign" = yes; then + cat >> confdefs.h <<\EOF +#define RSHIFT(x,y) ((x)>>y) +EOF + +else + cat >> confdefs.h <<\EOF +#define RSHIFT(x,y) (((x)<0) ? ~((~(x))>>y) : (x)>>y) +EOF + +fi + echo $ac_n "checking count field in FILE structures""... $ac_c" 1>&6 -echo "configure:3171: checking count field in FILE structures" >&5 +echo "configure:3218: checking count field in FILE structures" >&5 if eval "test \"`echo '$''{'rb_cv_fcnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->_cnt = 0; ; return 0; } EOF -if { (eval echo configure:3183: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3230: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="_cnt" else @@ -3189,14 +3236,14 @@ fi rm -f conftest* if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->__cnt = 0; ; return 0; } EOF -if { (eval echo configure:3200: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="__cnt" else @@ -3207,14 +3254,14 @@ rm -f conftest* fi if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->_r = 0; ; return 0; } EOF -if { (eval echo configure:3218: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="_r" else @@ -3225,14 +3272,14 @@ rm -f conftest* fi if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->readCount = 0; ; return 0; } EOF -if { (eval echo configure:3236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3283: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="readCount" else @@ -3257,9 +3304,9 @@ fi if test "$ac_cv_func_getpwent" = yes; then echo $ac_n "checking struct passwd""... $ac_c" 1>&6 -echo "configure:3261: checking struct passwd" >&5 +echo "configure:3308: checking struct passwd" >&5 cat > conftest.$ac_ext < EOF @@ -3274,7 +3321,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3289,7 +3336,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3304,7 +3351,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3319,7 +3366,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3334,7 +3381,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3349,7 +3396,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3382,7 +3429,7 @@ fi case "$host_os" in linux*) echo $ac_n "checking whether ELF binaries are produced""... $ac_c" 1>&6 -echo "configure:3386: checking whether ELF binaries are produced" >&5 +echo "configure:3433: checking whether ELF binaries are produced" >&5 if eval "test \"`echo '$''{'rb_cv_linux_elf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3390,7 +3437,7 @@ else : else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then rb_cv_linux_elf=yes else @@ -3440,7 +3487,7 @@ STATIC= if test "$with_dln_a_out" != yes; then rb_cv_dlopen=unknown echo $ac_n "checking whether OS depend dynamic link works""... $ac_c" 1>&6 -echo "configure:3444: checking whether OS depend dynamic link works" >&5 +echo "configure:3491: checking whether OS depend dynamic link works" >&5 if test "$GCC" = yes; then case "$host_os" in nextstep*) ;; @@ -3518,13 +3565,13 @@ dln_a_out_works=no if test "$ac_cv_header_a_out_h" = yes; then if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6 -echo "configure:3522: checking whether matz's dln works" >&5 +echo "configure:3569: checking whether matz's dln works" >&5 cat confdefs.h > config.h if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3585: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_dln_a_out=yes else @@ -3631,7 +3678,7 @@ fi case "$host_os" in human*) echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6 -echo "configure:3635: checking for _harderr in -lsignal" >&5 +echo "configure:3682: checking for _harderr in -lsignal" >&5 ac_lib_var=`echo signal'_'_harderr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3639,7 +3686,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsignal $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3678,7 +3725,7 @@ else fi echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6 -echo "configure:3682: checking for hmemset in -lhmem" >&5 +echo "configure:3729: checking for hmemset in -lhmem" >&5 ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3686,7 +3733,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lhmem $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3727,12 +3774,12 @@ fi for ac_func in select do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3731: checking for $ac_func" >&5 +echo "configure:3778: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3780,7 +3827,7 @@ fi done echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6 -echo "configure:3784: checking whether PD libc _dtos18 fail to convert big number" >&5 +echo "configure:3831: checking whether PD libc _dtos18 fail to convert big number" >&5 if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3788,7 +3835,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -3800,7 +3847,7 @@ main () } EOF -if { (eval echo configure:3804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then rb_cv_missing__dtos18=yes else @@ -3822,7 +3869,7 @@ EOF fi echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6 -echo "configure:3826: checking whether PD libc fconvert fail to round" >&5 +echo "configure:3873: checking whether PD libc fconvert fail to round" >&5 if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3830,7 +3877,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -3843,7 +3890,7 @@ main () } EOF -if { (eval echo configure:3847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then rb_cv_missing_fconvert=yes else @@ -3905,6 +3952,11 @@ if test "$host_os" = "beos"; then esac fi +if test "$enable_shared" = 'yes'; then + LIBRUBY='libruby.so' + LIBRUBYARG='-L./ -lruby' +fi + if test "$host_os" = "rhapsody" ; then CFLAGS="$CFLAGS -no-precomp" fi diff --git a/configure.in b/configure.in index c8f534d556..40e082fa42 100644 --- a/configure.in +++ b/configure.in @@ -231,6 +231,25 @@ fi AC_C_BIGENDIAN AC_CHAR_UNSIGNED +AC_MSG_CHECKING(whether right shift preserve sign bit) +AC_CACHE_VAL(rb_cv_rshift_sign, + [AC_TRY_RUN([ +#define FIXNUM_FLAG 0x01 +int +main() +{ + return (-1!=(((-1)<<1)&FIXNUM_FLAG)>>1); +} +], + rb_cv_rshift_sign=yes, + rb_cv_rshift_sign=no)]) + AC_MSG_RESULT($rb_cv_rshift_sign) +if test "$rb_cv_rshift_sign" = yes; then + AC_DEFINE(RSHIFT(x,y), ((x)>>y)) +else + AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y)) +fi + AC_MSG_CHECKING([count field in FILE structures]) AC_CACHE_VAL(rb_cv_fcnt, [AC_TRY_COMPILE([#include ], @@ -550,6 +569,11 @@ if test "$host_os" = "beos"; then esac fi +if test "$enable_shared" = 'yes'; then + LIBRUBY='libruby.so' + LIBRUBYARG='-L./ -lruby' +fi + if test "$host_os" = "rhapsody" ; then CFLAGS="$CFLAGS -no-precomp" fi diff --git a/eval.c b/eval.c index 1069ed8c1c..095b5be20d 100644 --- a/eval.c +++ b/eval.c @@ -454,25 +454,12 @@ new_dvar(id, value) return vars; } -static void -push_dvar(id, value) - ID id; - VALUE value; -{ - the_dyna_vars = new_dvar(id, value); -} - static void mark_dvar(vars) - struct RVarmap* vars; + struct RVarmap *vars; { - if (!vars) { - the_dyna_vars = new_dvar(0, 0); - the_dyna_vars->next = vars; - } - else { - the_dyna_vars = vars; - } + the_dyna_vars = new_dvar(0, 0); + the_dyna_vars->next = vars; } VALUE @@ -503,6 +490,14 @@ dyna_var_ref(id) return Qnil; } +void +dyna_var_push(id, value) + ID id; + VALUE value; +{ + the_dyna_vars = new_dvar(id, value); +} + VALUE dyna_var_asgn(id, value) ID id; @@ -517,10 +512,26 @@ dyna_var_asgn(id, value) } vars = vars->next; } - push_dvar(id, value); + dyna_var_push(id, value); return value; } +static void +dvar_asgn_push(id, value) + ID id; + VALUE value; +{ + if (the_dyna_vars && the_dyna_vars->id == 0) { + struct RVarmap* vars = new_dvar(id, value); + + vars->next = the_dyna_vars->next; + the_dyna_vars->next = vars; + } + else { + dyna_var_push(id, value); + } +} + struct iter { int iter; struct iter *prev; @@ -2081,15 +2092,7 @@ rb_eval(self, node) case NODE_DASGN_PUSH: result = rb_eval(self, node->nd_value); - if (the_dyna_vars && the_dyna_vars->id == 0) { - struct RVarmap* vars = new_dvar(node->nd_vid, result); - - vars->next = the_dyna_vars->next; - the_dyna_vars->next = vars; - } - else { - push_dvar(node->nd_vid, result); - } + dvar_asgn_push(node->nd_vid, result); break; case NODE_GASGN: @@ -2972,13 +2975,17 @@ assign(self, lhs, val) break; case NODE_DASGN_PUSH: - push_dvar(lhs->nd_vid, val); + dvar_asgn_push(lhs->nd_vid, val); break; case NODE_CASGN: rb_const_set(the_class, lhs->nd_vid, val); break; + case NODE_MASGN: + massign(self, lhs, val); + break; + case NODE_CALL: { VALUE recv; @@ -3817,7 +3824,7 @@ eval(self, src, scope, file, line) old_block = the_block; the_block = data->prev; old_d_vars = the_dyna_vars; - mark_dvar(data->d_vars); + the_dyna_vars = data->d_vars; old_vmode = scope_vmode; scope_vmode = data->vmode; @@ -4864,10 +4871,6 @@ f_binding(self) data->prev = 0; } - if (data->d_vars && data->d_vars->id) { - push_dvar(0, 0); - data->d_vars = the_dyna_vars; - } scope_dup(data->scope); POP_BLOCK(); @@ -4922,10 +4925,6 @@ proc_s_new(klass) break; } } - if (data->d_vars && data->d_vars->id) { - push_dvar(0, 0); - data->d_vars = the_dyna_vars; - } obj_call_init(proc); return proc; diff --git a/file.c b/file.c index 0feb226d22..8063850ab4 100644 --- a/file.c +++ b/file.c @@ -707,7 +707,7 @@ file_s_ftype(obj, fname) #if defined(MSDOS) || defined(NT) if (rb_stat(fname, &st) < 0) - rb_sys_fail(RSTRIN(fname)->ptr); + rb_sys_fail(RSTRING(fname)->ptr); #else Check_SafeStr(fname); if (lstat(RSTRING(fname)->ptr, &st) == -1) { diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb index 362d13f8d0..1a6d16a6da 100644 --- a/lib/cgi-lib.rb +++ b/lib/cgi-lib.rb @@ -81,7 +81,7 @@ class CGI < SimpleDelegator end def CGI.error - m = $!.dup + m = $!.to_s.dup m.gsub!(/&/, '&') m.gsub!(//, '>') diff --git a/lib/tk.rb b/lib/tk.rb index 8a772f5dda..5d1d68d902 100644 --- a/lib/tk.rb +++ b/lib/tk.rb @@ -142,6 +142,29 @@ module TkComm end private :bool, :number, :string, :list, :window, :procedure + def _get_eval_string(str) + return nil if str == None + if str.kind_of?(Hash) + str = hash_kv(str).join(" ") + elsif str.kind_of?(Array) + str = array2tk_list(str) + elsif str.kind_of?(Proc) + str = install_cmd(str) + elsif str == nil + str = "" + elsif str == false + str = "0" + elsif str == true + str = "1" + elsif (str.respond_to?(:to_eval)) + str = str.to_eval() + else + str = str.to_s() + end + return str + end + private :_get_eval_string + Tk_IDs = [0] # [0]-cmdid, [1]-winid def _curr_cmd_id id = format("c%.4d", Tk_IDs[0]) @@ -262,12 +285,26 @@ module TkComm end def after(ms, cmd=Proc.new) - myid = _curr_cmd_id - tk_call 'after', ms, - install_cmd(proc{ - TkUtil.eval_cmd cmd - uninstall_cmd myid - }) + myid = _curr_cmd_id + INTERP._eval('after '+ms+' '+_get_eval_string(install_cmd(proc{ + TkUtil.eval_cmd cmd + uninstall_cmd myid + }))) + return + if false #defined? Thread + Thread.start do + ms = Float(ms)/1000 + ms = 10 if ms == 0 + sleep ms/1000 + cmd.call + end + else + myid = _curr_cmd_id + INTERP._eval('after '+ms+' '+_get_eval_string(install_cmd(proc{ + TkUtil.eval_cmd cmd + uninstall_cmd myid + }))) + end end def update(idle=nil) @@ -296,28 +333,6 @@ module TkCore TclTkLib.mainloop end - def _get_eval_string(str) - return nil if str == None - if str.kind_of?(Hash) - str = hash_kv(str).join(" ") - elsif str.kind_of?(Array) - str = array2tk_list(str) - elsif str.kind_of?(Proc) - str = install_cmd(v) - elsif str == nil - str = "" - elsif str == false - str = "0" - elsif str == true - str = "1" - elsif (str.respond_to?(:to_eval)) - str = str.to_eval() - else - str = str.to_s() - end - return str - end - def tk_call(*args) print args.join(" "), "\n" if $DEBUG args.filter {|x|_get_eval_string(x)} @@ -981,11 +996,14 @@ class TkObject>1) -# define RSHIFT(x,y) ((x)>>y) -#else -# define RSHIFT(x,y) (((x)<0) ? ~((~(x))>>y) : (x)>>y) -#endif #define FIX2LONG(x) RSHIFT((long)x,1) #define FIX2ULONG(x) (((unsigned long)(x))>>1) #define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG) diff --git a/sample/test.rb b/sample/test.rb index eccbf23382..d8926c6c29 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -749,11 +749,23 @@ x = proc{proc{}}.call eval "(0..9).each{|i4| $x[i4] = proc{i4*2}}", x ok($x[4].call == 8) +x = binding +eval "i = 1", x +ok(eval("i", x) == 1) +x = proc{binding}.call +eval "i = 22", x +ok(eval("i", x) == 22) +$x = [] +x = proc{binding}.call +eval "(0..9).each{|i4| $x[i4] = proc{i4*2}}", x +ok($x[4].call == 8) + proc { - p = proc{} - foo = 1 - eval "foo = 10", p - ok(eval("foo", p) == eval("foo")) + p = binding + eval "foo11 = 1", p + proc{foo11=22}.call + ok(eval("foo11", p) == eval("foo11")) + ok(eval("foo11") == 1) }.call check "system" @@ -808,7 +820,7 @@ File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"` $bad = false for script in Dir["{lib,sample}/*.rb"] - unless `./ruby -c #{script}` == "Syntax OK\n" + unless `./ruby -c #{script}`.chomp == "Syntax OK" $bad = true end end diff --git a/version.h b/version.h index a5dcad63c1..4ed0fc630e 100644 --- a/version.h +++ b/version.h @@ -1,2 +1,2 @@ -#define RUBY_VERSION "1.1b9_26" -#define VERSION_DATE "98/06/18" +#define RUBY_VERSION "1.1b9_27" +#define VERSION_DATE "98/06/19"