diff options
-rw-r--r-- | ChangeLog | 34 | ||||
-rw-r--r-- | ToDo | 2 | ||||
-rw-r--r-- | configure.in | 10 | ||||
-rw-r--r-- | dir.c | 5 | ||||
-rw-r--r-- | ext/extmk.rb.in | 4 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 205 | ||||
-rw-r--r-- | ext/tk/lib/tkcanvas.rb | 107 | ||||
-rw-r--r-- | ext/tk/lib/tkentry.rb | 8 | ||||
-rw-r--r-- | ext/tk/lib/tkfont.rb | 14 | ||||
-rw-r--r-- | file.c | 7 | ||||
-rw-r--r-- | io.c | 26 | ||||
-rw-r--r-- | lib/jcode.rb | 16 | ||||
-rw-r--r-- | lib/mkmf.rb | 4 | ||||
-rw-r--r-- | misc/ruby-mode.el | 4 | ||||
-rw-r--r-- | numeric.c | 38 | ||||
-rw-r--r-- | re.c | 2 | ||||
-rw-r--r-- | rubytest.rb | 7 | ||||
-rw-r--r-- | time.c | 89 | ||||
-rw-r--r-- | version.h | 4 |
19 files changed, 494 insertions, 92 deletions
@@ -1,9 +1,39 @@ +Sat Jun 10 23:10:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp> + + * io.c (rb_io_seek): whence is optional, default is SEEK_SET. + +Fri Jun 9 15:11:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp> + + * time.c (make_time_t): supports daylight saving time. + + * eval.c (rb_thread_safe_level): should retrive current $SAFE + value if a thread is the current thread. + +Thu Jun 8 14:25:45 2000 Hiroshi Igarashi <iga@ruby-lang.org> + + * lib/mkmf.rb: add target `distclean' in Makefile for extlib. + target `clean' doesn't remove Makefile. + +Thu Jun 8 13:34:03 2000 Dave Thomas <dave@thomases.com> + + * numeric.c: add nan?, infinite?, and finite? to Float + Thu Jun 8 00:31:04 2000 WATANABE Hirofumi <eban@os.rim.or.jp> * regex.h: export re_mbctab properly on cygwin. * dln.c: use dlopen instead of LoadLibrary on cygwin. +Thu Jun 8 13:41:34 2000 Tadayoshi Funaba <tadf@kt.rim.or.jp> + + * file.c (rb_file_s_basename): might dump core. + +Tue Jun 6 03:29:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp> + + * dir.c (dir_foreach): now returns nil for consistency. + + * bignum.c (bigdivmod): modulo by small numbers was wrong. + Mon Jun 5 00:18:08 2000 WATANABE Hirofumi <eban@os.rim.or.jp> * bignum.c: avoid conflict with USHORT on mingw32. @@ -589,10 +619,6 @@ Sat Apr 1 00:16:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp> * object.c (sym_inspect): inspect gives ":sym", to_s gives "sym". -Fri Mar 31 08:56:55 2000 Yukihiro Matsumoto <matz@netlab.co.jp> - - * parse.y (yylex): - Thu Mar 30 12:19:44 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp> * enum.c (enum_find): rb_eval_cmd() should be called with array. @@ -25,6 +25,8 @@ Language Spec. * discourage use of Perlish features by giving warnings. * `exception' method to be alternative for `$!'. ?? * non confusing in-block local variable (is it possible?) + + remove scope by block + + variables appears within block may have independent values. Hacking Interpreter diff --git a/configure.in b/configure.in index 71aaa29ed4..242ce7f172 100644 --- a/configure.in +++ b/configure.in @@ -209,9 +209,13 @@ AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\ getpgrp setpgrp getpgid setpgid getgroups getpriority\ dlopen sigprocmask sigaction _setjmp setsid getrlimit) AC_STRUCT_TIMEZONE -if test "$ac_cv_func_strftime" = no; then - AC_TRY_LINK([], - [extern int daylight; int i = daylight;], AC_DEFINE(HAVE_DAYLIGHT)) +AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight, + [AC_TRY_LINK([], + [extern int daylight; int i = daylight;], + rb_cv_have_daylight=yes, + rb_cv_have_daylight=no)]) +if test "$rb_cv_have_daylight" = yes; then + AC_DEFINE(HAVE_DAYLIGHT) fi if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then @@ -783,7 +783,8 @@ dir_foreach(io, dirname) VALUE dir; dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname); - return rb_ensure(dir_each, dir, dir_close, dir); + rb_ensure(dir_each, dir, dir_close, dir); + return Qnil; } static VALUE @@ -814,6 +815,8 @@ Init_Dir() rb_define_method(rb_cDir,"rewind", dir_rewind, 0); rb_define_method(rb_cDir,"tell", dir_tell, 0); rb_define_method(rb_cDir,"seek", dir_seek, 1); + rb_define_method(rb_cDir,"pos", dir_tell, 0); + rb_define_method(rb_cDir,"pos=", dir_seek, 1); rb_define_method(rb_cDir,"close", dir_close, 0); rb_define_singleton_method(rb_cDir,"chdir", dir_s_chdir, -1); diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 44232da7a1..c97f86a687 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -425,10 +425,12 @@ all: $(DLLIB) clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) @$(RM) *.ilk *.exp *.pdb *.bak + +distclean: clean @$(RM) Makefile extconf.h conftest.* @$(RM) core ruby$(EXEEXT) *~ -realclean: clean +realclean: distclean EOS mfile.printf <<EOS diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index bb3f7f6ab8..a18a0e4587 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -457,6 +457,21 @@ module TkCore _get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) end + def scaling(scale=nil) + if scale + tk_call('tk', 'scaling', scale) + else + Float(number(tk_call('tk', 'scaling'))) + end + end + def scaling_displayof(win, scale=nil) + if scale + tk_call('tk', 'scaling', '-displayof', win, scale) + else + Float(number(tk_call('tk', '-displayof', win, 'scaling'))) + end + end + def appname(name=None) tk_call('tk', 'appname', name) end @@ -772,6 +787,24 @@ class TkBindTag end end +class TkBindTagAll<TkBindTag + BindTagALL = [] + def TkBindTagAll.new(*args) + if BindTagALL[0] + BindTagALL[0].bind(*args) if args != [] + else + new = super() + BindTagALL[0] = new + end + BindTagALL[0] + end + + def initialize(*args) + @id = 'all' + BindTagALL[0].bind(*args) if args != [] + end +end + class TkVariable include Tk extend TkCore @@ -1151,6 +1184,31 @@ module TkKinput end end +module TkXIM + include Tk + extend Tk + + def TkXIM.useinputmethods(window=nil,value=nil) + if window + if value + tk_call 'tk', 'useinputmethods', '-displayof', window.path, value + else + tk_call 'tk', 'useinputmethods', '-displayof', window.path + end + else + if value + tk_call 'tk', 'useinputmethods', value + else + tk_call 'tk', 'useinputmethods' + end + end + end + + def useinputmethods(value=nil) + TkXIM.useinputmethods(self,value) + end +end + module TkWinfo include Tk extend Tk @@ -1807,7 +1865,7 @@ class TkWindow<TkObject self end - def unpack(keys = nil) + def unpack tk_call 'pack', 'forget', epath self end @@ -1817,7 +1875,7 @@ class TkWindow<TkObject self end - def ungrid(keys = nil) + def ungrid tk_call 'grid', 'forget', epath self end @@ -1827,8 +1885,8 @@ class TkWindow<TkObject self end - def unplace(keys = nil) - tk_call 'place', 'forget', epath, *hash_kv(keys) + def unplace + tk_call 'place', 'forget', epath self end alias place_forget unplace @@ -1894,11 +1952,11 @@ class TkWindow<TkObject end def lower(below=None) - tk_call 'lower', path, below + tk_call 'lower', epath, below self end def raise(above=None) - tk_call 'raise', path, above + tk_call 'raise', epath, above self end @@ -1912,7 +1970,7 @@ class TkWindow<TkObject end def destroy - tk_call 'destroy', path + tk_call 'destroy', epath if @cmdtbl for id in @cmdtbl uninstall_cmd id @@ -1927,7 +1985,7 @@ class TkWindow<TkObject alias wait wait_visibility def wait_destroy - tk_call 'tkwait', 'window', path + tk_call 'tkwait', 'window', epath end def bindtags(taglist=nil) @@ -2259,6 +2317,41 @@ class TkListbox<TkTextWin def selection_set(first, last=None) tk_send 'selection', 'set', first, last end + + def itemcget(index, key) + tk_tcl2ruby tk_send 'itemcget', index, "-#{key}" + end + def itemconfigure(index, key, val=None) + if key.kind_of? Hash + if (key['font'] || key['kanjifont'] || + key['latinfont'] || key['asciifont']) + tagfont_configure(index, key.dup) + else + tk_send 'itemconfigure', index, *hash_kv(key) + end + + else + if (key == 'font' || key == 'kanjifont' || + key == 'latinfont' || key == 'asciifont' ) + tagfont_configure({key=>val}) + else + tk_call 'itemconfigure', index, "-#{key}", val + end + end + end + + def itemconfiginfo(index, key=nil) + if key + conf = tk_split_list(tk_send('itemconfigure',index,"-#{key}")) + conf[0] = conf[0][1..-1] + conf + else + tk_split_list(tk_send('itemconfigure', index)).collect{|conf| + conf[0] = conf[0][1..-1] + conf + } + end + end end module TkTreatMenuEntryFont @@ -2397,6 +2490,9 @@ class TkMenu<TkWindow def delete(index, last=None) tk_send 'delete', index, last end + def popup(x, y, index=nil) + tk_call 'tk_popup', path, x, y, index + end def post(x, y) tk_send 'post', x, y end @@ -2451,6 +2547,34 @@ class TkMenu<TkWindow end end +module TkSystemMenu + def initialize(parent, keys=nil) + fail unless parent.kind_of? TkMenu + @path = format("%s.%s", parent.path, self.type::SYSMENU_NAME) + TkComm::Tk_WINDOWS[@path] = self + create_self + configure(keys) if keys + end +end + +class TkSysMenu_Help<TkMenu + # for all platform + include TkSystemMenu + SYSMENU_NAME = 'help' +end + +class TkSysMenu_System<TkMenu + # for Windows + include TkSystemMenu + SYSMENU_NAME = 'system' +end + +class TkSysMenu_Apple<TkMenu + # for Machintosh + include TkSystemMenu + SYSMENU_NAME = 'apple' +end + class TkMenubutton<TkLabel WidgetClassNames['Menubutton'] = self def TkMenubutton.to_eval @@ -2461,6 +2585,71 @@ class TkMenubutton<TkLabel end end +class TkOptionMenubutton<TkMenubutton + class OptionMenu<TkMenu + def initialize(parent) + @path = parent.path + '.menu' + TkComm::Tk_WINDOWS[@path] = self + end + end + + def initialize(parent=nil, var=TkVariable.new, firstval=nil, *vals) + fail unless var.kind_of? TkVariable + @variable = var + firstval = @variable.value unless firstval + @variable.value = firstval + install_win(if parent then parent.path end) + @menu = OptionMenu.new(self) + tk_call 'tk_optionMenu', @path, @variable.id, firstval, *vals + end + + def value + @variable.value + end + + def activate(index) + @menu.activate(index) + end + def add(value) + @menu.add('radiobutton', 'variable'=>@variable, + 'label'=>value, 'value'=>value) + end + def index(index) + @menu.index(index) + end + def invoke(index) + @menu.invoke(index) + end + def insert(index, value) + @menu.add(index, 'radiobutton', 'variable'=>@variable, + 'label'=>value, 'value'=>value) + end + def delete(index, last=None) + @menu.delete(index, last) + end + def yposition(index) + @menu.yposition(index) + end + def menucget(index, key) + @menu.cget(index, key) + end + def menuconfigure(index, key, val=None) + @menu.configure(index, key, val) + end + def menuconfiginfo(index, key=nil) + @menu.configinfo(index, key) + end + def entrycget(index, key) + @menu.entrycget(index, key) + end + def entryconfigure(index, key, val=None) + @menu.entryconfigure(index, key, val) + end + def entryconfiginfo(index, key=nil) + @menu.entryconfiginfo(index, key) + end +end + module TkComposite include Tk extend Tk diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb index 914bfe01e3..5f4bdadaee 100644 --- a/ext/tk/lib/tkcanvas.rb +++ b/ext/tk/lib/tkcanvas.rb @@ -217,7 +217,7 @@ class TkCanvas<TkWindow def find(mode, *args) list(tk_send 'find', mode, *args).collect!{|id| - TkcItem.id2obj(id) + TkcItem.id2obj(self, id) } end def find_above(target) @@ -250,14 +250,14 @@ class TkCanvas<TkWindow if ret == "" nil else - TkcItem.id2obj(ret) + TkcItem.id2obj(self, ret) end end end def gettags(tagOrId) list(tk_send('gettags', tagid(tagOrId))).collect{|tag| - TkcTag.id2obj(tag) + TkcTag.id2obj(self, tag) } end @@ -471,6 +471,41 @@ module TkcTagAccess def itemtype @c.itemtype @id end + + # Followings operators supports logical expressions of canvas tags + # (for Tk8.3+). + # If tag1.path is 't1' and tag2.path is 't2', then + # ltag = tag1 & tag2; ltag.path => "(t1)&&(t2)" + # ltag = tag1 | tag2; ltag.path => "(t1)||(t2)" + # ltag = tag1 ^ tag2; ltag.path => "(t1)^(t2)" + # ltag = - tag1; ltag.path => "!(t1)" + def & (tag) + if tag.kind_of? TkObject + TkcTagString.new(@c, '(' + @id + ')&&(' + tag.path + ')') + else + TkcTagString.new(@c, '(' + @id + ')&&(' + tag.to_s + ')') + end + end + + def | (tag) + if tag.kind_of? TkObject + TkcTagString.new(@c, '(' + @id + ')||(' + tag.path + ')') + else + TkcTagString.new(@c, '(' + @id + ')||(' + tag.to_s + ')') + end + end + + def ^ (tag) + if tag.kind_of? TkObject + TkcTagString.new(@c, '(' + @id + ')^(' + tag.path + ')') + else + TkcTagString.new(@c, '(' + @id + ')^(' + tag.to_s + ')') + end + end + + def -@ + TkcTagString.new(@c, '!(' + @id + ')') + end end class TkcTag<TkObject @@ -478,8 +513,10 @@ class TkcTag<TkObject CTagID_TBL = {} - def TkcTag.id2obj(id) - CTagID_TBL[id]? CTagID_TBL[id]: id + def TkcTag.id2obj(canvas, id) + cpath = canvas.path + return id unless CTagID_TBL[cpath] + CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id end Tk_CanvasTag_ID = ['ctag0000'] @@ -488,8 +525,10 @@ class TkcTag<TkObject fail format("%s need to be TkCanvas", parent.inspect) end @c = parent + @cpath = parent.path @path = @id = Tk_CanvasTag_ID[0] - CTagID_TBL[@id] = self + CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] + CTagID_TBL[@cpath][@id] = self Tk_CanvasTag_ID[0] = Tk_CanvasTag_ID[0].succ if mode tk_call @c.path, "addtag", @id, mode, *args @@ -501,7 +540,7 @@ class TkcTag<TkObject def delete @c.delete @id - CTagID_TBL[@id] = nil + CTagID_TBL[@path][@id] = nil if CTagID_TBL[@path] end alias remove delete alias destroy delete @@ -527,7 +566,7 @@ class TkcTag<TkObject alias closest set_to_closest def set_to_enclosed(x1, y1, x2, y2) - @c.addtag_enclosest(@id, x1, y1, x2, y2) + @c.addtag_enclosed(@id, x1, y1, x2, y2) end alias enclosed set_to_enclosed @@ -542,14 +581,40 @@ class TkcTag<TkObject alias withtag set_to_withtag end +class TkcTagString<TkcTag + def self.new(parent, name, *args) + if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name] + return CTagID_TBL[parent.path][name] + else + super(parent, name, *args) + end + end + + def initialize(parent, name, mode=nil, *args) + if not parent.kind_of?(TkCanvas) + fail format("%s need to be TkCanvas", parent.inspect) + end + @c = parent + @cpath = parent.path + @path = @id = name + CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] + CTagID_TBL[@cpath][@id] = self + if mode + tk_call @c.path, "addtag", @id, mode, *args + end + end +end + class TkcTagAll<TkcTag def initialize(parent) if not parent.kind_of?(TkCanvas) fail format("%s need to be TkCanvas", parent.inspect) end @c = parent + @cpath = parent.path @path = @id = 'all' - CTagID_TBL[@id] = self + CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] + CTagID_TBL[@cpath][@id] = self end end @@ -559,8 +624,10 @@ class TkcTagCurrent<TkcTag fail format("%s need to be TkCanvas", parent.inspect) end @c = parent + @cpath = parent.path @path = @id = 'current' - CTagID_TBL[@id] = self + CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] + CTagID_TBL[@cpath][@id] = self end end @@ -571,8 +638,10 @@ class TkcGroup<TkcTag fail format("%s need to be TkCanvas", parent.inspect) end @c = parent + @cpath = parent.path @path = @id = Tk_cGroup_ID[0] - CTagID_TBL[@id] = self + CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] + CTagID_TBL[@cpath][@id] = self Tk_cGroup_ID[0] = Tk_cGroup_ID[0].succ add(*args) if args != [] end @@ -590,7 +659,6 @@ class TkcGroup<TkcTag end end - class TkcItem<TkObject include TkcTagAccess @@ -601,8 +669,10 @@ class TkcItem<TkObject CItemTypeToClass[type] end - def TkcItem.id2obj(id) - CItemID_TBL[id]? CItemID_TBL[id]: id + def TkcItem.id2obj(canvas, id) + cpath = canvas.path + return id unless CItemID_TBL[cpath] + CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id end def initialize(parent, *args) @@ -615,7 +685,8 @@ class TkcItem<TkObject keys = args.pop end @id = create_self(*args).to_i ;# 'canvas item id' is integer number - CItemID_TBL[@id] = self + CItemID_TBL[@path] = {} unless CItemID_TBL[@path] + CItemID_TBL[@path][@id] = self if keys # tk_call @path, 'itemconfigure', @id, *hash_kv(keys) configure(keys) if keys @@ -629,7 +700,7 @@ class TkcItem<TkObject def delete @c.delete @id - CItemID_TBL[@id] = nil + CItemID_TBL[@path][@id] = nil if CItemID_TBL[@path] end alias remove delete alias destroy delete @@ -761,6 +832,10 @@ class TkPhotoImage<TkImage tk_send 'copy', source, *args end + def data(keys=nil) + tk_send 'data', *hash_kv(keys) + end + def get(x, y) tk_send 'get', x, y end diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb index f35d2eef00..5207d9b895 100644 --- a/ext/tk/lib/tkentry.rb +++ b/ext/tk/lib/tkentry.rb @@ -59,6 +59,14 @@ class TkEntry<TkLabel tk_send 'selection', 'to', index end + def validate + if tk_send('validate') == '0' + false + else + true + end + end + def value tk_send 'get' end diff --git a/ext/tk/lib/tkfont.rb b/ext/tk/lib/tkfont.rb index 2683260d69..363839d3d3 100644 --- a/ext/tk/lib/tkfont.rb +++ b/ext/tk/lib/tkfont.rb @@ -49,7 +49,7 @@ class TkFont def TkFont.create_copy(font) keys = {} - font.configure.each{|key,value| keys[key] = value } + font.configinfo.each{|key,value| keys[key] = value } new_font = TkFont.new(font.latin_font, font.kanji_font, keys) end @@ -123,17 +123,13 @@ class TkFont ################################### private ################################### - def initialize(ltn=nil, knj=nil, keys=nil) + def initialize(ltn=DEFAULT_LATIN_FONT_NAME, knj=DEFAULT_KANJI_FONT_NAME, + keys=nil) @id = format("@font%.4d", Tk_FontID[0]) Tk_FontID[0] += 1 Tk_FontNameTBL[@id] = self - - ltn = DEFAULT_LATIN_FONT_NAME unless ltn create_latinfont(ltn) - - knj = DEFAULT_KANJI_FONT_NAME unless knj create_kanjifont(knj) - create_compoundfont(keys) end @@ -714,7 +710,7 @@ class TkFont if winobj.kind_of? TkText ret.push([winobj, winobj.tagid2obj(tag)]) elsif winobj.kind_of? TkCanvas - if (tagobj = TkcTag.id2obj(tag)).kind_of? TkcTag + if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag ret.push([winobj, tagobj]) elsif (tagobj = TkcItem.id2obj(tag)).kind_of? TkcItem ret.push([winobj, tagobj]) @@ -822,7 +818,7 @@ class TkFont if JAPANIZED_TK configinfo_core(@latinfont, slot) else - configure(slot, value) + configinfo(slot) end end @@ -1330,9 +1330,9 @@ rb_file_s_basename(argc, argv) name = STR2CSTR(fname); p = strrchr(name, '/'); if (!p) { - if (NIL_P(fext) || !(f = rmext(p, ext))) + if (NIL_P(fext) || !(f = rmext(name, ext))) return fname; - basename = rb_str_new(p, f); + basename = rb_str_new(name, f); } else { p++; /* skip last `/' */ @@ -1696,7 +1696,6 @@ rb_stat_l(obj) { #ifdef S_ISLNK if (S_ISLNK(get_stat(obj)->st_mode)) return Qtrue; - #endif return Qfalse; } @@ -1931,7 +1930,7 @@ rb_stat_sticky(obj) #ifdef S_ISVTX if (get_stat(obj)->st_mode & S_ISVTX) return Qtrue; #endif - return Qnil; + return Qfalse; } static VALUE rb_mConst; @@ -281,27 +281,35 @@ rb_io_tell(io) return rb_int2inum(pos); } +#ifndef SEEK_CUR +# define SEEK_SET 0 +# define SEEK_CUR 1 +# define SEEK_END 2 +#endif + static VALUE -rb_io_seek(io, offset, ptrname) - VALUE io, offset, ptrname; +rb_io_seek(argc, argv, io) + int argc; + VALUE *argv; + VALUE io; { + VALUE offset, ptrname; + int whence; OpenFile *fptr; long pos; + rb_scan_args(argc, argv, "11", &offset, &ptrname); + if (argc == 1) whence = SEEK_SET; + else whence = NUM2INT(ptrname); + GetOpenFile(io, fptr); - pos = fseek(fptr->f, NUM2INT(offset), NUM2INT(ptrname)); + pos = fseek(fptr->f, NUM2INT(offset), whence); if (pos != 0) rb_sys_fail(fptr->path); clearerr(fptr->f); return INT2FIX(0); } -#ifndef SEEK_CUR -# define SEEK_SET 0 -# define SEEK_CUR 1 -# define SEEK_END 2 -#endif - static VALUE rb_io_set_pos(io, offset) VALUE io, offset; diff --git a/lib/jcode.rb b/lib/jcode.rb index a7606d04ce..49262857a8 100644 --- a/lib/jcode.rb +++ b/lib/jcode.rb @@ -108,10 +108,6 @@ class String h end - def bsquote(str) - str.gsub(/\\/, '\\\\\\\\') - end - HashCache = {} TrPatternCache = {} DeletePatternCache = {} @@ -122,7 +118,7 @@ class String def tr!(from, to) return self.delete!(from) if to.length == 0 - pattern = TrPatternCache[from] ||= /[#{bsquote(from)}]/ + pattern = TrPatternCache[from] ||= /[#{Regexp::quote(from)}]/ if from[0] == ?^ last = /.$/.match(to)[0] self.gsub!(pattern, last) @@ -137,7 +133,7 @@ class String end def delete!(del) - self.gsub!(DeletePatternCache[del] ||= /[#{bsquote(del)}]+/, '') + self.gsub!(DeletePatternCache[del] ||= /[#{Regexp::quote(del)}]+/, '') end def delete(del) @@ -147,7 +143,7 @@ class String def squeeze!(del=nil) pattern = if del - SqueezePatternCache[del] ||= /([#{bsquote(del)}])\1+/ + SqueezePatternCache[del] ||= /([#{Regexp::quote(del)}])\1+/ else /(.|\n)\1+/ end @@ -161,7 +157,7 @@ class String def tr_s!(from, to) return self.delete!(from) if to.length == 0 - pattern = SqueezePatternCache[from] ||= /([#{bsquote(from)}])\1+"/ #" + pattern = SqueezePatternCache[from] ||= /([#{Regexp::quote(from)}])\1+"/ #" if from[0] == ?^ last = /.$/.match(to)[0] self.gsub!(pattern, last) @@ -194,11 +190,11 @@ class String def each_char if iterator? - scan(/./) do |x| + scan(/./m) do |x| yield x end else - scan(/./) + scan(/./m) end end diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 5dc843f47b..b885690ec5 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -406,10 +406,12 @@ all: $(DLLIB) clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB) @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).ilk *.pdb + +distclean: clean @$(RM) Makefile extconf.h conftest.* @$(RM) core ruby$(EXEEXT) *~ -realclean: clean +realclean: distclean install: $(archdir)/$(DLLIB) diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index a0a770b473..763c076d8a 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -14,11 +14,11 @@ (substring ruby-mode-revision (match-beginning 0) (match-end 0)))) (defconst ruby-block-beg-re - "class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin" + "class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin\\|do" ) (defconst ruby-non-block-do-re - "while\\|until\\|for\\|rescue" + "\\(while\\|until\\|for\\|rescue\\)\\>" ) (defconst ruby-indent-beg-re @@ -679,6 +679,40 @@ flo_zero_p(num) return Qfalse; } +static VALUE flo_is_nan_p(num) + VALUE num; +{ + + double value = RFLOAT(num)->value; + + return isnan(value) ? Qtrue : Qfalse; +} + +static VALUE flo_is_infinite_p(num) + VALUE num; +{ + double value = RFLOAT(num)->value; + + if (isinf(value)) { + return INT2FIX( value < 0 ? -1 : +1 ); + } + + return Qnil; +} + + +static VALUE flo_is_finite_p(num) + VALUE num; +{ + double value = RFLOAT(num)->value; + + if (isinf(value) || isnan(value)) + return Qfalse; + + return Qtrue; +} + + static VALUE to_integer(val) VALUE val; @@ -1570,4 +1604,8 @@ Init_Numeric() rb_define_method(rb_cFloat, "floor", flo_floor, 0); rb_define_method(rb_cFloat, "ceil", flo_ceil, 0); rb_define_method(rb_cFloat, "round", flo_round, 0); + + rb_define_method(rb_cFloat, "nan?", flo_is_nan_p, 0); + rb_define_method(rb_cFloat, "infinite?", flo_is_infinite_p, 0); + rb_define_method(rb_cFloat, "finite?", flo_is_finite_p, 0); } @@ -613,7 +613,7 @@ rb_reg_search(re, str, pos, reverse) if (result == -2) { rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len, - "Stack overfow in regexp matcher", re); + "Stack overflow in regexp matcher", re); } if (result < 0) { diff --git a/rubytest.rb b/rubytest.rb index 20032e303e..a2380e6f4c 100644 --- a/rubytest.rb +++ b/rubytest.rb @@ -3,6 +3,12 @@ require 'rbconfig' include Config +unless File.exist? "./#{CONFIG['ruby_install_name']}" + print "./#{CONFIG['ruby_install_name']} is not found.\n" + print "Try `make' first, then `make test', please.\n" + exit 0 +end + if File.exist? CONFIG['LIBRUBY_SO'] case RUBY_PLATFORM when /-hpux/ @@ -25,6 +31,7 @@ end $stderr.reopen($stdout) error = '' + `./#{CONFIG["ruby_install_name"]} #{CONFIG["srcdir"]}/sample/test.rb`.each do |line| if line =~ /^end of test/ print "test succeeded\n" @@ -208,6 +208,7 @@ time_arg(argc, argv, tm) VALUE v[6]; int i; + MEMZERO(tm, struct tm, 1); if (argc == 10) { v[0] = argv[5]; v[1] = argv[4]; @@ -215,6 +216,7 @@ time_arg(argc, argv, tm) v[3] = argv[2]; v[4] = argv[1]; v[5] = argv[0]; + tm->tm_isdst = RTEST(argv[9]) ? 1 : 0; } else { rb_scan_args(argc, argv, "15", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5]); @@ -271,9 +273,9 @@ static VALUE time_localtime _((VALUE)); static VALUE time_get_tm _((VALUE, int)); static time_t -make_time_t(tptr, fn) +make_time_t(tptr, utc_or_local) struct tm *tptr; - struct tm *(*fn)(); + int utc_or_local; { struct timeval tv; time_t oguess, guess; @@ -285,30 +287,73 @@ make_time_t(tptr, fn) } guess = tv.tv_sec; - tm = (*fn)(&guess); + tm = gmtime(&guess); if (!tm) goto error; t = tptr->tm_year; if (t < 69) goto out_of_range; while (diff = t - tm->tm_year) { oguess = guess; - guess += diff * 364 * 24 * 3600; + guess += diff * 363 * 24 * 3600; if (diff > 0 && guess <= oguess) goto out_of_range; - tm = (*fn)(&guess); + tm = gmtime(&guess); if (!tm) goto error; } t = tptr->tm_mon; while (diff = t - tm->tm_mon) { guess += diff * 27 * 24 * 3600; - tm = (*fn)(&guess); + tm = gmtime(&guess); if (!tm) goto error; if (tptr->tm_year != tm->tm_year) goto out_of_range; } - guess += (tptr->tm_mday - tm->tm_mday) * 3600 * 24; + guess += (tptr->tm_mday - tm->tm_mday) * 24 * 3600; guess += (tptr->tm_hour - tm->tm_hour) * 3600; guess += (tptr->tm_min - tm->tm_min) * 60; guess += (tptr->tm_sec - tm->tm_sec); if (guess < 0) goto out_of_range; + if (!utc_or_local) { /* localtime zone adjust */ +#if defined(HAVE_DAYLIGHT) + extern int daylight; + extern long timezone; + + localtime(&guess); + guess += timezone + daylight; +#else + struct tm gt, lt; + long tzsec; + + t = 0; + gt = *gmtime(&guess); + lt = *localtime(&guess); + tzsec = (gt.tm_min-lt.tm_min)*60 + (gt.tm_hour-lt.tm_hour)*3600; + + if(lt.tm_year > gt.tm_year) { + tzsec -= 24*3600; + } + else if(gt.tm_year > lt.tm_year) { + tzsec += 24*3600; + } + else { + tzsec += (gt.tm_yday - lt.tm_yday)*24*3600; + } + + if (lt.tm_isdst) tzsec += 3600; + + guess += tzsec; + if (guess < 0) { + goto out_of_range; + } + tm = localtime(&guess); + if (!tm) goto error; + if (tm->tm_hour != tptr->tm_hour) { + guess -= 3600; + } +#endif + if (guess < 0) { + goto out_of_range; + } + } + return guess; out_of_range: @@ -320,40 +365,37 @@ make_time_t(tptr, fn) } static VALUE -time_gm_or_local(argc, argv, gm_or_local, klass) +time_utc_or_local(argc, argv, utc_or_local, klass) int argc; VALUE *argv; - int gm_or_local; + int utc_or_local; VALUE klass; { struct tm tm; - struct tm *(*fn)(); VALUE time; - fn = (gm_or_local) ? gmtime : localtime; time_arg(argc, argv, &tm); - - time = time_new_internal(klass, make_time_t(&tm, fn), 0); - if (gm_or_local) return time_gmtime(time); + time = time_new_internal(klass, make_time_t(&tm, utc_or_local), 0); + if (utc_or_local) return time_gmtime(time); return time_localtime(time); } static VALUE -time_s_timegm(argc, argv, klass) +time_s_mkutc(argc, argv, klass) int argc; VALUE *argv; VALUE klass; { - return time_gm_or_local(argc, argv, 1, klass); + return time_utc_or_local(argc, argv, Qtrue, klass); } static VALUE -time_s_timelocal(argc, argv, klass) +time_s_mktime(argc, argv, klass) int argc; VALUE *argv; VALUE klass; { - return time_gm_or_local(argc, argv, 0, klass); + return time_utc_or_local(argc, argv, Qfalse, klass); } static VALUE @@ -765,8 +807,12 @@ time_zone(time) time_get_tm(time, tobj->gmt); } +#ifdef HAVE_TZNAME + return rb_str_new2(tobj->tm.tm_zone); +#else len = strftime(buf, 64, "%Z", &tobj->tm); return rb_str_new(buf, len); +#endif } static VALUE @@ -990,9 +1036,10 @@ Init_Time() rb_define_singleton_method(rb_cTime, "now", time_s_now, 0); rb_define_singleton_method(rb_cTime, "new", time_s_new, -1); rb_define_singleton_method(rb_cTime, "at", time_s_at, -1); - rb_define_singleton_method(rb_cTime, "gm", time_s_timegm, -1); - rb_define_singleton_method(rb_cTime, "local", time_s_timelocal, -1); - rb_define_singleton_method(rb_cTime, "mktime", time_s_timelocal, -1); + rb_define_singleton_method(rb_cTime, "utc", time_s_mkutc, -1); + rb_define_singleton_method(rb_cTime, "gm", time_s_mkutc, -1); + rb_define_singleton_method(rb_cTime, "local", time_s_mktime, -1); + rb_define_singleton_method(rb_cTime, "mktime", time_s_mktime, -1); rb_define_singleton_method(rb_cTime, "times", time_s_times, 0); @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.4" -#define RUBY_RELEASE_DATE "2000-06-05" +#define RUBY_RELEASE_DATE "2000-06-12" #define RUBY_VERSION_CODE 154 -#define RUBY_RELEASE_CODE 20000605 +#define RUBY_RELEASE_CODE 20000612 |