diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-18 07:47:15 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-18 07:47:15 +0000 |
commit | 992923053cfb51dc04c6a7ee07ca6fff1b61d1a5 (patch) | |
tree | 2b2857adc35295dcd45c57c338c440ec16f99eff | |
parent | 16487ee284f17cfbf6fad9f6b2fedc57f0f37e0a (diff) |
1.1b9_26
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | Makefile.in | 16 | ||||
-rw-r--r-- | configure | 8 | ||||
-rw-r--r-- | dir.c | 15 | ||||
-rw-r--r-- | eval.c | 51 | ||||
-rw-r--r-- | ext/Setup | 2 | ||||
-rw-r--r-- | ext/Win32API/extconf.rb | 10 | ||||
-rw-r--r-- | ext/extmk.rb.nt | 6 | ||||
-rw-r--r-- | ext/socket/depend | 2 | ||||
-rw-r--r-- | ext/tcltklib/tcltklib.c | 8 | ||||
-rw-r--r-- | ext/tkutil/tkutil.c | 3 | ||||
-rw-r--r-- | file.c | 7 | ||||
-rw-r--r-- | glob.c | 4 | ||||
-rw-r--r-- | intern.h | 4 | ||||
-rw-r--r-- | io.c | 10 | ||||
-rw-r--r-- | lib/tk.rb | 177 | ||||
-rw-r--r-- | lib/tkpalette.rb | 46 | ||||
-rw-r--r-- | lib/tktext.rb | 268 | ||||
-rw-r--r-- | missing/nt.h | 16 | ||||
-rw-r--r-- | node.h | 2 | ||||
-rw-r--r-- | numeric.c | 49 | ||||
-rw-r--r-- | parse.y | 7 | ||||
-rw-r--r-- | regex.c | 3 | ||||
-rw-r--r-- | sample/test.rb | 7 | ||||
-rw-r--r-- | util.c | 9 | ||||
-rw-r--r-- | version.h | 4 | ||||
-rw-r--r-- | win32/Makefile | 2 | ||||
-rw-r--r-- | win32/config.h | 2 | ||||
-rw-r--r-- | win32/ruby.def | 5 |
30 files changed, 645 insertions, 119 deletions
@@ -1,3 +1,23 @@ +Thu Jun 18 16:46:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * experimental release 1.1b9_26. + +Thu Jun 18 13:37:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * 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 <matz@netlab.co.jp> + + * parse.y (gettable): nesting local variables should have higher + priority than normal local variables. + Tue Jun 16 12:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * bignum.c (str2inum): handles `+ddd'. @@ -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 @@ -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 @@ -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; @@ -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 <stdarg.h> #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; @@ -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 @@ -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"; @@ -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; @@ -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)); @@ -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); @@ -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<TkVariable + def initialize(varname, val=nil) + @id = varname + if val + s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #' + INTERP._eval(format('global %s; set %s %s', @id, @id, s)) + end + end +end + module TkSelection include Tk extend Tk @@ -577,49 +663,49 @@ module TkWinfo def TkWinfo.depth(window) number(tk_call('winfo', 'depth', window.path)) end - def winfo_depth(window) + def winfo_depth TkWinfo.depth self end def TkWinfo.exist?(window) bool(tk_call('winfo', 'exists', window.path)) end - def winfo_exist?(window) + def winfo_exist? TkWinfo.exist? self end def TkWinfo.fpixels(window, number) number(tk_call('winfo', 'fpixels', window.path, number)) end - def winfo_fpixels(window, number) + def winfo_fpixels(number) TkWinfo.fpixels self end def TkWinfo.geometry(window) list(tk_call('winfo', 'geometry', window.path)) end - def winfo_geometry(window) + def winfo_geometry TkWinfo.geometry self end def TkWinfo.height(window) number(tk_call('winfo', 'height', window.path)) end - def winfo_height(window) + def winfo_height TkWinfo.height self end def TkWinfo.id(window) number(tk_call('winfo', 'id', window.path)) end - def winfo_id(window) + def winfo_id TkWinfo.id self end def TkWinfo.mapped?(window) bool(tk_call('winfo', 'ismapped', window.path)) end - def winfo_mapped?(window) + def winfo_mapped? TkWinfo.mapped? self end def TkWinfo.parent(window) window(tk_call('winfo', 'parent', window.path)) end - def winfo_parent(window) + def winfo_parent TkWinfo.parent self end def TkWinfo.widget(id) @@ -631,139 +717,139 @@ module TkWinfo def TkWinfo.pixels(window, number) number(tk_call('winfo', 'pixels', window.path, number)) end - def winfo_pixels(window, number) + def winfo_pixels(number) TkWinfo.pixels self, number end def TkWinfo.reqheight(window) number(tk_call('winfo', 'reqheight', window.path)) end - def winfo_reqheight(window) + def winfo_reqheight TkWinfo.reqheight self end def TkWinfo.reqwidth(window) number(tk_call('winfo', 'reqwidth', window.path)) end - def winfo_reqwidth(window) + def winfo_reqwidth TkWinfo.reqwidth self end def TkWinfo.rgb(window, color) list(tk_call('winfo', 'rgb', window.path, color)) end - def winfo_rgb(window, color) + def winfo_rgb(color) TkWinfo.rgb self, color end def TkWinfo.rootx(window) number(tk_call('winfo', 'rootx', window.path)) end - def winfo_rootx(window) + def winfo_rootx TkWinfo.rootx self end def TkWinfo.rooty(window) number(tk_call('winfo', 'rooty', window.path)) end - def winfo_rooty(window) + def winfo_rooty TkWinfo.rooty self end def TkWinfo.screen(window) tk_call 'winfo', 'screen', window.path end - def winfo_screen(window) + def winfo_screen TkWinfo.screen self end def TkWinfo.screencells(window) number(tk_call('winfo', 'screencells', window.path)) end - def winfo_screencells(window) + def winfo_screencells TkWinfo.screencells self end def TkWinfo.screendepth(window) number(tk_call('winfo', 'screendepth', window.path)) end - def winfo_screendepth(window) + def winfo_screendepth TkWinfo.screendepth self end def TkWinfo.screenheight (window) number(tk_call('winfo', 'screenheight', window.path)) end - def winfo_screenheight(window) + def winfo_screenheight TkWinfo.screenheight self end def TkWinfo.screenmmheight(window) number(tk_call('winfo', 'screenmmheight', window.path)) end - def winfo_screenmmheight(window) + def winfo_screenmmheight TkWinfo.screenmmheight self end def TkWinfo.screenmmwidth(window) number(tk_call('winfo', 'screenmmwidth', window.path)) end - def winfo_screenmmwidth(window) + def winfo_screenmmwidth TkWinfo.screenmmwidth self end def TkWinfo.screenvisual(window) tk_call 'winfo', 'screenvisual', window.path end - def winfo_screenvisual(window) + def winfo_screenvisual TkWinfo.screenvisual self end def TkWinfo.screenwidth(window) number(tk_call('winfo', 'screenwidth', window.path)) end - def winfo_screenwidth(window) + def winfo_screenwidth TkWinfo.screenwidth self end def TkWinfo.toplevel(window) window(tk_call('winfo', 'toplevel', window.path)) end - def winfo_toplevel(window) + def winfo_toplevel TkWinfo.toplevel self end def TkWinfo.visual(window) tk_call 'winfo', 'visual', window.path end - def winfo_visual(window) + def winfo_visual TkWinfo.visual self end def TkWinfo.vrootheigh(window) number(tk_call('winfo', 'vrootheight', window.path)) end - def winfo_vrootheight(window) + def winfo_vrootheight TkWinfo.vrootheight self end def TkWinfo.vrootwidth(window) number(tk_call('winfo', 'vrootwidth', window.path)) end - def winfo_vrootwidth(window) + def winfo_vrootwidth TkWinfo.vrootwidth self end def TkWinfo.vrootx(window) number(tk_call('winfo', 'vrootx', window.path)) end - def winfo_vrootx(window) + def winfo_vrootx TkWinfo.vrootx self end def TkWinfo.vrooty(window) number(tk_call('winfo', 'vrooty', window.path)) end - def winfo_vrooty(window) + def winfo_vrooty TkWinfo.vrooty self end def TkWinfo.width(window) number(tk_call('winfo', 'width', window.path)) end - def winfo_width(window) + def winfo_width TkWinfo.width self end def TkWinfo.x(window) number(tk_call('winfo', 'x', window.path)) end - def winfo_x(window) + def winfo_x TkWinfo.x self end def TkWinfo.y(window) number(tk_call('winfo', 'y', window.path)) end - def winfo_y(window) + def winfo_y TkWinfo.y self end end @@ -804,7 +890,7 @@ module TkGrid if args[-1].kind_of?(Hash) keys = args.pop end - wins = [widget.path] + wins = [widget.epath] for i in args wins.push i.epath end @@ -928,6 +1014,19 @@ class TkObject<TkKernel configure slot, install_cmd(value) end + def configinfo(slot = nil) + if slot + conf = tk_split_list(tk_send('configure', "-#{slot}") ) + conf[0] = conf[0][1..-1] + conf + else + tk_split_list(tk_send('configure') ).collect{|conf| + conf[0] = conf[0][1..-1] + conf + } + end + end + def bind(context, cmd=Proc.new, args=nil) _bind path, context, cmd, args end diff --git a/lib/tkpalette.rb b/lib/tkpalette.rb new file mode 100644 index 0000000000..b317330937 --- /dev/null +++ b/lib/tkpalette.rb @@ -0,0 +1,46 @@ +# +# tkpalette.rb : methods for Tcl/Tk standard library 'palette.tcl' +# 1998/06/18 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# +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<TkTextWin end } end + def image_names + tk_send('image', 'names').collect{|elt| + if not @tags[elt] + elt + else + @tags[elt] + end + } + end + + def set_insert(index) + tk_send 'mark', 'set', 'insert', index + end + def set_current(index) + tk_send 'mark', 'set', 'current', index + end + + def insert(index, chars, *tags) + super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') + end def destroy @tags.each_value do |t| @@ -68,6 +88,15 @@ class TkText<TkTextWin tk_send 'debug', boolean end + def bbox(index) + inf = tk_send('bbox', index) + (inf == "")? [0,0,0,0]: inf + end + def dlineinfo(index) + inf = tk_send('dlineinfo', index) + (inf == "")? [0,0,0,0,0]: inf + end + def yview(*what) tk_send 'yview', *what end @@ -107,18 +136,69 @@ class TkTextTag<TkObject tk_call @t.path, 'tag', 'remove', @id, *index end + def ranges + l = tk_split_list(tk_call(@t.path, 'tag', 'ranges', @id)) + r = [] + while key=l.shift + r.push [key, l.shift] + end + r + end + + def nextrange(first, last=nil) + l = tk_split_list(tk_call(@t.path, 'tag', 'nextrange', @id, first, last)) + r = [] + while key=l.shift + r.push [key, l.shift] + end + r + end + + def prevrange(first, last=nil) + l = tk_split_list(tk_call(@t.path, 'tag', 'prevrange', @id, first, last)) + r = [] + while key=l.shift + r.push [key, l.shift] + end + r + end + + def [](key) + cget key + end + + def []=(key,val) + configure key, val + end + + def cget(key) + tk_call @t.path, 'tag', 'cget', @id, "-#{key}" + end + def configure(keys) tk_call @t.path, 'tag', 'configure', @id, *hash_kv(keys) end +# def configure(key, value) +# if value == FALSE +# value = "0" +# elsif value.kind_of? Proc +# value = install_cmd(value) +# end +# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value +# end def bind(seq, cmd=Proc.new, args=nil) id = install_bind(cmd, args) - tk_call @t, 'tag', 'bind', @id, "<#{seq}>", 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 TkTextTag<TkObject end end +class TkTextTagSel<TkTextTag + def initialize(parent, keys=nil) + if not parent.kind_of?(TkText) + fail format("%s need to be TkText", parent.inspect) + end + @t = parent + @path = @id = 'sel' + tk_call @t.path, "tag", "configure", @id, *hash_kv(keys) + @t._addtag id, self + end +end + class TkTextMark<TkObject $tk_text_mark = 'mark0000' def initialize(parent, index) @@ -150,19 +242,183 @@ class TkTextMark<TkObject tk_call @t.path, 'mark', 'unset', @id end alias destroy unset + + def gravity + tk_call @t.path, 'mark', 'gravity', @id + end + + def gravity=(direction) + tk_call @t.path, 'mark', 'gravity', @id, direction + end +end + +class TkTextMarkInsert<TkTextMark + def initialize(parent, index=nil) + if not parent.kind_of?(TkText) + fail format("%s need to be TkText", parent.inspect) + end + @t = parent + @path = @id = 'insert' + tk_call @t.path, 'mark', 'set', @id, index if index + @t._addtag id, self + end +end + +class TkTextMarkCurrent<TkTextMark + def initialize(parent,index=nil) + if not parent.kind_of?(TkText) + fail format("%s need to be TkText", parent.inspect) + end + @t = parent + @path = @id = 'current' + tk_call @t.path, 'mark', 'set', @id, index if index + @t._addtag id, self + end end class TkTextWindow<TkObject - def initialize(parent, index, *args) + def initialize(parent, index, keys) if not parent.kind_of?(TkText) fail format("%s need to be TkText", parent.inspect) end @t = parent - @path = @index = index - tk_call @t.path, 'window', 'create', index, *args + if index == 'end' + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) + elsif index.kind_of? TkTextMark + if tk_call(@t.path,'index',index.path) == tk_call(@t.path,'index','end') + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) + else + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index.path)) + end + else + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index)) + end + @path.gravity = 'left' + @index = @path.path + @id = keys['window'] + if keys['create'] + @p_create = keys['create'] + if @p_create.kind_of? Proc + keys['create'] = install_cmd(proc{@id = @p_create.call; @id.path}) + end + end + tk_call @t.path, 'window', 'create', @index, *hash_kv(keys) + end + + def [](slot) + cget(slot) + end + def []=(slot, value) + configure(slot, value) + end + + def cget(slot) + tk_call @t.path, 'window', 'cget', @index, "-#{slot}" end def configure(slot, value) - tk_call @t.path, 'window', 'configure', @index, "-#{slot}", value + @id = value if slot == 'window' + if slot == 'create' + self.create=value + else + tk_call @t.path, 'window', 'configure', @index, "-#{slot}", value + end + end + + def window + @id + end + + def window=(value) + tk_call @t.path, 'window', 'configure', @index, '-window', value + @id = value + end + + def create + @p_create + end + + def create=(value) + @p_create = value + if @p_create.kind_of? Proc + value = install_cmd(proc{@id = @p_create.call}) + end + tk_call @t.path, 'window', 'configure', @index, '-create', value + end + + def configinfo(slot = nil) + if slot + conf = tk_split_list(tk_call @t.path, 'window', 'configure', + @index, "-#{slot}") + conf[0] = conf[0][1..-1] + conf + else + tk_split_list(tk_call @t.path, 'window', 'configure', + @index).collect{|conf| + conf[0] = conf[0][1..-1] + conf + } + end + end +end + +class TkTextImage<TkObject + def initialize(parent, index, keys) + if not parent.kind_of?(TkText) + fail format("%s need to be TkText", parent.inspect) + end + @t = parent + if index == 'end' + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) + elsif index.kind_of? TkTextMark + if tk_call(@t.path,'index',index.path) == tk_call(@t.path,'index','end') + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) + else + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index.path)) + end + else + @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index)) + end + @path.gravity = 'left' + @index = @path.path + @id = tk_call(@t.path, 'image', 'create', @index, *hash_kv(keys)) + end + + def [](slot) + cget(slot) + end + def []=(slot, value) + configure(slot, value) + end + + def cget(slot) + tk_call @t.path, 'image', 'cget', @index, "-#{slot}" + end + + def configure(slot, value) + tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value + end + + def image + tk_call @t.path, 'image', 'configure', @index, '-image' + end + + def image=(value) + tk_call @t.path, 'image', 'configure', @index, '-image', value + end + + def configinfo(slot = nil) + if slot + conf = tk_split_list(tk_call @t.path, 'image', 'configure', + @index, "-#{slot}") + conf[0] = conf[0][1..-1] + conf + else + tk_split_list(tk_call @t.path, 'image', 'configure', + @index).collect{|conf| + conf[0] = conf[0][1..-1] + conf + } + end end end diff --git a/missing/nt.h b/missing/nt.h index 830b9edf13..915a748e5b 100644 --- a/missing/nt.h +++ b/missing/nt.h @@ -230,20 +230,8 @@ extern char *mystrerror(int); #define pclose mypclose #endif -#undef va_start -#undef va_end - -#ifdef popen -#undef popen -#define popen mypopen -#endif -#ifdef pclose -#undef pclose -#define pclose mypclose -#endif - -#undef va_start -#undef va_end +/* #undef va_start */ +/* #undef va_end */ #ifdef fdopen #undef fdopen @@ -41,6 +41,7 @@ enum node_type { NODE_MASGN, NODE_LASGN, NODE_DASGN, + NODE_DASGN_PUSH, NODE_GASGN, NODE_IASGN, NODE_CASGN, @@ -250,6 +251,7 @@ typedef struct RNode { #define NEW_GASGN(v,val) node_newnode(NODE_GASGN,v,val,rb_global_entry(v)) #define NEW_LASGN(v,val) node_newnode(NODE_LASGN,v,val,local_cnt(v)) #define NEW_DASGN(v,val) node_newnode(NODE_DASGN,v,val,0); +#define NEW_DASGN_PUSH(v,val) node_newnode(NODE_DASGN_PUSH,v,val,0); #define NEW_IASGN(v,val) node_newnode(NODE_IASGN,v,val,0) #define NEW_CASGN(v,val) node_newnode(NODE_CASGN,v,val,0) #define NEW_OP_ASGN1(p,id,a) node_newnode(NODE_OP_ASGN1,p,id,a) @@ -574,6 +574,51 @@ flo_to_i(num) } static VALUE +flo_floor(num) + VALUE num; +{ + double f = floor(RFLOAT(num)->value); + 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); } @@ -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)) { @@ -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') @@ -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 <fcntl.h> /* * Copyright (c) 1993, Intergraph Corporation * @@ -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 |