mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* template/encdb.h.tmpl: define encoding index macros to use the index
statically from C source. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
df1192edf5
commit
5308b0fd5e
2 changed files with 20 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Jul 1 23:07:38 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* template/encdb.h.tmpl: define encoding index macros to use the index
|
||||||
|
statically from C source.
|
||||||
|
|
||||||
Mon Jul 1 22:57:19 2013 Tanaka Akira <akr@fsij.org>
|
Mon Jul 1 22:57:19 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (bary_mul2): New function.
|
* bignum.c (bary_mul2): New function.
|
||||||
|
|
|
@ -19,9 +19,14 @@ def check_duplication(defs, name, fn, line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
count = 0
|
|
||||||
lines = []
|
lines = []
|
||||||
encodings = []
|
BUILTIN_ENCODINGS = {
|
||||||
|
'ASCII-8BIT' => 0,
|
||||||
|
'UTF-8' => 1,
|
||||||
|
'US-ASCII' => 2,
|
||||||
|
}
|
||||||
|
encodings = %w[ASCII-8BIT UTF-8 US-ASCII] # BUILTIN_ENCODINGS.keys is not available on cross compiling and used ruby 1.8
|
||||||
|
count = encodings.size
|
||||||
defs = {}
|
defs = {}
|
||||||
encdirs = ARGV.dup
|
encdirs = ARGV.dup
|
||||||
encdirs << 'enc' if encdirs.empty?
|
encdirs << 'enc' if encdirs.empty?
|
||||||
|
@ -44,6 +49,7 @@ encdirs.each do |encdir|
|
||||||
name = $1
|
name = $1
|
||||||
end
|
end
|
||||||
check_duplication(defs, $1, fn, $.)
|
check_duplication(defs, $1, fn, $.)
|
||||||
|
next if BUILTIN_ENCODINGS[name]
|
||||||
encodings << $1
|
encodings << $1
|
||||||
count += 1
|
count += 1
|
||||||
end
|
end
|
||||||
|
@ -52,6 +58,7 @@ encdirs.each do |encdir|
|
||||||
when /^\s*rb_enc_register\(\s*"([^"]+)"/
|
when /^\s*rb_enc_register\(\s*"([^"]+)"/
|
||||||
count += 1
|
count += 1
|
||||||
line = nil
|
line = nil
|
||||||
|
encodings << $1
|
||||||
when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
|
when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
|
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
|
||||||
|
@ -73,11 +80,16 @@ encdirs.each do |encdir|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
encodings.each do |e|
|
encodings.each_with_index do |e, i|
|
||||||
%>ENC_DEFINE("<%=e%>");
|
%>ENC_DEFINE("<%=e%>");
|
||||||
|
#define ENCIDX_<%=e.tr('-', '_')%> <%=i%>
|
||||||
% end
|
% end
|
||||||
|
% encidx = encodings.size - 1
|
||||||
% lines.each do |line|
|
% lines.each do |line|
|
||||||
<%=line%>
|
<%=line%>
|
||||||
|
% if /^ENC_(?:DUMMY(?:_UNICODE)?|REPLICATE)\(\s*"([^"]+)/ =~ line
|
||||||
|
#define ENCIDX_<%=$1.tr('-', '_')%> <%=encidx+=1%>
|
||||||
|
% end
|
||||||
% end
|
% end
|
||||||
|
|
||||||
#define ENCODING_COUNT <%=count%>
|
#define ENCODING_COUNT <%=count%>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue