diff --git a/common.mk b/common.mk index c893e55f29..899ab0b116 100644 --- a/common.mk +++ b/common.mk @@ -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=$@ \ diff --git a/enc/make_encdb.rb b/template/encdb.h.tmpl similarity index 87% rename from enc/make_encdb.rb rename to template/encdb.h.tmpl index 5a420aed32..e65b651050 100644 --- a/enc/make_encdb.rb +++ b/template/encdb.h.tmpl @@ -1,3 +1,4 @@ +<% # # OnigEncodingDefine(foo, Foo) = { # .. @@ -23,7 +24,6 @@ lines = [] encodings = [] defs = {} encdirs = ARGV.dup -outhdr = encdirs.shift || 'encdb.h' encdirs << 'enc' if encdirs.empty? files = {} encdirs.each do |encdir| @@ -63,15 +63,17 @@ encdirs.each do |encdir| 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%> diff --git a/enc/trans/make_transdb.rb b/template/transdb.h.tmpl similarity index 87% rename from enc/trans/make_transdb.rb rename to template/transdb.h.tmpl index 4f11abd35a..d0cf101344 100644 --- a/enc/trans/make_transdb.rb +++ b/template/transdb.h.tmpl @@ -1,3 +1,4 @@ +<% # # static const rb_transcoder # rb_from_US_ASCII = { @@ -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| @@ -53,9 +53,7 @@ transdirs.each do |transdir| 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