diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-06-28 14:42:46 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-06-28 14:42:46 +0000 |
commit | f0221db4626bb589f230bf239a7f9df83d7e444f (patch) | |
tree | 0bd6a2a6dde695b2ac3cf1193419676a78f914b9 | |
parent | ee852ed46d1a2a0f894e20e939b079c31e1cdb4b (diff) |
* re.c (rb_reg_expr_str): need to process backslashes properly.
* object.c (rb_any_to_a): declare Object#to_a to be obsolete.
* object.c (rb_Array): do not convert nil into [] automagically.
* object.c (rb_Integer): use "to_int" instead of
"to_i". [experimental]
* object.c (nil_to_f): new method.
* object.c (rb_Integer): Symbols and nil should cause error.
* object.c (rb_Float): nil should cause error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 18 | ||||
-rw-r--r-- | ext/tk/lib/tkcanvas.rb | 28 | ||||
-rw-r--r-- | ext/tk/lib/tktext.rb | 32 | ||||
-rw-r--r-- | lib/mkmf.rb | 2 | ||||
-rw-r--r-- | lib/pp.rb | 2 | ||||
-rw-r--r-- | lib/tracer.rb | 2 | ||||
-rw-r--r-- | lib/tsort.rb | 2 | ||||
-rw-r--r-- | misc/ruby-mode.el | 1 | ||||
-rw-r--r-- | object.c | 36 | ||||
-rw-r--r-- | parse.y | 21 | ||||
-rw-r--r-- | re.c | 10 | ||||
-rw-r--r-- | sample/sieve.rb | 2 | ||||
-rw-r--r-- | sample/test.rb | 3 |
14 files changed, 117 insertions, 63 deletions
@@ -22,6 +22,16 @@ Thu Jun 27 08:28:18 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> * parse.y (literal_concat_string): non-string last expression in #{} was ignored when followed by literal. +Thu Jun 27 03:42:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * re.c (rb_reg_expr_str): need to process backslashes properly. + +Wed Jun 26 17:33:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * object.c (rb_any_to_a): declare Object#to_a to be obsolete. + + * object.c (rb_Array): do not convert nil into [] automagically. + Wed Jun 26 15:40:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> * parse.y (words, qwords): word list literal rules. @@ -39,6 +49,17 @@ Tue Jun 25 19:24:38 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp> * dln.c: remove definition rb_loaderror(). +Tue Jun 25 00:34:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * object.c (rb_Integer): use "to_int" instead of + "to_i". [experimental] + + * object.c (nil_to_f): new method. + + * object.c (rb_Integer): Symbols and nil should cause error. + + * object.c (rb_Float): nil should cause error. + Tue Jun 25 00:21:00 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp> * dln.c: remark definition rb_loaderror(). diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 2e33c4294c..bc9cb0676f 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -995,7 +995,7 @@ module Tk tk_call 'wm', 'title', path, *args end def transient(*args) - window(tk_call 'wm', 'transient', path, *args) + window(tk_call('wm', 'transient', path, *args)) end def withdraw tk_call 'wm', 'withdraw', path @@ -1475,7 +1475,7 @@ module TkSelection TkSelection.handle self, func, type, format end def TkSelection.own(win=None, func=None) - window(tk_call 'selection', 'own', win, func) + window(tk_call('selection', 'own', win, func)) end def own(func=None) TkSelection.own self, func @@ -1617,7 +1617,7 @@ module TkWinfo include Tk extend Tk def TkWinfo.atom(name) - number(tk_call 'winfo', 'atom', name) + number(tk_call('winfo', 'atom', name)) end def winfo_atom(name) TkWinfo.atom name @@ -1899,7 +1899,7 @@ module TkWinfo TkWinfo.y self end def TkWinfo.viewable(window) - bool(tk_call 'winfo', 'viewable', window.path) + bool(tk_call('winfo', 'viewable', window.path)) end def winfo_viewable TkWinfo.viewable self @@ -2469,7 +2469,7 @@ class TkObject<TkKernel when 'text', 'label', 'show', 'data', 'file' tk_call path, 'cget', "-#{slot}" else - tk_tcl2ruby tk_call path, 'cget', "-#{slot}" + tk_tcl2ruby tk_call(path, 'cget', "-#{slot}") end end @@ -2805,9 +2805,9 @@ class TkWindow<TkObject elsif args.length == 1 case args[0] when 'global', :global - return(tk_call 'grab', 'set', '-global', path) + return(tk_call('grab', 'set', '-global', path)) when 'release', :release - return(tk_call 'grab', 'release', path) + return tk_call('grab', 'release', path) else val = tk_call('grab', args[0], path) end @@ -3329,7 +3329,7 @@ class TkListbox<TkTextWin when 'text', 'label', 'show' tk_send 'itemcget', index, "-#{key}" else - tk_tcl2ruby tk_send 'itemcget', index, "-#{key}" + tk_tcl2ruby tk_send('itemcget', index, "-#{key}") end end def itemconfigure(index, key, val=None) @@ -3468,7 +3468,7 @@ class TkMenu<TkWindow when 'text', 'label', 'show' tk_send 'entrycget', index, "-#{key}" else - tk_tcl2ruby tk_send 'entrycget', index, "-#{key}" + tk_tcl2ruby tk_send('entrycget', index, "-#{key}") end end def entryconfigure(index, key, val=None) diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb index ac6ed5362f..18febd2f13 100644 --- a/ext/tk/lib/tkcanvas.rb +++ b/ext/tk/lib/tkcanvas.rb @@ -94,10 +94,10 @@ class TkCanvas<TkWindow end def canvasx(x, *args) - tk_tcl2ruby(tk_send 'canvasx', x, *args) + tk_tcl2ruby(tk_send('canvasx', x, *args)) end def canvasy(y, *args) - tk_tcl2ruby(tk_send 'canvasy', y, *args) + tk_tcl2ruby(tk_send('canvasy', y, *args)) end def coords(tag, *args) @@ -122,7 +122,7 @@ class TkCanvas<TkWindow end def find(mode, *args) - list(tk_send 'find', mode, *args).collect!{|id| + list(tk_send('find', mode, *args)).collect!{|id| TkcItem.id2obj(self, id) } end @@ -191,7 +191,7 @@ class TkCanvas<TkWindow when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' tk_send 'itemcget', tagid(tagOrId), "-#{option}" else - tk_tcl2ruby tk_send 'itemcget', tagid(tagOrId), "-#{option}" + tk_tcl2ruby tk_send('itemcget', tagid(tagOrId), "-#{option}") end end @@ -231,8 +231,8 @@ class TkCanvas<TkWindow if key case key.to_s when 'dash', 'activedash', 'disableddash' - conf = tk_split_simplelist(tk_send 'itemconfigure', - tagid(tagOrId), "-#{key}") + conf = tk_split_simplelist(tk_send('itemconfigure', + tagid(tagOrId), "-#{key}")) if conf[3] && conf[3] =~ /^[0-9]/ conf[3] = list(conf[3]) end @@ -240,17 +240,17 @@ class TkCanvas<TkWindow conf[4] = list(conf[4]) end when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' - conf = tk_split_simplelist(tk_send 'itemconfigure', - tagid(tagOrId), "-#{key}") + conf = tk_split_simplelist(tk_send('itemconfigure', + tagid(tagOrId), "-#{key}")) else - conf = tk_split_list(tk_send 'itemconfigure', - tagid(tagOrId), "-#{key}") + conf = tk_split_list(tk_send('itemconfigure', + tagid(tagOrId), "-#{key}")) end conf[0] = conf[0][1..-1] conf else - tk_split_simplelist(tk_send 'itemconfigure', - tagid(tagOrId)).collect{|conflist| + tk_split_simplelist(tk_send('itemconfigure', + tagid(tagOrId))).collect{|conflist| conf = tk_split_simplelist(conflist) conf[0] = conf[0][1..-1] case conf[0] @@ -330,7 +330,7 @@ class TkCanvas<TkWindow end def itemtype(tag) - TkcItem.type2class(tk_send 'type', tagid(tag)) + TkcItem.type2class(tk_send('type', tagid(tag))) end end @@ -812,7 +812,7 @@ class TkPhotoImage<TkImage when 'data', 'file' tk_send 'cget', option else - tk_tcl2ruby tk_send 'cget', option + tk_tcl2ruby tk_send('cget', option) end end diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb index 9eb70dcd61..952c05f566 100644 --- a/ext/tk/lib/tktext.rb +++ b/ext/tk/lib/tktext.rb @@ -189,7 +189,7 @@ class TkText<TkTextWin when 'text', 'label', 'show', 'data', 'file' tk_call @path, 'tag', 'cget', tag, "-#{key}" else - tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}" + tk_tcl2ruby tk_call(@path, 'tag', 'cget', tag, "-#{key}") end end @@ -636,7 +636,7 @@ class TkTextTag<TkObject when 'text', 'label', 'show', 'data', 'file' tk_call @t.path, 'tag', 'cget', @id, "-#{key}" else - tk_tcl2ruby tk_call @t.path, 'tag', 'cget', @id, "-#{key}" + tk_tcl2ruby tk_call(@t.path, 'tag', 'cget', @id, "-#{key}") end end @@ -854,7 +854,7 @@ class TkTextWindow<TkObject when 'text', 'label', 'show', 'data', 'file' tk_call @t.path, 'window', 'cget', @index, "-#{slot}" else - tk_tcl2ruby tk_call @t.path, 'window', 'cget', @index, "-#{slot}" + tk_tcl2ruby tk_call(@t.path, 'window', 'cget', @index, "-#{slot}") end end @@ -904,17 +904,17 @@ class TkTextWindow<TkObject if slot case slot.to_s when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(tk_call @t.path, 'window', 'configure', - @index, "-#{slot}") + conf = tk_split_simplelist(tk_call(@t.path, 'window', 'configure', + @index, "-#{slot}")) else - conf = tk_split_list(tk_call @t.path, 'window', 'configure', - @index, "-#{slot}") + conf = tk_split_list(tk_call(@t.path, 'window', 'configure', + @index, "-#{slot}")) end conf[0] = conf[0][1..-1] conf else - tk_split_simplelist(tk_call @t.path, 'window', 'configure', - @index).collect{|conflist| + tk_split_simplelist(tk_call(@t.path, 'window', 'configure', + @index)).collect{|conflist| conf = tk_split_simplelist(conflist) conf[0] = conf[0][1..-1] case conf[0] @@ -976,7 +976,7 @@ class TkTextImage<TkObject when 'text', 'label', 'show', 'data', 'file' tk_call @t.path, 'image', 'cget', @index, "-#{slot}" else - tk_tcl2ruby tk_call @t.path, 'image', 'cget', @index, "-#{slot}" + tk_tcl2ruby tk_call(@t.path, 'image', 'cget', @index, "-#{slot}") end end @@ -1003,17 +1003,17 @@ class TkTextImage<TkObject if slot case slot.to_s when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(tk_call @t.path, 'image', 'configure', - @index, "-#{slot}") + conf = tk_split_simplelist(tk_call(@t.path, 'image', 'configure', + @index, "-#{slot}")) else - conf = tk_split_list(tk_call @t.path, 'image', 'configure', - @index, "-#{slot}") + conf = tk_split_list(tk_call(@t.path, 'image', 'configure', + @index, "-#{slot}")) end conf[0] = conf[0][1..-1] conf else - tk_split_simplelist(tk_call @t.path, 'image', 'configure', - @index).collect{|conflist| + tk_split_simplelist(tk_call(@t.path, 'image', 'configure', + @index)).collect{|conflist| conf = tk_split_simplelist(conflist) conf[0] = conf[0][1..-1] case conf[0] diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 7f0e121176..58201d02a7 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -452,7 +452,7 @@ def create_makefile(target, srcprefix = nil) elsif RUBY_PLATFORM =~ /cygwin|mingw/ deffile = target + '.def' if not File.exist? deffile - if File.exist? File.join srcdir, deffile + if File.exist? File.join(srcdir, deffile) deffile = File.join srcdir, deffile else open(deffile, 'wb') do |f| @@ -214,7 +214,7 @@ class PP < PrettyPrint text '=' group(1) { breakable '' - pp(obj.instance_eval v) + pp(obj.instance_eval(v)) } } } diff --git a/lib/tracer.rb b/lib/tracer.rb index 817f68484e..6ff9caa98c 100644 --- a/lib/tracer.rb +++ b/lib/tracer.rb @@ -84,7 +84,7 @@ class Tracer def get_line(file, line) if p = @get_line_procs[file] - return p.call line + return p.call(line) end unless list = SCRIPT_LINES__[file] diff --git a/lib/tsort.rb b/lib/tsort.rb index 2c3c4b2c4e..0dd68c6b8a 100644 --- a/lib/tsort.rb +++ b/lib/tsort.rb @@ -184,7 +184,7 @@ module TSort if component.size == 1 yield component.first else - raise Cyclic.new "topological sort failed: #{component.inspect}" + raise Cyclic.new("topological sort failed: #{component.inspect}") end } end diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 6750035e71..13ca032bb9 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -782,6 +782,7 @@ An end of a defun is found by moving forward from the beginning of one." (make-local-variable 'font-lock-defaults) (make-local-variable 'font-lock-keywords) (make-local-variable 'font-lock-syntax-table) + (make-local-variable 'font-lock-syntactic-keywords) (setq font-lock-defaults '((ruby-font-lock-keywords) nil nil)) (setq font-lock-keywords ruby-font-lock-keywords) (setq font-lock-syntax-table ruby-font-lock-syntax-table) @@ -18,6 +18,7 @@ #include <stdio.h> #include <errno.h> #include <ctype.h> +#include <math.h> VALUE rb_mKernel; VALUE rb_cObject; @@ -134,6 +135,7 @@ static VALUE rb_any_to_a(obj) VALUE obj; { + rb_warn("default `to_a' will be obsolete"); return rb_ary_new3(1, obj); } @@ -338,6 +340,13 @@ nil_to_i(obj) } static VALUE +nil_to_f(obj) + VALUE obj; +{ + return rb_float_new(0.0); +} + +static VALUE nil_to_s(obj) VALUE obj; { @@ -917,6 +926,7 @@ rb_check_convert_type(val, type, tname, method) return v; } + static VALUE rb_to_integer(val, method) VALUE val; @@ -941,6 +951,8 @@ VALUE rb_Integer(val) VALUE val; { + VALUE v; + switch (TYPE(val)) { case T_FLOAT: if (RFLOAT(val)->value <= (double)FIXNUM_MAX @@ -961,7 +973,13 @@ rb_Integer(val) default: break; } - return rb_to_integer(val, "to_i"); + + if (rb_respond_to(val, rb_intern("to_int"))) { + return rb_to_integer(val, "to_int"); + } + else { + return rb_to_integer(val, "to_i"); + } } static VALUE @@ -1073,10 +1091,17 @@ rb_Float(val) return rb_float_new(rb_str_to_dbl(val, Qtrue)); case T_NIL: - return rb_float_new(0.0); + rb_raise(rb_eTypeError, "cannot convert nil into Float"); + break; default: - return rb_convert_type(val, T_FLOAT, "Float", "to_f"); + { + VALUE f = rb_convert_type(val, T_FLOAT, "Float", "to_f"); + if (isnan(RFLOAT(f)->value)) { + rb_raise(rb_eArgError, "invalid value for Float()"); + } + return f; + } } } @@ -1143,6 +1168,9 @@ rb_Array(val) { ID to_ary; + if (NIL_P(val)) { + rb_raise(rb_eTypeError, "cannot convert nil into Array"); + } if (TYPE(val) == T_ARRAY) return val; to_ary = rb_intern("to_ary"); if (rb_respond_to(val, to_ary)) { @@ -1251,7 +1279,7 @@ Init_Object() rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0); rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 0); - rb_define_method(rb_mKernel, "to_a", rb_any_to_a, 0); + rb_define_method(rb_mKernel, "to_a", rb_any_to_a, 0); /* to be removed */ rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0); rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0); rb_define_method(rb_mKernel, "methods", rb_obj_methods, 0); @@ -233,7 +233,7 @@ static void top_local_setup(); %type <node> words qwords word_list qword_list word %type <val> literal numeric %type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call -%type <node> expr_value arg_value primary_value block_call_value +%type <node> expr_value arg_value primary_value %type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure %type <node> args when_args call_args call_args2 open_args paren_args opt_paren_args %type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs @@ -605,11 +605,11 @@ command_call : command ; block_command : block_call - | block_call_value '.' operation2 command_args + | block_call '.' operation2 command_args { $$ = new_call($1, $3, $4); } - | block_call_value tCOLON2 operation2 command_args + | block_call tCOLON2 operation2 command_args { $$ = new_call($1, $3, $4); } @@ -1075,6 +1075,7 @@ arg_value : arg aref_args : none | command opt_nl { + rb_warn("parenthesize argument(s) for future version"); $$ = NEW_LIST($1); } | args trailer @@ -1107,10 +1108,12 @@ paren_args : '(' none ')' } | '(' block_call opt_nl ')' { + rb_warn("parenthesize argument for future version"); $$ = NEW_LIST($2); } | '(' args ',' block_call opt_nl ')' { + rb_warn("parenthesize argument for future version"); $$ = list_append($2, $4); } ; @@ -1121,6 +1124,7 @@ opt_paren_args : none call_args : command { + rb_warn("parenthesize argument(s) for future version"); $$ = NEW_LIST($1); } | args opt_block_arg @@ -1623,23 +1627,16 @@ block_call : command do_block $$ = $2; fixpos($$, $2); } - | block_call_value '.' operation2 opt_paren_args + | block_call '.' operation2 opt_paren_args { $$ = new_call($1, $3, $4); } - | block_call_value tCOLON2 operation2 opt_paren_args + | block_call tCOLON2 operation2 opt_paren_args { $$ = new_call($1, $3, $4); } ; -block_call_value : block_call - { - value_expr($$); - $$ = $1; - } - ; - method_call : operation paren_args { $$ = new_fcall($1, $2); @@ -236,7 +236,14 @@ rb_reg_expr_str(str, s, len) else { p = s; while (p<pend) { - if (*p == '/' && (s == p || p[-1] != '\\')) { + if (*p == '\\') { + rb_str_buf_cat(str, p, 1); + p++; + rb_str_buf_cat(str, p, mbclen(*p)); + p += mbclen(*p); + continue; + } + else if (*p == '/') { char c = '\\'; rb_str_buf_cat(str, &c, 1); rb_str_buf_cat(str, p, 1); @@ -244,6 +251,7 @@ rb_reg_expr_str(str, s, len) else if (ismbchar(*p)) { rb_str_buf_cat(str, p, mbclen(*p)); p += mbclen(*p); + need_escape = 1; continue; } else if (ISPRINT(*p)) { diff --git a/sample/sieve.rb b/sample/sieve.rb index 359c185f20..e0bb21d640 100644 --- a/sample/sieve.rb +++ b/sample/sieve.rb @@ -11,4 +11,4 @@ for i in 2 .. Math.sqrt(max) sieve[j] = nil end end -puts sieve.compact.join ", " +puts sieve.compact.join(", ") diff --git a/sample/test.rb b/sample/test.rb index fb2aee724d..9cf62b8eb0 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1212,8 +1212,7 @@ end def valid_syntax?(code, fname) eval("BEGIN {return true}\n#{code}", nil, fname, 0) rescue Exception - p $! -ensure + puts $!.message false end |