diff --git a/ChangeLog b/ChangeLog index 6bb3ca56f2..aa656e1262 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ -Wed Feb 27 13:49:24 2002 Yukihiro Matsumoto +Wed Feb 27 16:31:38 2002 Yukihiro Matsumoto - * stable version 1.6.6 released. + * stable version 1.6.7 released. + +Wed Feb 27 16:30:50 2002 Yukihiro Matsumoto + + * st.c (st_init_table_with_size): num_bins should be prime numbers + (no decrement). + + * st.c (rehash): ditto. Wed Feb 27 13:18:49 2002 WATANABE Hirofumi diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 144569b339..66df8de606 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -2174,6 +2174,123 @@ module TkTreatFont end end +module TkTreatItemFont + def __conf_cmd(idx) + raise NotImplementError, "need to define `__conf_cmd'" + end + def __item_pathname(tagOrId) + raise NotImplementError, "need to define `__item_pathname'" + end + private :__conf_cmd, :__item_pathname + + def tagfont_configinfo(tagOrId) + pathname = __item_pathname(tagOrId) + ret = TkFont.used_on(pathname) + if ret == nil + ret = TkFont.init_widget_font(pathname, self.path, + __conf_cmd(0), __conf_cmd(1), tagOrId) + end + ret + end + alias tagfontobj tagfont_configinfo + + def tagfont_configure(tagOrId, slot) + pathname = __item_pathname(tagOrId) + if (fnt = slot.delete('font')) + if fnt.kind_of? TkFont + return fnt.call_font_configure(pathname, self.path, + __conf_cmd(0), __conf_cmd(1), + tagOrId, slot) + else + latintagfont_configure(tagOrId, fnt) if fnt + end + end + if (ltn = slot.delete('latinfont')) + latintagfont_configure(tagOrId, ltn) if ltn + end + if (ltn = slot.delete('asciifont')) + latintagfont_configure(tagOrId, ltn) if ltn + end + if (knj = slot.delete('kanjifont')) + kanjitagfont_configure(tagOrId, knj) if knj + end + + tk_call(self.path, __conf_cmd(0), __conf_cmd(1), + tagOrId, *hash_kv(slot)) if slot != {} + self + end + + def latintagfont_configure(tagOrId, ltn, keys=nil) + fobj = tagfontobj(tagOrId) + if ltn.kind_of? TkFont + conf = {} + ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []} + if conf == {} + fobj.latin_replace(ltn) + fobj.latin_configure(keys) if keys + elsif keys + fobj.latin_configure(conf.update(keys)) + else + fobj.latin_configure(conf) + end + else + fobj.latin_replace(ltn) + end + end + alias asciitagfont_configure latintagfont_configure + + def kanjitagfont_configure(tagOrId, knj, keys=nil) + fobj = tagfontobj(tagOrId) + if knj.kind_of? TkFont + conf = {} + knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []} + if conf == {} + fobj.kanji_replace(knj) + fobj.kanji_configure(keys) if keys + elsif keys + fobj.kanji_configure(conf.update(keys)) + else + fobj.kanji_configure(conf) + end + else + fobj.kanji_replace(knj) + end + end + + def tagfont_copy(tagOrId, window, wintag=nil) + if wintag + window.tagfontobj(wintag).configinfo.each{|key,value| + tagfontobj(tagOrId).configure(key,value) + } + tagfontobj(tagOrId).replace(window.tagfontobj(wintag).latin_font, + window.tagfontobj(wintag).kanji_font) + else + window.tagfont(wintag).configinfo.each{|key,value| + tagfontobj(tagOrId).configure(key,value) + } + tagfontobj(tagOrId).replace(window.fontobj.latin_font, + window.fontobj.kanji_font) + end + end + + def latintagfont_copy(tagOrId, window, wintag=nil) + if wintag + tagfontobj(tagOrId).latin_replace(window.tagfontobj(wintag).latin_font) + else + tagfontobj(tagOrId).latin_replace(window.fontobj.latin_font) + end + end + alias asciitagfont_copy latintagfont_copy + + def kanjitagfont_copy(tagOrId, window, wintag=nil) + if wintag + tagfontobj(tagOrId).kanji_replace(window.tagfontobj(wintag).kanji_font) + else + tagfontobj(tagOrId).kanji_replace(window.fontobj.kanji_font) + end + end +end + class TkObjectval}) + tagfont_configure(index, {key=>val}) else tk_call 'itemconfigure', index, "-#{key}", val end @@ -2995,109 +3228,15 @@ class TkListboxval}) + tagfont_configure(index, {key=>val}) else tk_call 'entryconfigure', index, "-#{key}", val end @@ -3235,8 +3378,14 @@ module TkSystemMenu 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 + if self.method(:create_self).arity == 0 + p 'create_self has no arg' if $DEBUG + create_self + configure(keys) if keys + else + p 'create_self has an arg' if $DEBUG + create_self(keys) + end end end @@ -3263,8 +3412,12 @@ class TkMenubutton @@ -9,116 +9,18 @@ require "tk" require 'tkfont' module TkTreatCItemFont - def tagfont_configinfo(tagOrId) + include TkTreatItemFont + + ItemCMD = ['itemconfigure', TkComm::None] + def __conf_cmd(idx) + ItemCMD[idx] + end + + def __item_pathname(tagOrId) if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) - pathname = self.path + ';' + tagOrId.id.to_s + self.path + ';' + tagOrId.id.to_s else - pathname = self.path + ';' + tagOrId.to_s - end - ret = TkFont.used_on(pathname) - if ret == nil - ret = TkFont.init_widget_font(pathname, - self.path, 'itemconfigure', tagOrId) - end - ret - end - alias tagfontobj tagfont_configinfo - - def tagfont_configure(tagOrId, slot) - if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) - pathname = self.path + ';' + tagOrId.id.to_s - else - pathname = self.path + ';' + tagOrId.to_s - end - if (fnt = slot.delete('font')) - if fnt.kind_of? TkFont - return fnt.call_font_configure(pathname, - self.path,'itemconfigure',tagOrId,slot) - else - latintagfont_configure(tagOrId, fnt) if fnt - end - end - if (ltn = slot.delete('latinfont')) - latintagfont_configure(tagOrId, ltn) if ltn - end - if (ltn = slot.delete('asciifont')) - latintagfont_configure(tagOrId, ltn) if ltn - end - if (knj = slot.delete('kanjifont')) - kanjitagfont_configure(tagOrId, knj) if knj - end - - tk_call(self.path, 'itemconfigure', tagOrId, *hash_kv(slot)) if slot != {} - self - end - - def latintagfont_configure(tagOrId, ltn, keys=nil) - fobj = tagfontobj(tagOrId) - if ltn.kind_of? TkFont - conf = {} - ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []} - if conf == {} - fobj.latin_replace(ltn) - fobj.latin_configure(keys) if keys - elsif keys - fobj.latin_configure(conf.update(keys)) - else - fobj.latin_configure(conf) - end - else - fobj.latin_replace(ltn) - end - end - alias asciitagfont_configure latintagfont_configure - - def kanjitagfont_configure(tagOrId, knj, keys=nil) - fobj = tagfontobj(tagOrId) - if knj.kind_of? TkFont - conf = {} - knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []} - if conf == {} - fobj.kanji_replace(knj) - fobj.kanji_configure(keys) if keys - elsif keys - fobj.kanji_configure(conf.update(keys)) - else - fobj.kanji_configure(conf) - end - else - fobj.kanji_replace(knj) - end - end - - def tagfont_copy(tagOrId, window, wintag=nil) - if wintag - window.tagfontobj(wintag).configinfo.each{|key,value| - tagfontobj(tagOrId).configure(key,value) - } - tagfontobj(tagOrId).replace(window.tagfontobj(wintag).latin_font, - window.tagfontobj(wintag).kanji_font) - else - window.tagfont(tagOrId).configinfo.each{|key,value| - tagfontobj(tagOrId).configure(key,value) - } - tagfontobj(tagOrId).replace(window.fontobj.latin_font, - window.fontobj.kanji_font) - end - end - - def latintagfont_copy(tagOrId, window, wintag=nil) - if wintag - tagfontobj(tagOrId).latin_replace(window.tagfontobj(wintag).latin_font) - else - tagfontobj(tagOrId).latin_replace(window.fontobj.latin_font) - end - end - alias asciitagfont_copy latintagfont_copy - - def kanjitagfont_copy(tagOrId, window, wintag=nil) - if wintag - tagfontobj(tagOrId).kanji_replace(window.tagfontobj(wintag).kanji_font) - else - tagfontobj(tagOrId).kanji_replace(window.fontobj.kanji_font) + self.path + ';' + tagOrId.to_s end end end @@ -133,8 +35,12 @@ class TkCanvasval}) + tagfont_configure(tag, {key=>val}) else tk_send 'tag', 'configure', tag, "-#{key}", val end diff --git a/marshal.c b/marshal.c index 618e98f459..9a92081bb8 100644 --- a/marshal.c +++ b/marshal.c @@ -822,6 +822,7 @@ r_object(arg) case TYPE_FALSE: v = Qfalse; + break; case TYPE_FIXNUM: { diff --git a/st.c b/st.c index e9e5e7960e..ee758b1fcb 100644 --- a/st.c +++ b/st.c @@ -163,7 +163,7 @@ st_init_table_with_size(type, size) tbl = alloc(st_table); tbl->type = type; tbl->num_entries = 0; - tbl->num_bins = size-1; + tbl->num_bins = size; tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*)); return tbl; @@ -209,7 +209,7 @@ st_free_table(table) register st_table_entry *ptr, *next; int i; - for(i = 0; i <= table->num_bins; i++) { + for(i = 0; i < table->num_bins; i++) { ptr = table->bins[i]; while (ptr != 0) { next = ptr->next; @@ -264,7 +264,7 @@ st_lookup(table, key, value) #define ADD_DIRECT(table, key, value, hash_val, bin_pos)\ {\ st_table_entry *entry;\ - if (table->num_entries/(table->num_bins+1) > ST_DEFAULT_MAX_DENSITY) {\ + if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\ rehash(table);\ bin_pos = hash_val % table->num_bins;\ }\ @@ -324,8 +324,7 @@ rehash(table) new_num_bins = new_size(old_num_bins+1); new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*)); - new_num_bins--; - for(i = 0; i <= old_num_bins; i++) { + for(i = 0; i < old_num_bins; i++) { ptr = table->bins[i]; while (ptr != 0) { next = ptr->next; @@ -346,7 +345,7 @@ st_copy(old_table) { st_table *new_table; st_table_entry *ptr, *entry; - int i, num_bins = old_table->num_bins+1; + int i, num_bins = old_table->num_bins; new_table = alloc(st_table); if (new_table == 0) { @@ -483,7 +482,7 @@ st_foreach(table, func, arg) enum st_retval retval; int i; - for(i = 0; i <= table->num_bins; i++) { + for(i = 0; i < table->num_bins; i++) { last = 0; for(ptr = table->bins[i]; ptr != 0;) { retval = (*func)(ptr->key, ptr->record, arg);