Skip to content

Commit

Permalink
* ext/iconv/charset_alias.rb: preserve original order.
Browse files Browse the repository at this point in the history
* ext/iconv/extconf.rb: remove wrapper file at clean.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 13, 2003
1 parent 6a3f682 commit 2298eb5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Sat Dec 13 18:55:16 2003 Nobuyoshi Nakada <[email protected]>

* ext/iconv/charset_alias.rb: preserve original order.

* ext/iconv/extconf.rb: remove wrapper file at clean.

Sat Dec 13 18:09:42 2003 Yukihiro Matsumoto <[email protected]>

* eval.c (thread_timer): use timer by sub-thread and nanosleep.
Expand Down
17 changes: 15 additions & 2 deletions ext/iconv/charset_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@
OS = Config::CONFIG["target"]
SHELL = Config::CONFIG['SHELL']

class Hash::Ordered < Hash
def [](key)
val = super and val.last
end
def []=(key, val)
ary = fetch(key) {return super(key, [self.size, key, val])} and
ary.last = val
end
def each
values.sort.each {|i, key, val| yield key, val}
end
end

def charset_alias(config_charset, mapfile, target = OS)
map = {}
map = Hash::Ordered.new
comments = []
IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list|
next comments << list if /^\#/ =~ list
Expand All @@ -29,7 +42,7 @@ def charset_alias(config_charset, mapfile, target = OS)
f.puts
f.puts(comments)
f.puts("class Iconv")
map.keys.sort.each {|can| f.puts(" charset_map['#{can}'.freeze] = '#{map[can]}'.freeze")}
map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")}
f.puts("end")
end
end
Expand Down
4 changes: 3 additions & 1 deletion ext/iconv/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
else
conf = prefix + "config.charset"
end
wrapper = "iconv.rb"
$cleanfiles << wrapper
end
create_makefile("iconv")
if conf
open("Makefile", "a") do |mf|
mf.print("\nall: iconv.rb\n\niconv.rb: ", prefix, "charset_alias.rb")
mf.print("\nall: #{wrapper}\n\n#{wrapper}: #{prefix}charset_alias.rb")
mf.print(" ", conf) unless scheme
mf.print("\n\t$(RUBY) ", prefix, "charset_alias.rb ", conf, " $@\n")
end
Expand Down

0 comments on commit 2298eb5

Please sign in to comment.