mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
ee852ed46d
commit
f0221db462
14 changed files with 117 additions and 63 deletions
21
ChangeLog
21
ChangeLog
|
@ -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
|
* parse.y (literal_concat_string): non-string last expression in
|
||||||
#{} was ignored when followed by literal.
|
#{} 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>
|
Wed Jun 26 15:40:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* parse.y (words, qwords): word list literal rules.
|
* 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().
|
* 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>
|
Tue Jun 25 00:21:00 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
|
||||||
|
|
||||||
* dln.c: remark definition rb_loaderror().
|
* dln.c: remark definition rb_loaderror().
|
||||||
|
|
|
@ -995,7 +995,7 @@ module Tk
|
||||||
tk_call 'wm', 'title', path, *args
|
tk_call 'wm', 'title', path, *args
|
||||||
end
|
end
|
||||||
def transient(*args)
|
def transient(*args)
|
||||||
window(tk_call 'wm', 'transient', path, *args)
|
window(tk_call('wm', 'transient', path, *args))
|
||||||
end
|
end
|
||||||
def withdraw
|
def withdraw
|
||||||
tk_call 'wm', 'withdraw', path
|
tk_call 'wm', 'withdraw', path
|
||||||
|
@ -1475,7 +1475,7 @@ module TkSelection
|
||||||
TkSelection.handle self, func, type, format
|
TkSelection.handle self, func, type, format
|
||||||
end
|
end
|
||||||
def TkSelection.own(win=None, func=None)
|
def TkSelection.own(win=None, func=None)
|
||||||
window(tk_call 'selection', 'own', win, func)
|
window(tk_call('selection', 'own', win, func))
|
||||||
end
|
end
|
||||||
def own(func=None)
|
def own(func=None)
|
||||||
TkSelection.own self, func
|
TkSelection.own self, func
|
||||||
|
@ -1617,7 +1617,7 @@ module TkWinfo
|
||||||
include Tk
|
include Tk
|
||||||
extend Tk
|
extend Tk
|
||||||
def TkWinfo.atom(name)
|
def TkWinfo.atom(name)
|
||||||
number(tk_call 'winfo', 'atom', name)
|
number(tk_call('winfo', 'atom', name))
|
||||||
end
|
end
|
||||||
def winfo_atom(name)
|
def winfo_atom(name)
|
||||||
TkWinfo.atom name
|
TkWinfo.atom name
|
||||||
|
@ -1899,7 +1899,7 @@ module TkWinfo
|
||||||
TkWinfo.y self
|
TkWinfo.y self
|
||||||
end
|
end
|
||||||
def TkWinfo.viewable(window)
|
def TkWinfo.viewable(window)
|
||||||
bool(tk_call 'winfo', 'viewable', window.path)
|
bool(tk_call('winfo', 'viewable', window.path))
|
||||||
end
|
end
|
||||||
def winfo_viewable
|
def winfo_viewable
|
||||||
TkWinfo.viewable self
|
TkWinfo.viewable self
|
||||||
|
@ -2469,7 +2469,7 @@ class TkObject<TkKernel
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
tk_call path, 'cget', "-#{slot}"
|
tk_call path, 'cget', "-#{slot}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_call path, 'cget', "-#{slot}"
|
tk_tcl2ruby tk_call(path, 'cget', "-#{slot}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2805,9 +2805,9 @@ class TkWindow<TkObject
|
||||||
elsif args.length == 1
|
elsif args.length == 1
|
||||||
case args[0]
|
case args[0]
|
||||||
when 'global', :global
|
when 'global', :global
|
||||||
return(tk_call 'grab', 'set', '-global', path)
|
return(tk_call('grab', 'set', '-global', path))
|
||||||
when 'release', :release
|
when 'release', :release
|
||||||
return(tk_call 'grab', 'release', path)
|
return tk_call('grab', 'release', path)
|
||||||
else
|
else
|
||||||
val = tk_call('grab', args[0], path)
|
val = tk_call('grab', args[0], path)
|
||||||
end
|
end
|
||||||
|
@ -3329,7 +3329,7 @@ class TkListbox<TkTextWin
|
||||||
when 'text', 'label', 'show'
|
when 'text', 'label', 'show'
|
||||||
tk_send 'itemcget', index, "-#{key}"
|
tk_send 'itemcget', index, "-#{key}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_send 'itemcget', index, "-#{key}"
|
tk_tcl2ruby tk_send('itemcget', index, "-#{key}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def itemconfigure(index, key, val=None)
|
def itemconfigure(index, key, val=None)
|
||||||
|
@ -3468,7 +3468,7 @@ class TkMenu<TkWindow
|
||||||
when 'text', 'label', 'show'
|
when 'text', 'label', 'show'
|
||||||
tk_send 'entrycget', index, "-#{key}"
|
tk_send 'entrycget', index, "-#{key}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_send 'entrycget', index, "-#{key}"
|
tk_tcl2ruby tk_send('entrycget', index, "-#{key}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def entryconfigure(index, key, val=None)
|
def entryconfigure(index, key, val=None)
|
||||||
|
|
|
@ -94,10 +94,10 @@ class TkCanvas<TkWindow
|
||||||
end
|
end
|
||||||
|
|
||||||
def canvasx(x, *args)
|
def canvasx(x, *args)
|
||||||
tk_tcl2ruby(tk_send 'canvasx', x, *args)
|
tk_tcl2ruby(tk_send('canvasx', x, *args))
|
||||||
end
|
end
|
||||||
def canvasy(y, *args)
|
def canvasy(y, *args)
|
||||||
tk_tcl2ruby(tk_send 'canvasy', y, *args)
|
tk_tcl2ruby(tk_send('canvasy', y, *args))
|
||||||
end
|
end
|
||||||
|
|
||||||
def coords(tag, *args)
|
def coords(tag, *args)
|
||||||
|
@ -122,7 +122,7 @@ class TkCanvas<TkWindow
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(mode, *args)
|
def find(mode, *args)
|
||||||
list(tk_send 'find', mode, *args).collect!{|id|
|
list(tk_send('find', mode, *args)).collect!{|id|
|
||||||
TkcItem.id2obj(self, id)
|
TkcItem.id2obj(self, id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -191,7 +191,7 @@ class TkCanvas<TkWindow
|
||||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||||
tk_send 'itemcget', tagid(tagOrId), "-#{option}"
|
tk_send 'itemcget', tagid(tagOrId), "-#{option}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_send 'itemcget', tagid(tagOrId), "-#{option}"
|
tk_tcl2ruby tk_send('itemcget', tagid(tagOrId), "-#{option}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -231,8 +231,8 @@ class TkCanvas<TkWindow
|
||||||
if key
|
if key
|
||||||
case key.to_s
|
case key.to_s
|
||||||
when 'dash', 'activedash', 'disableddash'
|
when 'dash', 'activedash', 'disableddash'
|
||||||
conf = tk_split_simplelist(tk_send 'itemconfigure',
|
conf = tk_split_simplelist(tk_send('itemconfigure',
|
||||||
tagid(tagOrId), "-#{key}")
|
tagid(tagOrId), "-#{key}"))
|
||||||
if conf[3] && conf[3] =~ /^[0-9]/
|
if conf[3] && conf[3] =~ /^[0-9]/
|
||||||
conf[3] = list(conf[3])
|
conf[3] = list(conf[3])
|
||||||
end
|
end
|
||||||
|
@ -240,17 +240,17 @@ class TkCanvas<TkWindow
|
||||||
conf[4] = list(conf[4])
|
conf[4] = list(conf[4])
|
||||||
end
|
end
|
||||||
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
|
||||||
conf = tk_split_simplelist(tk_send 'itemconfigure',
|
conf = tk_split_simplelist(tk_send('itemconfigure',
|
||||||
tagid(tagOrId), "-#{key}")
|
tagid(tagOrId), "-#{key}"))
|
||||||
else
|
else
|
||||||
conf = tk_split_list(tk_send 'itemconfigure',
|
conf = tk_split_list(tk_send('itemconfigure',
|
||||||
tagid(tagOrId), "-#{key}")
|
tagid(tagOrId), "-#{key}"))
|
||||||
end
|
end
|
||||||
conf[0] = conf[0][1..-1]
|
conf[0] = conf[0][1..-1]
|
||||||
conf
|
conf
|
||||||
else
|
else
|
||||||
tk_split_simplelist(tk_send 'itemconfigure',
|
tk_split_simplelist(tk_send('itemconfigure',
|
||||||
tagid(tagOrId)).collect{|conflist|
|
tagid(tagOrId))).collect{|conflist|
|
||||||
conf = tk_split_simplelist(conflist)
|
conf = tk_split_simplelist(conflist)
|
||||||
conf[0] = conf[0][1..-1]
|
conf[0] = conf[0][1..-1]
|
||||||
case conf[0]
|
case conf[0]
|
||||||
|
@ -330,7 +330,7 @@ class TkCanvas<TkWindow
|
||||||
end
|
end
|
||||||
|
|
||||||
def itemtype(tag)
|
def itemtype(tag)
|
||||||
TkcItem.type2class(tk_send 'type', tagid(tag))
|
TkcItem.type2class(tk_send('type', tagid(tag)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ class TkPhotoImage<TkImage
|
||||||
when 'data', 'file'
|
when 'data', 'file'
|
||||||
tk_send 'cget', option
|
tk_send 'cget', option
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_send 'cget', option
|
tk_tcl2ruby tk_send('cget', option)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ class TkText<TkTextWin
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
tk_call @path, 'tag', 'cget', tag, "-#{key}"
|
tk_call @path, 'tag', 'cget', tag, "-#{key}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}"
|
tk_tcl2ruby tk_call(@path, 'tag', 'cget', tag, "-#{key}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ class TkTextTag<TkObject
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
|
tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
|
tk_tcl2ruby tk_call(@t.path, 'tag', 'cget', @id, "-#{key}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -854,7 +854,7 @@ class TkTextWindow<TkObject
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
|
tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
|
tk_tcl2ruby tk_call(@t.path, 'window', 'cget', @index, "-#{slot}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -904,17 +904,17 @@ class TkTextWindow<TkObject
|
||||||
if slot
|
if slot
|
||||||
case slot.to_s
|
case slot.to_s
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
conf = tk_split_simplelist(tk_call @t.path, 'window', 'configure',
|
conf = tk_split_simplelist(tk_call(@t.path, 'window', 'configure',
|
||||||
@index, "-#{slot}")
|
@index, "-#{slot}"))
|
||||||
else
|
else
|
||||||
conf = tk_split_list(tk_call @t.path, 'window', 'configure',
|
conf = tk_split_list(tk_call(@t.path, 'window', 'configure',
|
||||||
@index, "-#{slot}")
|
@index, "-#{slot}"))
|
||||||
end
|
end
|
||||||
conf[0] = conf[0][1..-1]
|
conf[0] = conf[0][1..-1]
|
||||||
conf
|
conf
|
||||||
else
|
else
|
||||||
tk_split_simplelist(tk_call @t.path, 'window', 'configure',
|
tk_split_simplelist(tk_call(@t.path, 'window', 'configure',
|
||||||
@index).collect{|conflist|
|
@index)).collect{|conflist|
|
||||||
conf = tk_split_simplelist(conflist)
|
conf = tk_split_simplelist(conflist)
|
||||||
conf[0] = conf[0][1..-1]
|
conf[0] = conf[0][1..-1]
|
||||||
case conf[0]
|
case conf[0]
|
||||||
|
@ -976,7 +976,7 @@ class TkTextImage<TkObject
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
|
tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
|
||||||
else
|
else
|
||||||
tk_tcl2ruby tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
|
tk_tcl2ruby tk_call(@t.path, 'image', 'cget', @index, "-#{slot}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1003,17 +1003,17 @@ class TkTextImage<TkObject
|
||||||
if slot
|
if slot
|
||||||
case slot.to_s
|
case slot.to_s
|
||||||
when 'text', 'label', 'show', 'data', 'file'
|
when 'text', 'label', 'show', 'data', 'file'
|
||||||
conf = tk_split_simplelist(tk_call @t.path, 'image', 'configure',
|
conf = tk_split_simplelist(tk_call(@t.path, 'image', 'configure',
|
||||||
@index, "-#{slot}")
|
@index, "-#{slot}"))
|
||||||
else
|
else
|
||||||
conf = tk_split_list(tk_call @t.path, 'image', 'configure',
|
conf = tk_split_list(tk_call(@t.path, 'image', 'configure',
|
||||||
@index, "-#{slot}")
|
@index, "-#{slot}"))
|
||||||
end
|
end
|
||||||
conf[0] = conf[0][1..-1]
|
conf[0] = conf[0][1..-1]
|
||||||
conf
|
conf
|
||||||
else
|
else
|
||||||
tk_split_simplelist(tk_call @t.path, 'image', 'configure',
|
tk_split_simplelist(tk_call(@t.path, 'image', 'configure',
|
||||||
@index).collect{|conflist|
|
@index)).collect{|conflist|
|
||||||
conf = tk_split_simplelist(conflist)
|
conf = tk_split_simplelist(conflist)
|
||||||
conf[0] = conf[0][1..-1]
|
conf[0] = conf[0][1..-1]
|
||||||
case conf[0]
|
case conf[0]
|
||||||
|
|
|
@ -452,7 +452,7 @@ def create_makefile(target, srcprefix = nil)
|
||||||
elsif RUBY_PLATFORM =~ /cygwin|mingw/
|
elsif RUBY_PLATFORM =~ /cygwin|mingw/
|
||||||
deffile = target + '.def'
|
deffile = target + '.def'
|
||||||
if not File.exist? deffile
|
if not File.exist? deffile
|
||||||
if File.exist? File.join srcdir, deffile
|
if File.exist? File.join(srcdir, deffile)
|
||||||
deffile = File.join srcdir, deffile
|
deffile = File.join srcdir, deffile
|
||||||
else
|
else
|
||||||
open(deffile, 'wb') do |f|
|
open(deffile, 'wb') do |f|
|
||||||
|
|
|
@ -214,7 +214,7 @@ class PP < PrettyPrint
|
||||||
text '='
|
text '='
|
||||||
group(1) {
|
group(1) {
|
||||||
breakable ''
|
breakable ''
|
||||||
pp(obj.instance_eval v)
|
pp(obj.instance_eval(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Tracer
|
||||||
|
|
||||||
def get_line(file, line)
|
def get_line(file, line)
|
||||||
if p = @get_line_procs[file]
|
if p = @get_line_procs[file]
|
||||||
return p.call line
|
return p.call(line)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless list = SCRIPT_LINES__[file]
|
unless list = SCRIPT_LINES__[file]
|
||||||
|
|
|
@ -184,7 +184,7 @@ module TSort
|
||||||
if component.size == 1
|
if component.size == 1
|
||||||
yield component.first
|
yield component.first
|
||||||
else
|
else
|
||||||
raise Cyclic.new "topological sort failed: #{component.inspect}"
|
raise Cyclic.new("topological sort failed: #{component.inspect}")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -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-defaults)
|
||||||
(make-local-variable 'font-lock-keywords)
|
(make-local-variable 'font-lock-keywords)
|
||||||
(make-local-variable 'font-lock-syntax-table)
|
(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-defaults '((ruby-font-lock-keywords) nil nil))
|
||||||
(setq font-lock-keywords ruby-font-lock-keywords)
|
(setq font-lock-keywords ruby-font-lock-keywords)
|
||||||
(setq font-lock-syntax-table ruby-font-lock-syntax-table)
|
(setq font-lock-syntax-table ruby-font-lock-syntax-table)
|
||||||
|
|
36
object.c
36
object.c
|
@ -18,6 +18,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
VALUE rb_mKernel;
|
VALUE rb_mKernel;
|
||||||
VALUE rb_cObject;
|
VALUE rb_cObject;
|
||||||
|
@ -134,6 +135,7 @@ static VALUE
|
||||||
rb_any_to_a(obj)
|
rb_any_to_a(obj)
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
{
|
{
|
||||||
|
rb_warn("default `to_a' will be obsolete");
|
||||||
return rb_ary_new3(1, obj);
|
return rb_ary_new3(1, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,6 +339,13 @@ nil_to_i(obj)
|
||||||
return INT2FIX(0);
|
return INT2FIX(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
nil_to_f(obj)
|
||||||
|
VALUE obj;
|
||||||
|
{
|
||||||
|
return rb_float_new(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
nil_to_s(obj)
|
nil_to_s(obj)
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
|
@ -917,6 +926,7 @@ rb_check_convert_type(val, type, tname, method)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_to_integer(val, method)
|
rb_to_integer(val, method)
|
||||||
VALUE val;
|
VALUE val;
|
||||||
|
@ -941,6 +951,8 @@ VALUE
|
||||||
rb_Integer(val)
|
rb_Integer(val)
|
||||||
VALUE val;
|
VALUE val;
|
||||||
{
|
{
|
||||||
|
VALUE v;
|
||||||
|
|
||||||
switch (TYPE(val)) {
|
switch (TYPE(val)) {
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
|
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
|
||||||
|
@ -961,7 +973,13 @@ rb_Integer(val)
|
||||||
default:
|
default:
|
||||||
break;
|
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
|
static VALUE
|
||||||
|
@ -1073,10 +1091,17 @@ rb_Float(val)
|
||||||
return rb_float_new(rb_str_to_dbl(val, Qtrue));
|
return rb_float_new(rb_str_to_dbl(val, Qtrue));
|
||||||
|
|
||||||
case T_NIL:
|
case T_NIL:
|
||||||
return rb_float_new(0.0);
|
rb_raise(rb_eTypeError, "cannot convert nil into Float");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
ID to_ary;
|
||||||
|
|
||||||
|
if (NIL_P(val)) {
|
||||||
|
rb_raise(rb_eTypeError, "cannot convert nil into Array");
|
||||||
|
}
|
||||||
if (TYPE(val) == T_ARRAY) return val;
|
if (TYPE(val) == T_ARRAY) return val;
|
||||||
to_ary = rb_intern("to_ary");
|
to_ary = rb_intern("to_ary");
|
||||||
if (rb_respond_to(val, 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, "freeze", rb_obj_freeze, 0);
|
||||||
rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 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, "to_s", rb_any_to_s, 0);
|
||||||
rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0);
|
rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0);
|
||||||
rb_define_method(rb_mKernel, "methods", rb_obj_methods, 0);
|
rb_define_method(rb_mKernel, "methods", rb_obj_methods, 0);
|
||||||
|
|
21
parse.y
21
parse.y
|
@ -233,7 +233,7 @@ static void top_local_setup();
|
||||||
%type <node> words qwords word_list qword_list word
|
%type <node> words qwords word_list qword_list word
|
||||||
%type <val> literal numeric
|
%type <val> literal numeric
|
||||||
%type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
|
%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> 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> 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
|
%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_command : block_call
|
||||||
| block_call_value '.' operation2 command_args
|
| block_call '.' operation2 command_args
|
||||||
{
|
{
|
||||||
$$ = new_call($1, $3, $4);
|
$$ = new_call($1, $3, $4);
|
||||||
}
|
}
|
||||||
| block_call_value tCOLON2 operation2 command_args
|
| block_call tCOLON2 operation2 command_args
|
||||||
{
|
{
|
||||||
$$ = new_call($1, $3, $4);
|
$$ = new_call($1, $3, $4);
|
||||||
}
|
}
|
||||||
|
@ -1075,6 +1075,7 @@ arg_value : arg
|
||||||
aref_args : none
|
aref_args : none
|
||||||
| command opt_nl
|
| command opt_nl
|
||||||
{
|
{
|
||||||
|
rb_warn("parenthesize argument(s) for future version");
|
||||||
$$ = NEW_LIST($1);
|
$$ = NEW_LIST($1);
|
||||||
}
|
}
|
||||||
| args trailer
|
| args trailer
|
||||||
|
@ -1107,10 +1108,12 @@ paren_args : '(' none ')'
|
||||||
}
|
}
|
||||||
| '(' block_call opt_nl ')'
|
| '(' block_call opt_nl ')'
|
||||||
{
|
{
|
||||||
|
rb_warn("parenthesize argument for future version");
|
||||||
$$ = NEW_LIST($2);
|
$$ = NEW_LIST($2);
|
||||||
}
|
}
|
||||||
| '(' args ',' block_call opt_nl ')'
|
| '(' args ',' block_call opt_nl ')'
|
||||||
{
|
{
|
||||||
|
rb_warn("parenthesize argument for future version");
|
||||||
$$ = list_append($2, $4);
|
$$ = list_append($2, $4);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -1121,6 +1124,7 @@ opt_paren_args : none
|
||||||
|
|
||||||
call_args : command
|
call_args : command
|
||||||
{
|
{
|
||||||
|
rb_warn("parenthesize argument(s) for future version");
|
||||||
$$ = NEW_LIST($1);
|
$$ = NEW_LIST($1);
|
||||||
}
|
}
|
||||||
| args opt_block_arg
|
| args opt_block_arg
|
||||||
|
@ -1623,23 +1627,16 @@ block_call : command do_block
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
}
|
}
|
||||||
| block_call_value '.' operation2 opt_paren_args
|
| block_call '.' operation2 opt_paren_args
|
||||||
{
|
{
|
||||||
$$ = new_call($1, $3, $4);
|
$$ = 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);
|
$$ = new_call($1, $3, $4);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
block_call_value : block_call
|
|
||||||
{
|
|
||||||
value_expr($$);
|
|
||||||
$$ = $1;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
method_call : operation paren_args
|
method_call : operation paren_args
|
||||||
{
|
{
|
||||||
$$ = new_fcall($1, $2);
|
$$ = new_fcall($1, $2);
|
||||||
|
|
10
re.c
10
re.c
|
@ -236,7 +236,14 @@ rb_reg_expr_str(str, s, len)
|
||||||
else {
|
else {
|
||||||
p = s;
|
p = s;
|
||||||
while (p<pend) {
|
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 = '\\';
|
char c = '\\';
|
||||||
rb_str_buf_cat(str, &c, 1);
|
rb_str_buf_cat(str, &c, 1);
|
||||||
rb_str_buf_cat(str, p, 1);
|
rb_str_buf_cat(str, p, 1);
|
||||||
|
@ -244,6 +251,7 @@ rb_reg_expr_str(str, s, len)
|
||||||
else if (ismbchar(*p)) {
|
else if (ismbchar(*p)) {
|
||||||
rb_str_buf_cat(str, p, mbclen(*p));
|
rb_str_buf_cat(str, p, mbclen(*p));
|
||||||
p += mbclen(*p);
|
p += mbclen(*p);
|
||||||
|
need_escape = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (ISPRINT(*p)) {
|
else if (ISPRINT(*p)) {
|
||||||
|
|
|
@ -11,4 +11,4 @@ for i in 2 .. Math.sqrt(max)
|
||||||
sieve[j] = nil
|
sieve[j] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts sieve.compact.join ", "
|
puts sieve.compact.join(", ")
|
||||||
|
|
|
@ -1212,8 +1212,7 @@ end
|
||||||
def valid_syntax?(code, fname)
|
def valid_syntax?(code, fname)
|
||||||
eval("BEGIN {return true}\n#{code}", nil, fname, 0)
|
eval("BEGIN {return true}\n#{code}", nil, fname, 0)
|
||||||
rescue Exception
|
rescue Exception
|
||||||
p $!
|
puts $!.message
|
||||||
ensure
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue