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
This commit is contained in:
parent
3048637571
commit
5f2080048e
@ -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>
|
Mon Jul 15 02:32:58 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* encoding.c (rb_enc_init): no longer needs NO_PRESERVED_ENCODING.
|
* encoding.c (rb_enc_init): no longer needs NO_PRESERVED_ENCODING.
|
||||||
|
13
common.mk
13
common.mk
@ -33,7 +33,7 @@ MAINOBJ = $(NORMALMAINOBJ)
|
|||||||
EXTOBJS =
|
EXTOBJS =
|
||||||
DLDOBJS = $(DMYEXT)
|
DLDOBJS = $(DMYEXT)
|
||||||
EXTSOLIBS =
|
EXTSOLIBS =
|
||||||
MINIOBJS = $(ARCHMINIOBJS) dmyencoding.$(OBJEXT) dmyloadpath.$(OBJEXT) miniprelude.$(OBJEXT)
|
MINIOBJS = $(ARCHMINIOBJS) miniinit.$(OBJEXT) miniprelude.$(OBJEXT)
|
||||||
ENC_MK = enc.mk
|
ENC_MK = enc.mk
|
||||||
|
|
||||||
COMMONOBJS = array.$(OBJEXT) \
|
COMMONOBJS = array.$(OBJEXT) \
|
||||||
@ -43,6 +43,7 @@ COMMONOBJS = array.$(OBJEXT) \
|
|||||||
complex.$(OBJEXT) \
|
complex.$(OBJEXT) \
|
||||||
dir.$(OBJEXT) \
|
dir.$(OBJEXT) \
|
||||||
dln_find.$(OBJEXT) \
|
dln_find.$(OBJEXT) \
|
||||||
|
encoding.$(OBJEXT) \
|
||||||
enum.$(OBJEXT) \
|
enum.$(OBJEXT) \
|
||||||
enumerator.$(OBJEXT) \
|
enumerator.$(OBJEXT) \
|
||||||
error.$(OBJEXT) \
|
error.$(OBJEXT) \
|
||||||
@ -99,7 +100,7 @@ COMMONOBJS = array.$(OBJEXT) \
|
|||||||
$(MISSING)
|
$(MISSING)
|
||||||
|
|
||||||
EXPORTOBJS = $(DLNOBJ) \
|
EXPORTOBJS = $(DLNOBJ) \
|
||||||
encoding.$(OBJEXT) \
|
localeinit.$(OBJEXT) \
|
||||||
loadpath.$(OBJEXT) \
|
loadpath.$(OBJEXT) \
|
||||||
$(COMMONOBJS)
|
$(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)
|
dln_find.$(OBJEXT): {$(VPATH)}dln_find.c {$(VPATH)}dln.h $(RUBY_H_INCLUDES)
|
||||||
dmydln.$(OBJEXT): {$(VPATH)}dmydln.c $(RUBY_H_INCLUDES)
|
dmydln.$(OBJEXT): {$(VPATH)}dmydln.c $(RUBY_H_INCLUDES)
|
||||||
dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
|
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.$(OBJEXT): {$(VPATH)}encoding.c $(RUBY_H_INCLUDES) \
|
||||||
$(ENCODING_H_INCLUDES) {$(VPATH)}regenc.h {$(VPATH)}util.h \
|
$(ENCODING_H_INCLUDES) {$(VPATH)}regenc.h {$(VPATH)}util.h \
|
||||||
{$(VPATH)}internal.h
|
{$(VPATH)}internal.h
|
||||||
@ -777,7 +775,10 @@ version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES) \
|
|||||||
loadpath.$(OBJEXT): {$(VPATH)}loadpath.c $(RUBY_H_INCLUDES) \
|
loadpath.$(OBJEXT): {$(VPATH)}loadpath.c $(RUBY_H_INCLUDES) \
|
||||||
$(srcdir)/include/ruby/version.h $(srcdir)/version.h {$(VPATH)}config.h \
|
$(srcdir)/include/ruby/version.h $(srcdir)/version.h {$(VPATH)}config.h \
|
||||||
verconf.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 \
|
compile.$(OBJEXT): {$(VPATH)}compile.c {$(VPATH)}iseq.h \
|
||||||
$(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}insns.inc \
|
$(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}insns.inc \
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
#define NO_LOCALE_CHARMAP 1
|
|
||||||
#include "encoding.c"
|
|
@ -1,2 +0,0 @@
|
|||||||
const char ruby_exec_prefix[] = "";
|
|
||||||
const char ruby_initial_load_paths[] = "";
|
|
58
encoding.c
58
encoding.c
@ -14,14 +14,6 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "regenc.h"
|
#include "regenc.h"
|
||||||
#include <ctype.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"
|
#include "ruby/util.h"
|
||||||
|
|
||||||
#undef rb_ascii8bit_encindex
|
#undef rb_ascii8bit_encindex
|
||||||
@ -1269,25 +1261,6 @@ rb_locale_encoding(void)
|
|||||||
return rb_enc_from_index(rb_locale_encindex());
|
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
|
int
|
||||||
rb_filesystem_encindex(void)
|
rb_filesystem_encindex(void)
|
||||||
{
|
{
|
||||||
@ -1310,6 +1283,8 @@ struct default_encoding {
|
|||||||
|
|
||||||
static struct default_encoding default_external = {0};
|
static struct default_encoding default_external = {0};
|
||||||
|
|
||||||
|
extern int Init_enc_set_filesystem_encoding(void);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const char *name)
|
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)
|
if (def == &default_external)
|
||||||
enc_set_filesystem_encoding();
|
enc_alias_internal("filesystem", Init_enc_set_filesystem_encoding());
|
||||||
|
|
||||||
return overridden;
|
return overridden;
|
||||||
}
|
}
|
||||||
@ -1529,32 +1504,7 @@ set_default_internal(VALUE klass, VALUE encoding)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_locale_charmap(VALUE klass)
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_encoding_const(const char *name, rb_encoding *enc)
|
set_encoding_const(const char *name, rb_encoding *enc)
|
||||||
|
65
localeinit.c
Normal file
65
localeinit.c
Normal file
@ -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;
|
||||||
|
}
|
30
miniinit.c
Normal file
30
miniinit.c
Normal file
@ -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());
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user