From 992923053cfb51dc04c6a7ee07ca6fff1b61d1a5 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 18 Jun 1998 07:47:15 +0000 Subject: 1.1b9_26 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 20 ++++ MANIFEST | 1 + Makefile.in | 16 +-- configure | 8 +- dir.c | 15 +-- eval.c | 51 +++++++-- ext/Setup | 2 +- ext/Win32API/extconf.rb | 10 +- ext/extmk.rb.nt | 6 +- ext/socket/depend | 2 +- ext/tcltklib/tcltklib.c | 8 +- ext/tkutil/tkutil.c | 3 +- file.c | 7 ++ glob.c | 4 + intern.h | 4 +- io.c | 10 +- lib/tk.rb | 177 +++++++++++++++++++++++++------- lib/tkpalette.rb | 46 +++++++++ lib/tktext.rb | 268 ++++++++++++++++++++++++++++++++++++++++++++++-- missing/nt.h | 16 +-- node.h | 2 + numeric.c | 49 +++++++++ parse.y | 7 +- regex.c | 3 + sample/test.rb | 7 ++ util.c | 9 +- version.h | 4 +- win32/Makefile | 2 +- win32/config.h | 2 +- win32/ruby.def | 5 +- 30 files changed, 645 insertions(+), 119 deletions(-) create mode 100644 lib/tkpalette.rb diff --git a/ChangeLog b/ChangeLog index 9283422124..491b3e7557 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +Thu Jun 18 16:46:04 1998 Yukihiro Matsumoto + + * experimental release 1.1b9_26. + +Thu Jun 18 13:37:19 1998 Yukihiro Matsumoto + + * file.c (file_s_ftype): uses lstat(2) instead of stat(2). + + * dir.c (dir_s_glob): there can be buffer overrun, check added. + + * eval.c (f_binding): handles in-block variables declared after + binding's generation. + + * numeric.c (flo_floor): floor, ceil, round added to Float. + +Wed Jun 17 11:20:00 1998 Yukihiro Matsumoto + + * parse.y (gettable): nesting local variables should have higher + priority than normal local variables. + Tue Jun 16 12:30:46 1998 Yukihiro Matsumoto * bignum.c (str2inum): handles `+ddd'. diff --git a/MANIFEST b/MANIFEST index a94502de0b..d4c60398e9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -127,6 +127,7 @@ lib/tkclass.rb lib/tkdialog.rb lib/tkentry.rb lib/tkmenubar.rb +lib/tkpalette.rb lib/tkscrollbox.rb lib/tktext.rb lib/tracer.rb diff --git a/Makefile.in b/Makefile.in index 43c9ec7831..c41f0c1750 100644 --- a/Makefile.in +++ b/Makefile.in @@ -190,24 +190,24 @@ dln.o: dln.c config.h defines.h dln.h dmyext.o: dmyext.c enum.o: enum.c ruby.h config.h defines.h intern.h error.o: error.c ruby.h config.h defines.h intern.h env.h -eval.o: eval.c ruby.h config.h defines.h intern.h node.h env.h sig.h st.h dln.h -file.o: file.c ruby.h config.h defines.h intern.h io.h sig.h -gc.o: gc.c ruby.h config.h defines.h intern.h sig.h st.h node.h env.h re.h regex.h -hash.o: hash.c ruby.h config.h defines.h intern.h st.h sig.h +eval.o: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h +file.o: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h +gc.o: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h +hash.o: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h inits.o: inits.c ruby.h config.h defines.h intern.h -io.o: io.c ruby.h config.h defines.h intern.h io.h sig.h +io.o: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h main.o: main.c ruby.h config.h defines.h intern.h -marshal.o: marshal.c ruby.h config.h defines.h intern.h io.h sig.h st.h +marshal.o: marshal.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h st.h math.o: math.c ruby.h config.h defines.h intern.h numeric.o: numeric.c ruby.h config.h defines.h intern.h object.o: object.c ruby.h config.h defines.h intern.h st.h pack.o: pack.c ruby.h config.h defines.h intern.h -process.o: process.c ruby.h config.h defines.h intern.h sig.h st.h +process.o: process.c ruby.h config.h defines.h intern.h rubysig.h st.h random.o: random.c ruby.h config.h defines.h intern.h range.o: range.c ruby.h config.h defines.h intern.h re.o: re.c ruby.h config.h defines.h intern.h re.h regex.h ruby.o: ruby.c ruby.h config.h defines.h intern.h dln.h -signal.o: signal.c ruby.h config.h defines.h intern.h sig.h +signal.o: signal.c ruby.h config.h defines.h intern.h rubysig.h sprintf.o: sprintf.c ruby.h config.h defines.h intern.h st.o: st.c config.h st.h string.o: string.c ruby.h config.h defines.h intern.h re.h regex.h diff --git a/configure b/configure index 42ca84458c..411407a9f5 100644 --- a/configure +++ b/configure @@ -622,12 +622,12 @@ if test "${enable_fat_binary+set}" = set; then fat_binary=$enableval fi -if test "$fat_binary" = yes ; then + if test "$fat_binary" = yes ; then echo $ac_n "checking target architecture ""... $ac_c" 1>&6 echo "configure:629: checking target architecture " >&5 - if "$host_os" = "rhapsody" ; then + if test "$host_os" = "rhapsody" ; then echo -n "Rhapsody: " if test "$TARGET_ARCHS" = "" ; then TARGET_ARCHS="ppc i486" @@ -3905,8 +3905,8 @@ if test "$host_os" = "beos"; then esac fi -if "$host_os" = "rhapsody" ; then - CFLAGS="$CFLAGS -no-precomp" +if test "$host_os" = "rhapsody" ; then + CFLAGS="$CFLAGS -no-precomp" fi diff --git a/dir.c b/dir.c index be3ee4247f..cce2572e7b 100644 --- a/dir.c +++ b/dir.c @@ -371,22 +371,23 @@ push_braces(ary, s) } static VALUE -dir_s_glob(dir, vstr) - VALUE dir, vstr; +dir_s_glob(dir, str) + VALUE dir, str; { char *p, *pend; char buf[MAXPATHLEN]; char *t, *t0; int nest; VALUE ary; - struct RString *str; - Check_SafeStr(vstr); - str = RSTRING(vstr); + Check_SafeStr(str); + if (RSTRING(str)->len > MAXPATHLEN) { + ArgError("pathname too long (%d bytes)", RSTRING(str)->len); + } ary = ary_new(); - p = str->ptr; - pend = p + str->len; + p = RSTRING(str)->ptr; + pend = p + RSTRING(str)->len; while (p < pend) { t = buf; diff --git a/eval.c b/eval.c index ae4bba96f4..1069ed8c1c 100644 --- a/eval.c +++ b/eval.c @@ -1041,19 +1041,19 @@ rb_eval_string(str) return v; } -void +VALUE rb_eval_cmd(cmd, arg) VALUE cmd, arg; { int state; + VALUE val; struct SCOPE *saved_scope; volatile int safe = rb_safe_level(); if (TYPE(cmd) != T_STRING) { Check_Type(arg, T_ARRAY); - rb_funcall2(cmd, rb_intern("call"), - RARRAY(arg)->len, RARRAY(arg)->ptr); - return; + return rb_funcall2(cmd, rb_intern("call"), + RARRAY(arg)->len, RARRAY(arg)->ptr); } PUSH_CLASS(); @@ -1067,7 +1067,7 @@ rb_eval_cmd(cmd, arg) } if ((state = EXEC_TAG()) == 0) { - eval(TopSelf, cmd, Qnil, 0, 0); + val = eval(TopSelf, cmd, Qnil, 0, 0); } the_scope = saved_scope; @@ -1097,24 +1097,27 @@ rb_eval_cmd(cmd, arg) JUMP_TAG(state); break; } + return val; } -void +VALUE rb_trap_eval(cmd, sig) VALUE cmd; int sig; { int state; + VALUE val; /* OK */ PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { - rb_eval_cmd(cmd, ary_new3(1, INT2FIX(sig))); + val = rb_eval_cmd(cmd, ary_new3(1, INT2FIX(sig))); } POP_TAG(); if (state) { trap_immediate = 0; JUMP_TAG(state); } + return val; } static VALUE @@ -1122,7 +1125,7 @@ superclass(self, node) VALUE self; NODE *node; { - VALUE val = 0; /* OK */ + VALUE val; /* OK */ int state; PUSH_TAG(PROT_NONE); @@ -1130,7 +1133,7 @@ superclass(self, node) val = rb_eval(self, node); } POP_TAG(); - if (state == TAG_RAISE) { + if (state) { superclass_error: switch (nd_type(node)) { case NODE_COLON2: @@ -1351,8 +1354,8 @@ is_defined(self, node, buf) } break; - case NODE_FCALL: case NODE_VCALL: + case NODE_FCALL: val = CLASS_OF(self); goto check_bound; @@ -1401,6 +1404,7 @@ is_defined(self, node, buf) case NODE_MASGN: case NODE_LASGN: case NODE_DASGN: + case NODE_DASGN_PUSH: case NODE_GASGN: case NODE_IASGN: case NODE_CASGN: @@ -2075,6 +2079,19 @@ rb_eval(self, node) result = dyna_var_asgn(node->nd_vid, rb_eval(self, node->nd_value)); break; + 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); + } + break; + case NODE_GASGN: { VALUE val; @@ -2954,6 +2971,10 @@ assign(self, lhs, val) dyna_var_asgn(lhs->nd_vid, val); break; + case NODE_DASGN_PUSH: + push_dvar(lhs->nd_vid, val); + break; + case NODE_CASGN: rb_const_set(the_class, lhs->nd_vid, val); break; @@ -3604,7 +3625,7 @@ f_send(argc, argv, recv) } -#ifdef __STDC__ +#ifdef HAVE_STDARG_PROTOTYPES #include #define va_init_list(a,b) va_start(a,b) #else @@ -4843,6 +4864,10 @@ 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(); @@ -4897,6 +4922,10 @@ 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/ext/Setup b/ext/Setup index 9e3a2474c3..4258bd4873 100644 --- a/ext/Setup +++ b/ext/Setup @@ -1,7 +1,7 @@ #option nodynamic #GD -#curses +curses #dbm #etc #fcntl diff --git a/ext/Win32API/extconf.rb b/ext/Win32API/extconf.rb index 78b5f6a1e8..a03f358593 100644 --- a/ext/Win32API/extconf.rb +++ b/ext/Win32API/extconf.rb @@ -1,7 +1,7 @@ -if PLATFORM =~ /win32/i - $:.unshift '../..' - require 'rbconfig' - include Config - $CFLAGS = "-fno-defer-pop" if /gcc/ =~ CONFIG['CC'] +case PLATFORM +when /cygwin32/,/mingw32/ + $CFLAGS = "-fno-defer-pop" + create_makefile("Win32API") +when /win32/ create_makefile("Win32API") end diff --git a/ext/extmk.rb.nt b/ext/extmk.rb.nt index 6792f2717b..5836e5c681 100644 --- a/ext/extmk.rb.nt +++ b/ext/extmk.rb.nt @@ -1,5 +1,7 @@ #! /usr/local/bin/ruby +$".push 'mkmf.rb' #" + if ARGV[0] == 'static' $force_static = TRUE ARGV.shift @@ -379,7 +381,7 @@ def extmake(target) end end if $static - #$extlibs = " " + $extlibs = " " $extlibs += " " + $LDFLAGS if $LDFLAGS $extlibs += " " + $local_libs if $local_libs $extlibs += " " + $libs if $libs @@ -438,6 +440,8 @@ if $cache_mod end exit if $install or $clean +$extinit = " " unless $extinit +$extobjs = "" if $extlist.size > 0 for s,t in $extlist #for s,t in $static_ext diff --git a/ext/socket/depend b/ext/socket/depend index 3d54fa073c..6e8c3b7d97 100644 --- a/ext/socket/depend +++ b/ext/socket/depend @@ -1 +1 @@ -socket.o : socket.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h $(hdrdir)/io.h $(hdrdir)/sig.h +socket.o : socket.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h $(hdrdir)/rubyio.h $(hdrdir)/rubysig.h diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index e144c5f082..7d2abb8e80 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -120,8 +120,9 @@ ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) res = rb_rescue(rb_eval_string, (VALUE)argv[1], ip_eval_rescue, (VALUE)&failed); trap_immediate = old_trapflg; + Tcl_ResetResult(interp); if (failed) { - Tcl_AppendResult(interp, RSTRING(failed)->ptr, (char*)NULL); + Tcl_AppendResult(interp, STR2CSTR(failed), (char*)NULL); return TCL_ERROR; } @@ -130,12 +131,11 @@ ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) DUMP1("(rb_eval_string result) nil"); return TCL_OK; } - Check_Type(res, T_STRING); /* copy result to the tcl interpreter */ - DUMP2("(rb_eval_string result) %s", RSTRING(res)->ptr); + DUMP2("(rb_eval_string result) %s", STR2CSTR(res)); DUMP1("Tcl_AppendResult"); - Tcl_AppendResult(interp, RSTRING(res)->ptr, (char *)NULL); + Tcl_AppendResult(interp, STR2CSTR(res), (char *)NULL); return TCL_OK; } diff --git a/ext/tkutil/tkutil.c b/ext/tkutil/tkutil.c index 540995eb82..58a382a41b 100644 --- a/ext/tkutil/tkutil.c +++ b/ext/tkutil/tkutil.c @@ -18,8 +18,7 @@ tk_eval_cmd(argc, argv) VALUE cmd, rest; rb_scan_args(argc, argv, "1*", &cmd, &rest); - rb_eval_cmd(cmd, rest); - return Qnil; + return rb_eval_cmd(cmd, rest); } static VALUE diff --git a/file.c b/file.c index 3619e55a29..0feb226d22 100644 --- a/file.c +++ b/file.c @@ -705,8 +705,15 @@ file_s_ftype(obj, fname) struct stat st; char *t; +#if defined(MSDOS) || defined(NT) if (rb_stat(fname, &st) < 0) + rb_sys_fail(RSTRIN(fname)->ptr); +#else + Check_SafeStr(fname); + if (lstat(RSTRING(fname)->ptr, &st) == -1) { rb_sys_fail(RSTRING(fname)->ptr); + } +#endif if (S_ISREG(st.st_mode)) { t = "file"; diff --git a/glob.c b/glob.c index bba41e6687..13ccdc6e86 100644 --- a/glob.c +++ b/glob.c @@ -111,6 +111,10 @@ extern void throw_to_top_level (); extern int interrupt_state; #endif /* SHELL */ +#if defined(NT) +#include "missing/dir.h" +#endif + /* Global variable which controls whether or not * matches .*. Non-zero means don't match .*. */ int noglob_dot_filenames = 1; diff --git a/intern.h b/intern.h index 4096338e1f..aa724d0d3c 100644 --- a/intern.h +++ b/intern.h @@ -103,8 +103,8 @@ VALUE dyna_var_asgn _((ID, VALUE)); void ruby_init _((void)); void ruby_options _((int, char**)); void ruby_run _((void)); -void rb_eval_cmd _((VALUE, VALUE)); -void rb_trap_eval _((VALUE, int)); +VALUE rb_eval_cmd _((VALUE, VALUE)); +VALUE rb_trap_eval _((VALUE, int)); int rb_respond_to _((VALUE, ID)); void rb_raise _((VALUE)); void rb_fatal _((VALUE)); diff --git a/io.c b/io.c index 2d35f8355e..0643f21813 100644 --- a/io.c +++ b/io.c @@ -459,7 +459,11 @@ io_gets_method(argc, argv, io) if (!NIL_P(rs)) Check_Type(rs, T_STRING); } - if (!NIL_P(rs)) { + if (NIL_P(rs)) { + rsptr = 0; + rslen = 0; + } + else { rslen = RSTRING(rs)->len; if (rslen == 0) { rsptr = "\n\n"; @@ -473,10 +477,6 @@ io_gets_method(argc, argv, io) rsptr = RSTRING(rs)->ptr; } } - else { - rsptr = 0; - rslen = 0; - } GetOpenFile(io, fptr); io_readable(fptr); diff --git a/lib/tk.rb b/lib/tk.rb index b44f585b0f..8a772f5dda 100644 --- a/lib/tk.rb +++ b/lib/tk.rb @@ -54,6 +54,7 @@ module TkComm return tk_tcl2ruby(str) unless idx list = tk_tcl2ruby(str[0,idx]) + list = [] if list == "" str = str[idx+1..-1] i = -1 brace = 1 @@ -78,7 +79,6 @@ module TkComm if keys and keys != None for k, v in keys conf.push("-#{k}") - v = install_cmd(v) if v.kind_of? Proc conf.push(v) end end @@ -86,6 +86,20 @@ module TkComm end private :hash_kv + def array2tk_list(ary) + ary.collect{|e| + if e.kind_of? Array + "{#{array2tk_list(e)}}" + elsif e.kind_of? Hash + "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}" + else + s = _get_eval_string(e) + (s.index(/\s/))? "{#{s}}": s + end + }.join(" ") + end + private :array2tk_list + def bool(val) case val when "1", 1, 'yes', 'true' @@ -221,8 +235,12 @@ module TkComm end def _bind(path, context, cmd, args=nil) + context = context.join("><") if context.kind_of? Array + if /,/ =~ context + context = context.split(/\s*,\s*/).join("><") + end + id = install_bind(cmd, args) begin - id = install_bind(cmd, args) tk_call 'bind', path, "<#{context}>", id rescue uninstall_cmd(id) @@ -271,7 +289,7 @@ module TkCore def TkCore.callback(arg) arg = Array(tk_split_list(arg)) - TkUtil.eval_cmd Tk_CMDTBL[arg.shift], *arg + _get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) end def mainloop @@ -282,6 +300,10 @@ module TkCore 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 @@ -325,6 +347,9 @@ module Tk include TkCore extend Tk + TCL_VERSION = INTERP._invoke("info", "tclversion") + TK_VERSION = INTERP._invoke("set", "tk_version") + def root TkRoot.new end @@ -448,8 +473,20 @@ class TkVariable def initialize(val="") @id = Tk_VARIABLE_ID[0] Tk_VARIABLE_ID[0] = Tk_VARIABLE_ID[0].succ - s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #' - INTERP._eval(format('global %s; set %s %s', @id, @id, s)) + if val == [] + INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)', + @id, @id, @id)) + elsif val.kind_of?(Array) + s = '"' + array2tk_list(val).gsub(/[][$"]/, '\\\\\&') + '"' #' + INTERP._eval(format('global %s; array set %s %s', @id, @id, s)) + elsif val.kind_of?(Hash) + s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ + ..gsub(/[][$"]/, '\\\\\&') + '"' #' + INTERP._eval(format('global %s; array set %s %s', @id, @id, s)) + else + s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #' + INTERP._eval(format('global %s; set %s %s', @id, @id, s)) + end end def id @@ -457,11 +494,50 @@ class TkVariable end def value - INTERP._eval(format('global %s; set %s', @id, @id)) + begin + INTERP._eval(format('global %s; set %s', @id, @id)) + rescue + if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" + raise + else + INTERP._eval(format('global %s; array get %s', @id, @id)) + end + end end def value=(val) - INTERP._eval(format('global %s; set %s %s', @id, @id, _get_eval_string(val))) + begin + INTERP._eval(format('global %s; set %s %s', @id, @id, _get_eval_string(val))) + rescue + if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" + raise + else + INTERP._eval(format('global %s; unset %s'), @id, @id) + if val == [] + INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)', + @id, @id, @id)) + elsif val.kind_of?(Array) + s = '"' + array2tk_list(val).gsub(/[][$"]/, '\\\\\&') + '"' #' + INTERP._eval(format('global %s; array set %s %s', @id, @id, s)) + elsif val.kind_of?(Hash) + s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ + .gsub(/[][$"]/, '\\\\\&') + '"' #' + INTERP._eval(format('global %s; array set %s %s', @id, @id, s)) + else + raise + end + end + end + end + + def [](index) + INTERP._eval(format('global %s; set %s(%s)', + @id, @id, _get_eval_string(index))) + end + + def []=(index,val) + INTERP._eval(format('global %s; set %s(%s) %s', @id, @id, + _get_eval_string(index), _get_eval_string(val))) end def to_i @@ -506,6 +582,16 @@ class TkVariable end end +class TkVarAccess +# +module TkPalette + include Tk + extend Tk + + def TkPalette.set(*args) + args = args.to_a.flatten if args.kind_of? Hash + tk_call 'tk_setPalette', *args + end + def TkPalette.setPalette(*args) + TkPalette.set(*args) + end + + def TkPalette.bisque + tk_call 'tk_bisque' + end + + def TkPalette.darken(color, percent) + tk_call 'tkDarken', color, percent + end + + def TkPalette.recolorTree(window, colors) + if not colors.kind_of?(Hash) + fail "2nd arg need to be Hash" + end + + colors.each{|key, value| + begin + if window.cget(key) == tk_call('set', "tkPalette(#{key})") + window[key] = colors[key] + end + rescue + # ignore + end + } + + TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)} + end + + def recolorTree(colors) + TkPalette.recolorTree(self, colors) + end +end diff --git a/lib/tktext.rb b/lib/tktext.rb index a940c31a1b..8e6772c470 100644 --- a/lib/tktext.rb +++ b/lib/tktext.rb @@ -45,6 +45,26 @@ class TkText", id + tk_call @t.path, 'tag', 'bind', @id, "<#{seq}>", id @t._addcmd cmd end + def raise(above=None) + tk_call @t.path, 'tag', 'raise', @id, above + end + def lower(below=None) - tk_call @t.path, 'tag', 'lower', below + tk_call @t.path, 'tag', 'lower', @id, below end def destroy @@ -126,6 +206,18 @@ class TkTextTagvalue); + long val; + + if (!FIXABLE(f)) { + return dbl2big(f); + } + val = f; + return INT2FIX(val); +} + +static VALUE +flo_ceil(num) + VALUE num; +{ + double f = ceil(RFLOAT(num)->value); + long val; + + if (!FIXABLE(f)) { + return dbl2big(f); + } + val = f; + return INT2FIX(val); +} + +static VALUE +flo_round(num) + VALUE num; +{ + double f = RFLOAT(num)->value; + long val; + + if (f > 0.0) f = floor(f+0.5); + if (f < 0.0) f = ceil(f-0.5); + + if (!FIXABLE(f)) { + return dbl2big(f); + } + val = f; + return INT2FIX(val); +} + static VALUE flo_to_f(num) VALUE num; @@ -1410,4 +1455,8 @@ Init_Numeric() rb_define_method(cFloat, "to_f", flo_to_f, 0); rb_define_method(cFloat, "abs", flo_abs, 0); rb_define_method(cFloat, "zero?", flo_zero_p, 0); + + rb_define_method(cFloat, "floor", flo_floor, 0); + rb_define_method(cFloat, "ceil", flo_ceil, 0); + rb_define_method(cFloat, "round", flo_round, 0); } diff --git a/parse.y b/parse.y index d71273f612..1ba5da4375 100644 --- a/parse.y +++ b/parse.y @@ -3379,8 +3379,8 @@ gettable(id) return NEW_LIT(INT2FIX(sourceline)); } else if (is_local_id(id)) { - if (local_id(id)) return NEW_LVAR(id); if (dyna_var_defined(id)) return NEW_DVAR(id); + if (local_id(id)) return NEW_LVAR(id); /* method call without arguments */ return NEW_VCALL(id); } @@ -3429,8 +3429,11 @@ assignable(id, val) else{ if (!dyna_var_defined(id)) { dyna_var_asgn(id, 0); + lhs = NEW_DASGN_PUSH(id, val); + } + else { + lhs = NEW_DASGN(id, val); } - lhs = NEW_DASGN(id, val); } } else if (is_global_id(id)) { diff --git a/regex.c b/regex.c index a9ac531e24..accfbdf457 100644 --- a/regex.c +++ b/regex.c @@ -2971,6 +2971,9 @@ re_match(bufp, string_arg, size, pos, regs) regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; +#ifdef __CHECKER__ + reg_info[mcnt].word = 0; +#endif REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; IS_ACTIVE (reg_info[mcnt]) = 0; MATCHED_SOMETHING (reg_info[mcnt]) = 0; diff --git a/sample/test.rb b/sample/test.rb index b3303959f2..eccbf23382 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -749,6 +749,13 @@ x = proc{proc{}}.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")) +}.call + check "system" ok(`echo foobar` == "foobar\n") ok(`./ruby -e 'print "foobar"'` == 'foobar') diff --git a/util.c b/util.c index a5049a72f4..d886d41c78 100644 --- a/util.c +++ b/util.c @@ -15,6 +15,10 @@ #define RUBY_NO_INLINE #include "ruby.h" +#ifdef NT +#include "missing/file.h" +#endif + int rb_type(obj) VALUE obj; @@ -101,6 +105,10 @@ int *retlen; # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) #endif +#ifdef NT +#include "missing/file.h" +#endif + static char * check_dir(dir) char *dir; @@ -133,7 +141,6 @@ ruby_mktemp() } #if defined(MSDOS) || defined(__CYGWIN32__) || defined(NT) -#include /* * Copyright (c) 1993, Intergraph Corporation * diff --git a/version.h b/version.h index 0ed7bbc426..a5dcad63c1 100644 --- a/version.h +++ b/version.h @@ -1,2 +1,2 @@ -#define RUBY_VERSION "1.1b9_25" -#define VERSION_DATE "98/06/11" +#define RUBY_VERSION "1.1b9_26" +#define VERSION_DATE "98/06/18" diff --git a/win32/Makefile b/win32/Makefile index c7e8b8dbec..d2af7c1363 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -15,7 +15,7 @@ INSTALL_DATA = $(INSTALL) -m 644 PURIFY = -CFLAGS = -nologo -DNT=1 -Ox +CFLAGS = -nologo -DNT=1 -Ox -I. -I./missing LDFLAGS = $(CFLAGS) -Fm #CFLAGS = -nologo -DNT=1 -Zi -MD #LDFLAGS = $(CFLAGS) -Fm -MD diff --git a/win32/config.h b/win32/config.h index c0bbd4212c..8c7b990d8d 100644 --- a/win32/config.h +++ b/win32/config.h @@ -4,7 +4,7 @@ #define SIZEOF_VOIDP 4 #define HAVE_PROTOTYPES 1 #define HAVE_STDARG_PROTOTYPES 1 -#define HAVE_ATTR_NORETURN 1 +/* #define HAVE_ATTR_NORETURN 1 */ /* #define HAVE_DIRENT_H 1 */ /* #define HAVE_UNISTD_H 1 */ #define HAVE_STDLIB_H 1 diff --git a/win32/ruby.def b/win32/ruby.def index 55e212fcae..868b81599d 100644 --- a/win32/ruby.def +++ b/win32/ruby.def @@ -96,7 +96,8 @@ EXPORTS int2inum str2inum big2str - big2int + big2ulong + big2long big_to_i dbl2big big2dbl @@ -365,7 +366,7 @@ EXPORTS str_substr str_modify str_freeze - str_dup_freezed + str_dup_frozen str_taint str_tainted str_resize -- cgit v1.2.3