Skip to content

Commit

Permalink
* template/{encdb,transdb}.h.tmpl: moved enc/make_encdb.rb and
Browse files Browse the repository at this point in the history
  enc/trans/make_transdb.rb using tool/generic_erb.rb.

* common.mk (encdb.h, transdb.h): generates from avobe template.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jan 13, 2009
1 parent 4cb8d33 commit e668e36
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
10 changes: 4 additions & 6 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,11 @@ insns: $(INSNS)

node_name.inc: {$(VPATH)}node.h

encdb.h: $(PREP)
$(MINIRUBY) $(srcdir)/enc/make_encdb.rb $@.new $(srcdir)/enc enc
$(IFCHANGE) "$@" "$@.new"
encdb.h: $(PREP) $(srcdir)/tool/generic_erb.rb $(srcdir)/template/encdb.h.tmpl
$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -c -o $@ $(srcdir)/template/encdb.h.tmpl $(srcdir)/enc enc

transdb.h: $(PREP) srcs-enc
$(MINIRUBY) $(srcdir)/enc/trans/make_transdb.rb $@.new $(srcdir)/enc/trans enc/trans
$(IFCHANGE) "$@" "$@.new"
transdb.h: $(PREP) srcs-enc $(srcdir)/tool/generic_erb.rb $(srcdir)/template/transdb.h.tmpl
$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -c -o $@ $(srcdir)/template/transdb.h.tmpl $(srcdir)/enc/trans enc/trans

# {$(VPATH)}id.h: {$(VPATH)}parse.h $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.h.tmpl
# $(BASERUBY) $(srcdir)/tool/generic_erb.rb --if-change --output=$@ \
Expand Down
16 changes: 9 additions & 7 deletions enc/make_encdb.rb → template/encdb.h.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%
#
# OnigEncodingDefine(foo, Foo) = {
# ..
Expand All @@ -23,7 +24,6 @@ def check_duplication(defs, name, fn, line)
encodings = []
defs = {}
encdirs = ARGV.dup
outhdr = encdirs.shift || 'encdb.h'
encdirs << 'enc' if encdirs.empty?
files = {}
encdirs.each do |encdir|
Expand Down Expand Up @@ -63,15 +63,17 @@ def check_duplication(defs, name, fn, line)
next
end
check_duplication(defs, $1, fn, $.)
lines << line.sub(/;.*/m, "").chomp + ";\n" if line
lines << line.sub(/;.*/m, "").chomp + ";" if line
end
end
end
end
end
encodings.each do |e|
%>ENC_DEFINE("<%=e%>");
% end
% lines.each do |line|
<%=line%>
% end

result = encodings.map {|e| %[ENC_DEFINE("#{e}");\n]}.join + lines.join +
"\n#define ENCODING_COUNT #{count}\n"
open(outhdr, 'wb') do |f|
f.print result
end
#define ENCODING_COUNT <%=count%>
12 changes: 5 additions & 7 deletions enc/trans/make_transdb.rb → template/transdb.h.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%
#
# static const rb_transcoder
# rb_from_US_ASCII = {
Expand All @@ -9,7 +10,6 @@
count = 0
converters = {}
transdirs = ARGV.dup
outhdr = transdirs.shift || 'transdb.h'
transdirs << 'enc/trans' if transdirs.empty?

transdirs = transdirs.sort_by {|td|
Expand Down Expand Up @@ -53,9 +53,7 @@
end
end
end
result = converter_list.map do |from_to|
%[rb_declare_transcoder("%s", "%s", "%s");\n] % converters[from_to]
end.join("")
open(outhdr, 'wb') do |f|
f.print result
end
converter_list.each do |from_to|
from, to, fn = *converters[from_to]
%>rb_declare_transcoder("<%=from%>", "<%=to%>", "<%=fn%>");
% end

0 comments on commit e668e36

Please sign in to comment.