summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-14 17:47:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-14 17:47:25 +0000
commit5f2080048e6bf76b647bec00c4b9cb1c7ec79ab2 (patch)
treeb8b5a58d3d573437a24f9a14158905713c93554e
parent30486375713988a02c8463185e2b4613e042aaea (diff)
localeinit.c: split
* localeinit.c (rb_locale_charmap, Init_enc_set_filesystem_encoding): move from encoding.c. * miniinit.c (rb_locale_charmap, Init_enc_set_filesystem_encoding): define miniruby specific functions only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--common.mk13
-rw-r--r--dmyencoding.c2
-rw-r--r--dmyloadpath.c2
-rw-r--r--encoding.c58
-rw-r--r--localeinit.c65
-rw-r--r--miniinit.c30
7 files changed, 114 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c25d726aad..0ea6e738524 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Jul 15 02:47:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * localeinit.c (rb_locale_charmap, Init_enc_set_filesystem_encoding):
+ move from encoding.c.
+
+ * miniinit.c (rb_locale_charmap, Init_enc_set_filesystem_encoding):
+ define miniruby specific functions only.
+
Mon Jul 15 02:32:58 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_enc_init): no longer needs NO_PRESERVED_ENCODING.
diff --git a/common.mk b/common.mk
index 89c042e767e..d4dc2572d0d 100644
--- a/common.mk
+++ b/common.mk
@@ -33,7 +33,7 @@ MAINOBJ = $(NORMALMAINOBJ)
EXTOBJS =
DLDOBJS = $(DMYEXT)
EXTSOLIBS =
-MINIOBJS = $(ARCHMINIOBJS) dmyencoding.$(OBJEXT) dmyloadpath.$(OBJEXT) miniprelude.$(OBJEXT)
+MINIOBJS = $(ARCHMINIOBJS) miniinit.$(OBJEXT) miniprelude.$(OBJEXT)
ENC_MK = enc.mk
COMMONOBJS = array.$(OBJEXT) \
@@ -43,6 +43,7 @@ COMMONOBJS = array.$(OBJEXT) \
complex.$(OBJEXT) \
dir.$(OBJEXT) \
dln_find.$(OBJEXT) \
+ encoding.$(OBJEXT) \
enum.$(OBJEXT) \
enumerator.$(OBJEXT) \
error.$(OBJEXT) \
@@ -99,7 +100,7 @@ COMMONOBJS = array.$(OBJEXT) \
$(MISSING)
EXPORTOBJS = $(DLNOBJ) \
- encoding.$(OBJEXT) \
+ localeinit.$(OBJEXT) \
loadpath.$(OBJEXT) \
$(COMMONOBJS)
@@ -659,9 +660,6 @@ dln.$(OBJEXT): {$(VPATH)}dln.c {$(VPATH)}dln.h $(RUBY_H_INCLUDES)
dln_find.$(OBJEXT): {$(VPATH)}dln_find.c {$(VPATH)}dln.h $(RUBY_H_INCLUDES)
dmydln.$(OBJEXT): {$(VPATH)}dmydln.c $(RUBY_H_INCLUDES)
dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
-dmyencoding.$(OBJEXT): {$(VPATH)}dmyencoding.c $(RUBY_H_INCLUDES) \
- {$(VPATH)}regenc.h {$(VPATH)}util.h $(ENCODING_H_INCLUDES) \
- {$(VPATH)}encoding.c {$(VPATH)}internal.h
encoding.$(OBJEXT): {$(VPATH)}encoding.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES) {$(VPATH)}regenc.h {$(VPATH)}util.h \
{$(VPATH)}internal.h
@@ -777,7 +775,10 @@ version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES) \
loadpath.$(OBJEXT): {$(VPATH)}loadpath.c $(RUBY_H_INCLUDES) \
$(srcdir)/include/ruby/version.h $(srcdir)/version.h {$(VPATH)}config.h \
verconf.h
-dmyloadpath.$(OBJEXT): {$(VPATH)}dmyloadpath.c
+localeinit.$(OBJEXT): {$(VPATH)}localeinit.c $(RUBY_H_INCLUDES) \
+ $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h
+miniinit.$(OBJEXT): {$(VPATH)}miniinit.c $(RUBY_H_INCLUDES) \
+ $(ENCODING_H_INCLUDES)
compile.$(OBJEXT): {$(VPATH)}compile.c {$(VPATH)}iseq.h \
$(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}insns.inc \
diff --git a/dmyencoding.c b/dmyencoding.c
deleted file mode 100644
index 1bd1106e696..00000000000
--- a/dmyencoding.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define NO_LOCALE_CHARMAP 1
-#include "encoding.c"
diff --git a/dmyloadpath.c b/dmyloadpath.c
deleted file mode 100644
index eaa607ad957..00000000000
--- a/dmyloadpath.c
+++ /dev/null
@@ -1,2 +0,0 @@
-const char ruby_exec_prefix[] = "";
-const char ruby_initial_load_paths[] = "";
diff --git a/encoding.c b/encoding.c
index 1d17e05e147..075c1abd656 100644
--- a/encoding.c
+++ b/encoding.c
@@ -14,14 +14,6 @@
#include "internal.h"
#include "regenc.h"
#include <ctype.h>
-#ifndef NO_LOCALE_CHARMAP
-#ifdef __CYGWIN__
-#include <windows.h>
-#endif
-#ifdef HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-#endif
#include "ruby/util.h"
#undef rb_ascii8bit_encindex
@@ -1269,25 +1261,6 @@ rb_locale_encoding(void)
return rb_enc_from_index(rb_locale_encindex());
}
-static int
-enc_set_filesystem_encoding(void)
-{
- int idx;
-#if defined NO_LOCALE_CHARMAP
- idx = rb_enc_to_index(rb_default_external_encoding());
-#elif defined _WIN32 || defined __CYGWIN__
- char cp[sizeof(int) * 8 / 3 + 4];
- snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
- idx = rb_enc_find_index(cp);
- if (idx < 0) idx = ENCINDEX_ASCII;
-#else
- idx = rb_enc_to_index(rb_default_external_encoding());
-#endif
-
- enc_alias_internal("filesystem", idx);
- return idx;
-}
-
int
rb_filesystem_encindex(void)
{
@@ -1310,6 +1283,8 @@ struct default_encoding {
static struct default_encoding default_external = {0};
+extern int Init_enc_set_filesystem_encoding(void);
+
static int
enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const char *name)
{
@@ -1332,7 +1307,7 @@ enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const cha
}
if (def == &default_external)
- enc_set_filesystem_encoding();
+ enc_alias_internal("filesystem", Init_enc_set_filesystem_encoding());
return overridden;
}
@@ -1529,32 +1504,7 @@ set_default_internal(VALUE klass, VALUE encoding)
*
*/
VALUE
-rb_locale_charmap(VALUE klass)
-{
-#if defined NO_LOCALE_CHARMAP
- return rb_usascii_str_new2("ASCII-8BIT");
-#elif defined _WIN32 || defined __CYGWIN__
- const char *codeset = 0;
- char cp[sizeof(int) * 3 + 4];
-# ifdef __CYGWIN__
- const char *nl_langinfo_codeset(void);
- codeset = nl_langinfo_codeset();
-# endif
- if (!codeset) {
- UINT codepage = GetConsoleCP();
- if (!codepage) codepage = GetACP();
- snprintf(cp, sizeof(cp), "CP%d", codepage);
- codeset = cp;
- }
- return rb_usascii_str_new2(codeset);
-#elif defined HAVE_LANGINFO_H
- char *codeset;
- codeset = nl_langinfo(CODESET);
- return rb_usascii_str_new2(codeset);
-#else
- return Qnil;
-#endif
-}
+rb_locale_charmap(VALUE klass);
static void
set_encoding_const(const char *name, rb_encoding *enc)
diff --git a/localeinit.c b/localeinit.c
new file mode 100644
index 00000000000..369013fc26d
--- /dev/null
+++ b/localeinit.c
@@ -0,0 +1,65 @@
+/**********************************************************************
+
+ localeinit.c -
+
+ $Author$
+ created at: Thu Jul 11 22:09:57 JST 2013
+
+ Copyright (C) 2013 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+#include "internal.h"
+#ifdef __CYGWIN__
+#include <windows.h>
+#endif
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+
+VALUE
+rb_locale_charmap(VALUE klass)
+{
+#if defined NO_LOCALE_CHARMAP
+# error NO_LOCALE_CHARMAP defined
+#elif defined _WIN32 || defined __CYGWIN__
+ const char *codeset = 0;
+ char cp[sizeof(int) * 3 + 4];
+# ifdef __CYGWIN__
+ const char *nl_langinfo_codeset(void);
+ codeset = nl_langinfo_codeset();
+# endif
+ if (!codeset) {
+ UINT codepage = GetConsoleCP();
+ if (!codepage) codepage = GetACP();
+ snprintf(cp, sizeof(cp), "CP%d", codepage);
+ codeset = cp;
+ }
+ return rb_usascii_str_new2(codeset);
+#elif defined HAVE_LANGINFO_H
+ char *codeset;
+ codeset = nl_langinfo(CODESET);
+ return rb_usascii_str_new2(codeset);
+#else
+ return Qnil;
+#endif
+}
+
+int
+Init_enc_set_filesystem_encoding(void)
+{
+ int idx;
+#if defined NO_LOCALE_CHARMAP
+# error NO_LOCALE_CHARMAP defined
+#elif defined _WIN32 || defined __CYGWIN__
+ char cp[sizeof(int) * 8 / 3 + 4];
+ snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
+ idx = rb_enc_find_index(cp);
+ if (idx < 0) idx = ENCINDEX_ASCII;
+#else
+ idx = rb_enc_to_index(rb_default_external_encoding());
+#endif
+ return idx;
+}
diff --git a/miniinit.c b/miniinit.c
new file mode 100644
index 00000000000..bc6138a7748
--- /dev/null
+++ b/miniinit.c
@@ -0,0 +1,30 @@
+/**********************************************************************
+
+ miniinit.c -
+
+ $Author$
+ created at: Thu Jul 11 22:09:57 JST 2013
+
+ Copyright (C) 2013 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+/* loadpath.c */
+const char ruby_exec_prefix[] = "";
+const char ruby_initial_load_paths[] = "";
+
+/* localeinit.c */
+VALUE
+rb_locale_charmap(VALUE klass)
+{
+ return rb_usascii_str_new2("ASCII-8BIT");
+}
+
+int
+Init_enc_set_filesystem_encoding(void)
+{
+ return rb_enc_to_index(rb_default_external_encoding());
+}