summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 08:07:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 08:07:56 +0000
commitdc4d4b3923cbb832f69abdc0df6d9ee0ea38cae1 (patch)
treefcfaf15c7c5843954940f34a66abee4e68901b89
parentbe137f3601610491d4265a4f9c87bf52fef28d66 (diff)
* common.mk (enc.mk): depends on rbconfig.rb.
* regenc.h (OnigEncodingDefine): external encoding definition macro. * enc/Makefile.in: fix for linking. * enc/depend, enc/make_encmake.rb: fix for Windows. * enc/{ascii,euc_jp,sjis,utf8,iso_8859_{1..16}}.c: renamed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--common.mk4
-rw-r--r--enc/Makefile.in12
-rw-r--r--enc/ascii.c2
-rw-r--r--enc/depend27
-rw-r--r--enc/euc_jp.c2
-rw-r--r--enc/iso_8859_1.c2
-rw-r--r--enc/iso_8859_10.c2
-rw-r--r--enc/iso_8859_11.c2
-rw-r--r--enc/iso_8859_13.c2
-rw-r--r--enc/iso_8859_14.c2
-rw-r--r--enc/iso_8859_15.c2
-rw-r--r--enc/iso_8859_16.c2
-rw-r--r--enc/iso_8859_2.c2
-rw-r--r--enc/iso_8859_3.c2
-rw-r--r--enc/iso_8859_4.c2
-rw-r--r--enc/iso_8859_5.c2
-rw-r--r--enc/iso_8859_6.c2
-rw-r--r--enc/iso_8859_7.c2
-rw-r--r--enc/iso_8859_8.c2
-rw-r--r--enc/iso_8859_9.c2
-rw-r--r--enc/make_encmake.rb4
-rw-r--r--enc/sjis.c2
-rw-r--r--enc/utf8.c2
-rw-r--r--regenc.h16
25 files changed, 87 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b4ec27..fa90ad8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Thu Dec 20 17:07:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * common.mk (enc.mk): depends on rbconfig.rb.
+
+ * regenc.h (OnigEncodingDefine): external encoding definition macro.
+
+ * enc/Makefile.in: fix for linking.
+
+ * enc/depend, enc/make_encmake.rb: fix for Windows.
+
+
+ * enc/{ascii,euc_jp,sjis,utf8,iso_8859_{1..16}}.c: renamed.
+
Thu Dec 20 16:42:55 2007 Koichi Sasada <ko1@atdot.net>
* iseq.c (find_line_no): return 0 if not found.
diff --git a/common.mk b/common.mk
index a015cb8..9805163 100644
--- a/common.mk
+++ b/common.mk
@@ -343,8 +343,8 @@ encs: enc.mk
$(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTOUT)/$(arch)/enc"
$(MAKE) -f enc.mk -$(MAKEFLAGS)
-enc.mk: miniruby$(EXEEXT) $(srcdir)/enc/make_encmake.rb \
- $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend $(srcdir)/lib/mkmf.rb
+enc.mk: $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend \
+ $(srcdir)/lib/mkmf.rb rbconfig.rb
$(MINIRUBY) $(srcdir)/enc/make_encmake.rb --builtin-encs="$(BUILTIN_ENCOBJS)" $@
.PRECIOUS: $(MKFILES)
diff --git a/enc/Makefile.in b/enc/Makefile.in
index 6cb9789..a16124d 100644
--- a/enc/Makefile.in
+++ b/enc/Makefile.in
@@ -1,4 +1,6 @@
srcdir = @srcdir@
+topdir = .
+libdir = @libdir@
top_srcdir = $(srcdir:/enc=)
arch = @arch@
EXTOUT = @EXTOUT@
@@ -12,16 +14,22 @@ BUILTIN_ENCS = ascii.c \
euc_jp.c sjis.c \
unicode.c utf8.c
+RUBY_SO_NAME = @RUBY_SO_NAME@
+LIBRUBY = @LIBRUBY@
+LIBRUBY_A = @LIBRUBY_A@
+LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@
+LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
+
empty =
CC = @CC@
OUTFLAG = @OUTFLAG@$(empty)
CFLAGS = @CFLAGS@ @ARCH_FLAG@
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir)
DEFS = @DEFS@
-CPPFLAGS = @CPPFLAGS@
+CPPFLAGS = @CPPFLAGS@ -DONIG_ENC_REGISTER=rb_enc_register
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
-LIBS = @LIBS@ $(EXTLIBS)
+LIBS = @LIBRUBYARG@ @LIBS@ $(EXTLIBS)
LDSHARED = @LDSHARED@
DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
diff --git a/enc/ascii.c b/enc/ascii.c
index 894cea4..9428902 100644
--- a/enc/ascii.c
+++ b/enc/ascii.c
@@ -38,7 +38,7 @@ ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
return FALSE;
}
-OnigEncodingType OnigEncodingASCII = {
+OnigEncodingDefine(ASCII) = {
onigenc_single_byte_mbc_enc_len,
"ASCII-8BIT",/* name */
1, /* max byte length */
diff --git a/enc/depend b/enc/depend
index f5eeafe..29ae915 100644
--- a/enc/depend
+++ b/enc/depend
@@ -3,23 +3,43 @@
! encs = encs.sort_by {|e| e.split(/(\d+)/).map {|n| Integer(n) rescue n}}
VPATH = <% %w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join(CONFIG["PATH_SEPARATOR"]) %>
+LIBPATH = <%libpathflag($DEFLIBPATH)%>
ENCOBJS = <%encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%"\n" if encs.size>1%>
+ENCDEFS = <%encs.map {|e|"#{e}.def"}.join(" \\\n\t ") if DEFFILE%><%"\n" if encs.size>1%>
ENCSOS = <%encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>
all: $(ENCSOS)
-.c.$(OBJEXT):
+! COMPILE_RULES.each do |rule|
+<% rule % %w[c $(OBJEXT)] %>
<%COMPILE_C%>
+
+! end
! unless encs.empty?
$(ENCOBJS): regenc.h oniguruma.h config.h defines.h
+! encs.each do |e|
+<%e%>.so: $(ENCSODIR)/<%e%>.$(DLEXT)
! end
+
+! end
+! link_so = LINK_SO.gsub(/\n/, "\n\t")
! encs.each do |e|
-$(ENCSODIR)/<%e%>.$(DLEXT): <%e%>.$(OBJEXT)
- <%LINK_SO.gsub(/\n/, "\n\t")%>
+! deps = "#{e}.$(OBJEXT)"
+! deps << " #{e}-$(arch).def" if DEFFILE
+$(ENCSODIR)/<%e%>.$(DLEXT): <%deps%>
+ <%link_so.sub(/\$\(OBJS\)/, deps)%>
+
+! end
+! if DEFFILE
+! encs.each do |e|
+<%e%>-$(arch).def:
+ echo EXPORTS > $@
+ echo <%EXPORT_PREFIX%>Init_<%e.upcase%> >> $@
+! end
! end
! encs.each do |e|
<%e%>.$(OBJEXT): <%e%>.c
@@ -27,6 +47,7 @@ $(ENCSODIR)/<%e%>.$(DLEXT): <%e%>.$(OBJEXT)
clean:
$(RM) $(ENCSOS)
+ $(RM) $(ENCDEFS)
$(RM) $(ENCOBJS)
distclean: clean
diff --git a/enc/euc_jp.c b/enc/euc_jp.c
index ea2a8e0..240e110 100644
--- a/enc/euc_jp.c
+++ b/enc/euc_jp.c
@@ -341,7 +341,7 @@ get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
}
-OnigEncodingType OnigEncodingEUC_JP = {
+OnigEncodingDefine(EUC_JP) = {
mbc_enc_len,
"EUC-JP", /* name */
3, /* max enc length */
diff --git a/enc/iso_8859_1.c b/enc/iso_8859_1.c
index fc2d93c..f7db6f9 100644
--- a/enc/iso_8859_1.c
+++ b/enc/iso_8859_1.c
@@ -254,7 +254,7 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
return FALSE;
}
-OnigEncodingType OnigEncodingISO_8859_1 = {
+OnigEncodingDefine(ISO_8859_1) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-1", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_10.c b/enc/iso_8859_10.c
index 976b428..20606d7 100644
--- a/enc/iso_8859_10.c
+++ b/enc/iso_8859_10.c
@@ -224,7 +224,7 @@ iso_8859_10_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_10 = {
+OnigEncodingDefine(ISO_8859_10) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-10", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_11.c b/enc/iso_8859_11.c
index 70645fa..463f52e 100644
--- a/enc/iso_8859_11.c
+++ b/enc/iso_8859_11.c
@@ -76,7 +76,7 @@ iso_8859_11_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding e
return FALSE;
}
-OnigEncodingType OnigEncodingISO_8859_11 = {
+OnigEncodingDefine(ISO_8859_11) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-11", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_13.c b/enc/iso_8859_13.c
index b3318b2..3a99115 100644
--- a/enc/iso_8859_13.c
+++ b/enc/iso_8859_13.c
@@ -213,7 +213,7 @@ iso_8859_13_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_13 = {
+OnigEncodingDefine(ISO_8859_13) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-13", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_14.c b/enc/iso_8859_14.c
index 030e030..d4afd9d 100644
--- a/enc/iso_8859_14.c
+++ b/enc/iso_8859_14.c
@@ -225,7 +225,7 @@ iso_8859_14_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_14 = {
+OnigEncodingDefine(ISO_8859_14) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-14", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_15.c b/enc/iso_8859_15.c
index 7650bf9..9deeec7 100644
--- a/enc/iso_8859_15.c
+++ b/enc/iso_8859_15.c
@@ -219,7 +219,7 @@ iso_8859_15_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_15 = {
+OnigEncodingDefine(ISO_8859_15) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-15", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_16.c b/enc/iso_8859_16.c
index 90de07d..76517f8 100644
--- a/enc/iso_8859_16.c
+++ b/enc/iso_8859_16.c
@@ -222,7 +222,7 @@ iso_8859_16_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_16 = {
+OnigEncodingDefine(ISO_8859_16) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-16", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_2.c b/enc/iso_8859_2.c
index e12962a..182a417 100644
--- a/enc/iso_8859_2.c
+++ b/enc/iso_8859_2.c
@@ -219,7 +219,7 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
return FALSE;
}
-OnigEncodingType OnigEncodingISO_8859_2 = {
+OnigEncodingDefine(ISO_8859_2) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-2", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_3.c b/enc/iso_8859_3.c
index 4188895..952483a 100644
--- a/enc/iso_8859_3.c
+++ b/enc/iso_8859_3.c
@@ -219,7 +219,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_3 = {
+OnigEncodingDefine(ISO_8859_3) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-3", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_4.c b/enc/iso_8859_4.c
index 0cddf19..a82ec3c 100644
--- a/enc/iso_8859_4.c
+++ b/enc/iso_8859_4.c
@@ -221,7 +221,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_4 = {
+OnigEncodingDefine(ISO_8859_4) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-4", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_5.c b/enc/iso_8859_5.c
index 187e6b1..69908a2 100644
--- a/enc/iso_8859_5.c
+++ b/enc/iso_8859_5.c
@@ -209,7 +209,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_5 = {
+OnigEncodingDefine(ISO_8859_5) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-5", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_6.c b/enc/iso_8859_6.c
index 1681506..b0da863 100644
--- a/enc/iso_8859_6.c
+++ b/enc/iso_8859_6.c
@@ -76,7 +76,7 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
return FALSE;
}
-OnigEncodingType OnigEncodingISO_8859_6 = {
+OnigEncodingDefine(ISO_8859_6) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-6", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_7.c b/enc/iso_8859_7.c
index 3790c71..fc825b1 100644
--- a/enc/iso_8859_7.c
+++ b/enc/iso_8859_7.c
@@ -206,7 +206,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
}
-OnigEncodingType OnigEncodingISO_8859_7 = {
+OnigEncodingDefine(ISO_8859_7) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-7", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_8.c b/enc/iso_8859_8.c
index ba1d486..61cd842 100644
--- a/enc/iso_8859_8.c
+++ b/enc/iso_8859_8.c
@@ -76,7 +76,7 @@ iso_8859_8_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding en
return FALSE;
}
-OnigEncodingType OnigEncodingISO_8859_8 = {
+OnigEncodingDefine(ISO_8859_8) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-8", /* name */
1, /* max enc length */
diff --git a/enc/iso_8859_9.c b/enc/iso_8859_9.c
index 1a51fad..95d92d9 100644
--- a/enc/iso_8859_9.c
+++ b/enc/iso_8859_9.c
@@ -213,7 +213,7 @@ iso_8859_9_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingISO_8859_9 = {
+OnigEncodingDefine(ISO_8859_9) = {
onigenc_single_byte_mbc_enc_len,
"ISO-8859-9", /* name */
1, /* max enc length */
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb
index c209201..799c4a0 100644
--- a/enc/make_encmake.rb
+++ b/enc/make_encmake.rb
@@ -14,11 +14,13 @@ else
BUILTIN_ENCS = []
end
+DEFFILE = (true if CONFIG["DLDFLAGS"].sub!(/\s+-def:\$\(DEFFILE\)\s+/, ' '))
+
mkin = File.read(File.join($srcdir, "Makefile.in"))
mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
if File.exist?(depend = File.join($srcdir, "depend"))
tmp = ''
- eval(serb(File.read(depend), 'tmp'))
+ eval(serb(File.read(depend), 'tmp'), binding, depend)
mkin << "\n#### depend ####\n\n" << depend_rules(tmp).join
end
open(ARGV[0], 'wb') {|f|
diff --git a/enc/sjis.c b/enc/sjis.c
index ff7da34..e3d656f 100644
--- a/enc/sjis.c
+++ b/enc/sjis.c
@@ -351,7 +351,7 @@ get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
}
}
-OnigEncodingType OnigEncodingSJIS = {
+OnigEncodingDefine(SJIS) = {
mbc_enc_len,
"Shift_JIS", /* name */
2, /* max byte length */
diff --git a/enc/utf8.c b/enc/utf8.c
index 24a3854..9f278b5 100644
--- a/enc/utf8.c
+++ b/enc/utf8.c
@@ -486,7 +486,7 @@ utf8_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
-OnigEncodingType OnigEncodingUTF8 = {
+OnigEncodingDefine(UTF8) = {
utf8_mbc_enc_len,
"UTF-8", /* name */
6, /* max byte length */
diff --git a/regenc.h b/regenc.h
index b9d96a6..2512985 100644
--- a/regenc.h
+++ b/regenc.h
@@ -177,5 +177,21 @@ ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
(ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
+#ifdef ONIG_ENC_REGISTER
+extern int ONIG_ENC_REGISTER(const char *, OnigEncodingType*);
+#define OnigEncodingName(n) encoding_##n
+#define OnigEncodingDeclare(n) static OnigEncodingType OnigEncodingName(n)
+#define OnigEncodingDefine(n) \
+ OnigEncodingDeclare(n); \
+ void Init_##n(void) { \
+ ONIG_ENC_REGISTER(OnigEncodingName(n).name, \
+ &OnigEncodingName(n)); \
+ } \
+ OnigEncodingDeclare(n)
+#else
+#define OnigEncodingName(n) OnigEncoding##n
+#define OnigEncodingDeclare(n) OnigEncodingType OnigEncodingName(n)
+#define OnigEncodingDefine(n) OnigEncodingDeclare(n)
+#endif
#endif /* REGENC_H */