summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-15 09:56:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-15 09:56:59 +0000
commitf2bd108d8df6def3ff39674337eb4d40cfb25e3b (patch)
tree7520d2b73558bb8a6a4973eaf86f861d2c4f3b9b
parentc5851d1d6906e130bbb156d9ace962c59c8b0086 (diff)
* configure.in (enc/Makefile): add external encoding objects list.
* common.mk (BUILTIN_ENCOBJS): renamed from ENCOBJS. * Makefile.in (BUILTIN_ENCOBJS): substitued by autoconf. * enc/Makefile.in: new file to compile external encoding sources. * encoding.c (rb_enc_find_index): auto-load external encoding objects as "ext/ENCODING_NAME". [ruby-dev:32606] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--Makefile.in2
-rw-r--r--common.mk8
-rw-r--r--configure.in33
-rw-r--r--enc/Makefile.in33
-rw-r--r--encoding.c24
6 files changed, 103 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ccc556543..e995a7f76e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sat Dec 15 18:56:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * configure.in (enc/Makefile): add external encoding objects list.
+
+ * common.mk (BUILTIN_ENCOBJS): renamed from ENCOBJS.
+
+ * Makefile.in (BUILTIN_ENCOBJS): substitued by autoconf.
+
+ * enc/Makefile.in: new file to compile external encoding sources.
+
+ * encoding.c (rb_enc_find_index): auto-load external encoding objects
+ as "ext/ENCODING_NAME". [ruby-dev:32606]
+
Sat Dec 15 13:04:30 2007 Tanaka Akira <akr@fsij.org>
* vm_core.h (rb_thread_t): new member machine_stack_maxsize and
diff --git a/Makefile.in b/Makefile.in
index 702fa518d6..8dbb27f74f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -51,6 +51,7 @@ DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
SOLIBS = @SOLIBS@
MAINLIBS = @MAINLIBS@
MINIOBJS = @MINIOBJS@ miniprelude.$(OBJEXT)
+BUILTIN_ENCOBJS = @BUILTIN_ENCOBJS@
RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
RUBY_SO_NAME=@RUBY_SO_NAME@
@@ -93,6 +94,7 @@ ASFLAGS = @ASFLAGS@
OBJEXT = @OBJEXT@
ASMEXT = S
+DLEXT = @DLEXT@
MANTYPE = @MANTYPE@
INSTALLED_LIST= .installed.list
diff --git a/common.mk b/common.mk
index 1f2f25e96f..de96ed77dc 100644
--- a/common.mk
+++ b/common.mk
@@ -18,12 +18,6 @@ MAINOBJ = main.$(OBJEXT)
EXTOBJS =
DLDOBJS = $(DMYEXT)
-ENCOBJS = ascii.$(OBJEXT) \
- euc_jp.$(OBJEXT) \
- sjis.$(OBJEXT) \
- unicode.$(OBJEXT) \
- utf8.$(OBJEXT)
-
COMMONOBJS = array.$(OBJEXT) \
bignum.$(OBJEXT) \
class.$(OBJEXT) \
@@ -79,7 +73,7 @@ COMMONOBJS = array.$(OBJEXT) \
thread.$(OBJEXT) \
cont.$(OBJEXT) \
id.$(OBJEXT) \
- $(ENCOBJS) \
+ $(BUILTIN_ENCOBJS) \
$(MISSING)
OBJS = dln.$(OBJEXT) \
diff --git a/configure.in b/configure.in
index 469de63449..fb0994cb60 100644
--- a/configure.in
+++ b/configure.in
@@ -1203,6 +1203,7 @@ n=`expr "$DLEXT2" : '.*'`; test "$n" -gt "$len" && len=$n
AC_DEFINE_UNQUOTED(DLEXT_MAXLEN, `expr $len + 1`)
test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT")
test ".$DLEXT2" = "." || AC_DEFINE_UNQUOTED(DLEXT2, ".$DLEXT2")
+AC_SUBST(DLEXT)
AC_SUBST(STRIP)dnl
if test "$with_dln_a_out" = yes; then
@@ -1578,7 +1579,7 @@ AC_SUBST(EXPORT_PREFIX)
AC_SUBST(MINIOBJS)
AC_SUBST(THREAD_MODEL)
-MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
+MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'` enc/GNUmakefile"
MAKEFILES="`echo $MAKEFILES`"
AC_SUBST(MAKEFILES)
@@ -1734,7 +1735,37 @@ else
fi
tr -d '\015' < largefile.h > confdefs.h
+test -d enc || mkdir enc
+BUILTIN_ENCS="`sed -n '/^BUILTIN_ENCS[ ]*=/{s///;:l;/\\\\$/N;s/\\\\\\n/ /;t l;p}' \"${srcdir}/enc/Makefile.in\"`"
+BUILTIN_ENCS="`echo $BUILTIN_ENCS`"
+EXTERNAL_ENCS=
+for e in "${srcdir}/enc"/*.c; do
+ e=`basename "$e" .c`
+ case " $BUILTIN_ENCS " in
+ *" $e "*) ;;
+ *) EXTERNAL_ENCS="$EXTERNAL_ENCS $e";;
+ esac
+done
+echo $EX
+BUILTIN_ENCOBJS=
+for e in $BUILTIN_ENCS; do BUILTIN_ENCOBJS="$BUILTIN_ENCOBJS $e"'.$(OBJEXT)'; done
+EXTERNAL_ENCOBJS=
+for e in $EXTERNAL_ENCS; do EXTERNAL_ENCOBJS="$EXTERNAL_ENCOBJS $e"'.$(OBJEXT)'; done
+ENCSOS=
+for e in $EXTERNAL_ENCS; do ENCSOS="$ENCSOS "'$(ENCSODIR)/'"$e"'.$(DLEXT)'; done
+
+AC_SUBST(BUILTIN_ENCOBJS)
+AC_SUBST(EXTERNAL_ENCOBJS)
+AC_SUBST(ENCSOS)
+
AC_CONFIG_FILES($FIRSTMAKEFILE)
+AC_CONFIG_FILES(enc/Makefile, [{
+ for e in $ENCS; do
+ echo ''
+ echo '$(ENCSODIR)/'"$e"'.$(DLEXT): '"$e"'.$(OBJEXT)'
+ echo ' $(LDSHARED) $(DLDFLAGS) $< $(OUTFLAG)$''@'
+ done >> enc/Makefile
+}], [ENCS="$EXTERNAL_ENCS"])
AC_CONFIG_FILES(Makefile, [{
sed '/^MISSING/s/\$U\././g' Makefile
echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
diff --git a/enc/Makefile.in b/enc/Makefile.in
new file mode 100644
index 0000000000..86ed944262
--- /dev/null
+++ b/enc/Makefile.in
@@ -0,0 +1,33 @@
+srcdir = @srcdir@
+top_srcdir = $(srcdir:/enc=)
+arch = @arch@
+EXTOUT = $(top_srcdir)/@EXTOUT@
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(EXTOUT)/include/$(arch)
+VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(top_srcdir):$(srcdir)
+ENCSODIR = $(EXTOUT)/$(arch)/enc
+DLEXT = @DLEXT@
+OBJEXT = @OBJEXT@
+
+BUILTIN_ENCS = ascii \
+ euc_jp sjis \
+ unicode utf8
+
+ENCOBJS = @EXTERNAL_ENCOBJS@
+ENCSOS = @ENCSOS@
+empty =
+CC = @CC@
+OUTFLAG = @OUTFLAG@$(empty)
+CFLAGS = @CFLAGS@ @ARCH_FLAG@
+XCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir) @XCFLAGS@
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
+XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
+LIBS = @LIBS@ $(EXTLIBS)
+LDSHARED = @LDSHARED@
+DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
+
+all: $(ENCOBJS) $(ENCSOS)
+
+.c.@OBJEXT@:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c $<
diff --git a/encoding.c b/encoding.c
index b2d9359694..325ee7a73b 100644
--- a/encoding.c
+++ b/encoding.c
@@ -155,7 +155,7 @@ enc_register(const char *name, rb_encoding *encoding)
}
static VALUE enc_based_encoding(VALUE);
-#define rb_enc_registered(name) rb_enc_find_index(name)
+int rb_enc_registered(const char *name);
int
rb_enc_register(const char *name, rb_encoding *encoding)
@@ -252,7 +252,7 @@ rb_enc_from_index(int index)
}
int
-rb_enc_find_index(const char *name)
+rb_enc_registered(const char *name)
{
int i;
st_data_t alias = 0;
@@ -278,6 +278,26 @@ rb_enc_find_index(const char *name)
return -1;
}
+static VALUE
+require_enc(VALUE enclib)
+{
+ return rb_require_safe(enclib, rb_safe_level());
+}
+
+int
+rb_enc_find_index(const char *name)
+{
+ int i = rb_enc_registered(name);
+ if (i < 0) {
+ VALUE enclib = rb_sprintf("enc/%s", name);
+ OBJ_FREEZE(enclib);
+ if (RTEST(rb_protect(require_enc, enclib, 0)))
+ i = rb_enc_registered(name);
+ rb_set_errinfo(Qnil);
+ }
+ return i;
+}
+
rb_encoding *
rb_enc_find(const char *name)
{