ruby-changes:55477
From: usa <ko1@a...>
Date: Tue, 23 Apr 2019 11:14:48 +0900 (JST)
Subject: [ruby-changes:55477] usa:23ccbdf521 (ruby_1_9_3): merge revision(s) 48402:
usa 2014-11-13 22:39:32 +0900 (Thu, 13 Nov 2014) New Revision: 23ccbdf521 https://git.ruby-lang.org/ruby.git/commit/?id=23ccbdf521 Log: merge revision(s) 48402: * lib/rexml/document.rb: add REXML::Document#document. reported by Tomas Hoger <thoger@r...> and patched by nahi. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@48406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e Modified files: ChangeLog lib/rexml/document.rb lib/rexml/entity.rb test/rexml/test_document.rb version.h Index: v1_1r/ext/gtk/gtk.c =================================================================== --- v1_1r/ext/gtk/gtk.c (revision 22) +++ v1_1r/ext/gtk/gtk.c (revision 23) @@ -196,19 +196,20 @@ static void https://github.com/ruby/ruby/blob/trunk/v1_1r/ext/gtk/gtk.c#L196 gobj_free(obj) GtkObject *obj; { - VALUE self = get_value_from_gobject(obj); - - if (GTK_OBJECT_NEED_DESTROY(obj)) { - gtk_object_destroy(obj); - } - rb_ivar_set(self, id_relatives, Qnil); + /* just a type mark */ } static void -delete_gobject(obj) - GtkObject *obj; +delete_gobject(gtkobj, obj) + GtkObject *gtkobj; + VALUE obj; { - ary_delete(gtk_object_list, get_value_from_gobject(obj)); + struct RData *data; + + data = RDATA(rb_ivar_get(obj, id_gtkdata)); + data->dfree = 0; + data->data = 0; + ary_delete(gtk_object_list, obj); } static VALUE @@ -223,7 +224,8 @@ make_gobject(klass, gtkobj) https://github.com/ruby/ruby/blob/trunk/v1_1r/ext/gtk/gtk.c#L224 gtk_object_set_user_data(gtkobj, (gpointer)obj); rb_ivar_set(obj, id_gtkdata, data); - gtk_signal_connect(gtkobj, "destroy", (GtkSignalFunc)delete_gobject, 0); + gtk_signal_connect(gtkobj, "destroy", + (GtkSignalFunc)delete_gobject, (gpointer)obj); ary_push(gtk_object_list, obj); return obj; } Index: v1_1r/ext/gtk/test5.rb =================================================================== --- v1_1r/ext/gtk/test5.rb (revision 22) +++ v1_1r/ext/gtk/test5.rb (revision 23) @@ -21,10 +21,11 @@ button = [] https://github.com/ruby/ruby/blob/trunk/v1_1r/ext/gtk/test5.rb#L21 end 0.upto(8) do |i| button[i].signal_connect("clicked") do |w| - if button[i+1].visible? - button[i+1].hide + j = (i+1)%9 + if button[j].visible? + button[j].hide else - button[i+1].show + button[j].show end end button[i].show Index: v1_1r/ext/gtk/testd.rb =================================================================== --- v1_1r/ext/gtk/testd.rb (nonexistent) +++ v1_1r/ext/gtk/testd.rb (revision 23) @@ -0,0 +1,96 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/ext/gtk/testd.rb#L1 +require 'gtk' + +def create_menu(depth) + return nil if depth < 1 + + menu = Gtk::Menu::new() + group = nil + submenu = nil + + for i in 0..4 + buf = sprintf("item %2d - %d", depth, i+1) +# menuitem = Gtk::MenuItem::new(buf) + menuitem = Gtk::RadioMenuItem.new(group, buf) + group = menuitem.group + if depth % 2 + menuitem.set_show_toggle TRUE + end + menu.append menuitem + menuitem.show + if depth > 0 + unless submenu + submenu = create_menu(depth - 1) + end + menuitem.set_submenu submenu + end + end + return menu +end + +window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL) +window.signal_connect("destroy") do + exit +end +window.signal_connect("delete_event") do + exit +end +window.set_title("menus") +window.border_width(0) + +box1 = Gtk::VBox::new(FALSE, 0) +window.add box1 +box1.show + +menubar = Gtk::MenuBar::new() +box1.pack_start menubar, FALSE, TRUE, 0 +menubar.show + +menu = create_menu(2) +menuitem = Gtk::MenuItem::new("test\nline2") +menuitem.set_submenu menu +menubar.append menuitem +menuitem.show + +menuitem = Gtk::MenuItem::new("foo") +menuitem.set_submenu menu +menubar.append menuitem +menuitem.show + +menuitem = Gtk::MenuItem::new("bar") +menuitem.set_submenu menu +menubar.append menuitem +menuitem.show + +box2 = Gtk::VBox::new(FALSE, 10) +box2.border_width 10 +box1.pack_start box2, TRUE, TRUE, 0 +box2.show + +optionmenu = Gtk::OptionMenu::new() +optionmenu.set_menu create_menu(1) +optionmenu.set_history 4 +box2.pack_start optionmenu, TRUE, TRUE, 0 +optionmenu.show + +separator = Gtk::HSeparator::new() +box1.pack_start(separator, FALSE, TRUE, 0) +separator.show + +box2 = Gtk::HBox::new(FALSE, 10) +box2.border_width(10) +box1.pack_start(box2, FALSE, TRUE, 0) +box2.show + +button = Gtk::Button::new("close") +button.signal_connect("clicked") do + window.destroy + exit +end +box2.pack_start(button, TRUE, TRUE, 0) +button.set_flags(Gtk::CAN_DEFAULT); +button.grab_default +button.show + +window.show + +Gtk::main() Property changes on: v1_1r/ext/gtk/testd.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Index: v1_1r/ext/Setup =================================================================== --- v1_1r/ext/Setup (revision 22) +++ v1_1r/ext/Setup (revision 23) @@ -10,3 +10,4 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/ext/Setup#L10 #socket #tkutil #tcltklib +gtk Index: v1_1r/ChangeLog =================================================================== --- v1_1r/ChangeLog (revision 22) +++ v1_1r/ChangeLog (revision 23) @@ -1,7 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/ChangeLog#L1 Fri Jan 16 00:43:43 1998 Yukihiro Matsumoto <matz@n...> - * variable.c (rb_ivar_get): Files can have instance variables now. - * ruby.h (CLONESETUP): copies its singleton classes too. * class.c (singleton_class_attached): saves binded object in the Index: v1_1r/variable.c =================================================================== --- v1_1r/variable.c (revision 22) +++ v1_1r/variable.c (revision 23) @@ -97,14 +97,14 @@ fc_i(key, value, res) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L97 } static VALUE -find_class_path(cls) - VALUE cls; +find_class_path(klass) + VALUE klass; { struct fc_result arg; arg.name = 0; arg.path = 0; - arg.klass = cls; + arg.klass = klass; arg.track = cObject; arg.prev = 0; if (RCLASS(cObject)->iv_tbl) { @@ -114,30 +114,30 @@ find_class_path(cls) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L114 st_foreach(class_tbl, fc_i, &arg); } if (arg.name) { - rb_iv_set(cls, "__classpath__", arg.path); + rb_iv_set(klass, "__classpath__", arg.path); return arg.path; } return Qnil; } static VALUE -classname(cls) - VALUE cls; +classname(klass) + VALUE klass; { VALUE path; - while (TYPE(cls) == T_ICLASS || FL_TEST(cls, FL_SINGLETON)) { - cls = (VALUE)RCLASS(cls)->super; + while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) { + klass = (VALUE)RCLASS(klass)->super; } - path = rb_iv_get(cls, "__classpath__"); + path = rb_iv_get(klass, "__classpath__"); if (NIL_P(path)) { - path = rb_iv_get(cls, "__classid__"); + path = rb_iv_get(klass, "__classid__"); if (!NIL_P(path)) { path = str_new2(rb_id2name(FIX2INT(path))); } } if (NIL_P(path)) { - path = find_class_path(cls); + path = find_class_path(klass); if (NIL_P(path)) { return 0; } @@ -158,25 +158,25 @@ mod_name(mod) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L158 } VALUE -rb_class_path(cls) - VALUE cls; +rb_class_path(klass) + VALUE klass; { - VALUE path = classname(cls); + VALUE path = classname(klass); if (path) return path; else { char buf[256]; char *s = "Class"; - if (TYPE(cls) == T_MODULE) s = "Module"; - sprintf(buf, "#<%s 0x%x>", s, cls); + if (TYPE(klass) == T_MODULE) s = "Module"; + sprintf(buf, "#<%s 0x%x>", s, klass); return str_new2(buf); } } void -rb_set_class_path(cls, under, name) - VALUE cls, under; +rb_set_class_path(klass, under, name) + VALUE klass, under; char *name; { VALUE str; @@ -189,7 +189,7 @@ rb_set_class_path(cls, under, name) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L189 str_cat(str, "::", 2); str_cat(str, name, strlen(name)); } - rb_iv_set(cls, "__classpath__", str); + rb_iv_set(klass, "__classpath__", str); } VALUE @@ -203,17 +203,17 @@ rb_path2class(path) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L203 } void -rb_name_class(cls, id) - VALUE cls; +rb_name_class(klass, id) + VALUE klass; ID id; { extern VALUE cString; if (cString) { - rb_iv_set(cls, "__classpath__", str_new2(rb_id2name(id))); + rb_iv_set(klass, "__classpath__", str_new2(rb_id2name(id))); } else { - rb_iv_set(cls, "__classid__", INT2FIX(id)); + rb_iv_set(klass, "__classid__", INT2FIX(id)); } } @@ -235,17 +235,17 @@ rb_autoload_id(id, filename) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L235 } void -rb_autoload(cls, filename) - char *cls, *filename; +rb_autoload(klass, filename) + char *klass, *filename; { - rb_autoload_id(rb_intern(cls), filename); + rb_autoload_id(rb_intern(klass), filename); } VALUE -f_autoload(obj, cls, file) - VALUE obj, cls, file; +f_autoload(obj, klass, file) + VALUE obj, klass, file; { - ID id = rb_to_id(cls); + ID id = rb_to_id(klass); Check_Type(file, T_STRING); rb_autoload_id(id, RSTRING(file)->ptr); @@ -253,10 +253,10 @@ f_autoload(obj, cls, file) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L253 } char * -rb_class2name(cls) - VALUE cls; +rb_class2name(klass) + VALUE klass; { - return RSTRING(rb_class_path(cls))->ptr; + return RSTRING(rb_class_path(klass))->ptr; } struct trace_var { @@ -702,7 +702,6 @@ rb_ivar_get(obj, id) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L702 case T_OBJECT: case T_CLASS: case T_MODULE: - case T_FILE: if (ROBJECT(obj)->iv_tbl && st_lookup(ROBJECT(obj)->iv_tbl, id, &val)) return val; return Qnil; @@ -729,7 +728,6 @@ rb_ivar_set(obj, id, val) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L728 case T_OBJECT: case T_CLASS: case T_MODULE: - case T_FILE: if (!ROBJECT(obj)->iv_tbl) ROBJECT(obj)->iv_tbl = new_idhash(); st_insert(ROBJECT(obj)->iv_tbl, id, val); break; @@ -752,7 +750,6 @@ rb_ivar_defined(obj, id) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L750 case T_OBJECT: case T_CLASS: case T_MODULE: - case T_FILE: if (ROBJECT(obj)->iv_tbl && st_lookup(ROBJECT(obj)->iv_tbl, id, 0)) return TRUE; break; @@ -782,7 +779,6 @@ obj_instance_variables(obj) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L779 case T_OBJECT: case T_CLASS: case T_MODULE: - case T_FILE: if (ROBJECT(obj)->iv_tbl) { st_foreach(ROBJECT(obj)->iv_tbl, ivar_i, hash); } @@ -808,7 +804,6 @@ obj_remove_instance_variable(obj, name) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L804 case T_OBJECT: case T_CLASS: case T_MODULE: - case T_FILE: if (ROBJECT(obj)->iv_tbl) { st_delete(ROBJECT(obj)->iv_tbl, &id, &val); } @@ -822,41 +817,41 @@ obj_remove_instance_variable(obj, name) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L817 } VALUE -rb_const_get_at(cls, id) - VALUE cls; +rb_const_get_at(klass, id) + VALUE klass; ID id; { VALUE value; - if (RCLASS(cls)->iv_tbl && st_lookup(RCLASS(cls)->iv_tbl, id, &value)) { + if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) { return value; } - if (cls == cObject) { - return rb_const_get(cls, id); + if (klass == cObject) { + return rb_const_get(klass, id); } NameError("Uninitialized constant %s::%s", - RSTRING(rb_class_path(cls))->ptr, + RSTRING(rb_class_path(klass))->ptr, rb_id2name(id)); /* not reached */ } VALUE -rb_const_get(cls, id) - VALUE cls; +rb_const_get(klass, id) + VALUE klass; ID id; { VALUE value; VALUE tmp; - tmp = cls; + tmp = klass; while (tmp) { if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { return value; } tmp = RCLASS(tmp)->super; } - if (BUILTIN_TYPE(cls) == T_MODULE) { + if (BUILTIN_TYPE(klass) == T_MODULE) { return rb_const_get(cObject, id); } @@ -872,13 +867,13 @@ rb_const_get(cls, id) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L867 module = str_new2(modname); free(modname); f_require(0, module); - return rb_const_get(cls, id); + return rb_const_get(klass, id); } /* Uninitialized constant */ - if (cls && cls != cObject) + if (klass && klass != cObject) NameError("Uninitialized constant %s::%s", - RSTRING(rb_class_path(cls))->ptr, + RSTRING(rb_class_path(klass))->ptr, rb_id2name(id)); else { NameError("Uninitialized constant %s",rb_id2name(id)); @@ -952,15 +947,15 @@ mod_const_of(mod, ary) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L947 } int -rb_const_defined_at(cls, id) - VALUE cls; +rb_const_defined_at(klass, id) + VALUE klass; ID id; { - if (RCLASS(cls)->iv_tbl && st_lookup(RCLASS(cls)->iv_tbl, id, 0)) { + if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) { return TRUE; } - if (cls == cObject) { - return rb_const_defined(cls, id); + if (klass == cObject) { + return rb_const_defined(klass, id); } return FALSE; } @@ -975,15 +970,15 @@ rb_autoload_defined(id) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L970 } int -rb_const_defined(cls, id) - VALUE cls; +rb_const_defined(klass, id) + VALUE klass; ID id; { - while (cls) { - if (RCLASS(cls)->iv_tbl && st_lookup(RCLASS(cls)->iv_tbl, id, 0)) { + while (klass) { + if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) { return TRUE; } - cls = RCLASS(cls)->super; + klass = RCLASS(klass)->super; } if (st_lookup(class_tbl, id, 0)) return TRUE; @@ -991,24 +986,24 @@ rb_const_defined(cls, id) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L986 } void -rb_const_set(cls, id, val) - VALUE cls; +rb_const_set(klass, id, val) + VALUE klass; ID id; VALUE val; { - if (!RCLASS(cls)->iv_tbl) { - RCLASS(cls)->iv_tbl = new_idhash(); + if (!RCLASS(klass)->iv_tbl) { + RCLASS(klass)->iv_tbl = new_idhash(); } - else if (st_lookup(RCLASS(cls)->iv_tbl, id, 0)) { + else if (st_lookup(RCLASS(klass)->iv_tbl, id, 0)) { NameError("already initialized constant %s", rb_id2name(id)); } - st_insert(RCLASS(cls)->iv_tbl, id, val); + st_insert(RCLASS(klass)->iv_tbl, id, val); } void -rb_define_const(cls, name, val) - VALUE cls; +rb_define_const(klass, name, val) + VALUE klass; char *name; VALUE val; { @@ -1016,7 +1011,7 @@ rb_define_const(cls, name, val) https://github.com/ruby/ruby/blob/trunk/v1_1r/variable.c#L1011 if (!rb_is_const_id(id)) { NameError("wrong constant name %s", name); } - rb_const_set(cls, id, val); + rb_const_set(klass, id, val); } void Index: v1_1r/sample/ruby-mode.el =================================================================== --- v1_1r/sample/ruby-mode.el (revision 22) +++ v1_1r/sample/ruby-mode.el (revision 23) @@ -633,7 +633,7 @@ An end of a defun is found by moving for https://github.com/ruby/ruby/blob/trunk/v1_1r/sample/ruby-mode.el#L633 2 font-lock-type-face) ;; functions '("^\\s *def[ \t]+.*$" - 0 font-lock-function-name-face)) + 0 font-lock-function-name-face t)) "*Additional expressions to highlight in ruby mode.") (if (and (>= (string-to-int emacs-version) 20) (not (featurep 'xemacs))) Index: v1_1r/lib/tempfile.rb =================================================================== --- v1_1r/lib/tempfile.rb (revision 22) +++ v1_1r/lib/tempfile.rb (revision 23) @@ -6,11 +6,11 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/tempfile.rb#L6 # The class for temporary files. # o creates a temporary file, which name is "basename.pid.n" with mode "w+". # o Tempfile objects can be used like IO object. -# o created temporary files are removed if it is closed or garbage collected, -# or script termination. +# o created temporary files are removed on closing or script termination. # o file mode of the temporary files are 0600. require 'delegate' +require 'final' class Tempfile < SimpleDelegater Max_try = 10 @@ -45,8 +45,7 @@ class Tempfile < SimpleDelegater https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/tempfile.rb#L45 File.unlink(@tmpdir + '/' + @tmpname + '.lock') end } - ObjectSpace.call_finalizer(self) - ObjectSpace.add_finalizer(@clean_files) + ObjectSpace.define_finalizer(self, @clean_files) @tmpfile = open(@tmpname, 'w+') super(@tmpfile) @@ -57,8 +56,13 @@ class Tempfile < SimpleDelegater https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/tempfile.rb#L56 end end + def Tempfile.open(*args) + Tempfile.new(*args) + end + def close - super + @tmpfile.close @clean_files.call + ObjectSpace.undefine_finalizer(self) end end Index: v1_1r/lib/sync.rb =================================================================== --- v1_1r/lib/sync.rb (revision 22) +++ v1_1r/lib/sync.rb (revision 23) @@ -43,7 +43,7 @@ unless defined? Thread https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/sync.rb#L43 fail "Thread not available for this ruby interpreter" end -require "finalize" +require "final" module Sync_m RCS_ID='-$Header$-' @@ -321,7 +321,11 @@ module Sync_m https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/sync.rb#L321 def For_primitive_object.extend_object(obj) super obj.sync_extended - Finalizer.add(obj, For_primitive_object, :sync_finalize) + # Changed to use `final.rb'. + # Finalizer.add(obj, For_primitive_object, :sync_finalize) + ObjectSpace.define_finalizer(obj) do |id| + For_primitive_object.sync_finalize(id) + end end def initialize Index: v1_1r/lib/ftplib.rb =================================================================== --- v1_1r/lib/ftplib.rb (revision 22) +++ v1_1r/lib/ftplib.rb (revision 23) @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/ftplib.rb#L1 ### ftplib.rb -*- Mode: ruby; tab-width: 8; -*- -## $Revision: 1.1.1.1 $ -## $Date: 1998/01/16 04:05:49 $ +## $Revision: 1.1.1.1.4.1 $ +## $Date: 1998/01/16 12:36:05 $ ## by maeda shugo <shugo@p...> ### Code: @@ -17,7 +17,7 @@ class FTPProtoError < FTPError; end https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/ftplib.rb#L17 class FTP - RCS_ID = '$Id: ftplib.rb,v 1.1.1.1 1998/01/16 04:05:49 matz Exp $' + RCS_ID = '$Id: ftplib.rb,v 1.1.1.1.4.1 1998/01/16 12:36:05 matz Exp $ ' FTP_PORT = 21 CRLF = "\r\n" Index: v1_1r/lib/final.rb =================================================================== --- v1_1r/lib/final.rb (nonexistent) +++ v1_1r/lib/final.rb (revision 23) @@ -0,0 +1,41 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/lib/final.rb#L1 +# +# $Id$ +# Copyright (C) 1998 Yukihiro Matsumoto. All rights reserved. + +# The ObjectSpace extention: +# +# ObjectSpace.define_finalizer(obj, proc=lambda()) +# +# Defines the finalizer for the specified object. +# +# ObjectSpace.undefine_finalizer(obj) +# +# Removes the finalizers for the object. If multiple finalizers are +# defined for the object, all finalizers will be removed. +# + +module ObjectSpace + Finalizer = {} + def define_finalizer(obj, proc=lambda()) + ObjectSpace.call_finalizer(obj) + if assoc = Finalizer[obj.id] + assoc.push(proc) + else + Finalizer[obj.id] = [proc] + end + end + def undefine_finalizer(obj) + Finalizer.delete(obj.id) + end + module_function :define_finalizer, :remove_finalizer + + Generic_Finalizer = proc {|id| + if Finalizer.key? id + for proc in Finalizer[id] + proc.call(id) + end + Finalizer.delete(id) + end + } + add_finalizer Generic_Finalizer +end Property changes on: v1_1r/lib/final.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property I (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/