ruby-changes:29921
From: nobu <ko1@a...>
Date: Mon, 15 Jul 2013 02:47:40 +0900 (JST)
Subject: [ruby-changes:29921] nobu:r41973 (trunk): localeinit.c: split
nobu 2013-07-15 02:47:25 +0900 (Mon, 15 Jul 2013) New Revision: 41973 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41973 Log: 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. Added files: trunk/localeinit.c trunk/miniinit.c Removed files: trunk/dmyencoding.c trunk/dmyloadpath.c Modified files: trunk/ChangeLog trunk/common.mk trunk/encoding.c Index: dmyloadpath.c =================================================================== --- dmyloadpath.c (revision 41972) +++ dmyloadpath.c (revision 41973) @@ -1,2 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/dmyloadpath.c#L0 -const char ruby_exec_prefix[] = ""; -const char ruby_initial_load_paths[] = ""; Index: dmyencoding.c =================================================================== --- dmyencoding.c (revision 41972) +++ dmyencoding.c (revision 41973) @@ -1,2 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/dmyencoding.c#L0 -#define NO_LOCALE_CHARMAP 1 -#include "encoding.c" Index: encoding.c =================================================================== --- encoding.c (revision 41972) +++ encoding.c (revision 41973) @@ -14,14 +14,6 @@ https://github.com/ruby/ruby/blob/trunk/encoding.c#L14 #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) https://github.com/ruby/ruby/blob/trunk/encoding.c#L1261 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 { https://github.com/ruby/ruby/blob/trunk/encoding.c#L1283 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_ https://github.com/ruby/ruby/blob/trunk/encoding.c#L1307 } 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 https://github.com/ruby/ruby/blob/trunk/encoding.c#L1504 * */ 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) Index: ChangeLog =================================================================== --- ChangeLog (revision 41972) +++ ChangeLog (revision 41973) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 15 02:47:09 2013 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * encoding.c (rb_enc_init): no longer needs NO_PRESERVED_ENCODING. Index: miniinit.c =================================================================== --- miniinit.c (revision 0) +++ miniinit.c (revision 41973) @@ -0,0 +1,30 @@ https://github.com/ruby/ruby/blob/trunk/miniinit.c#L1 +/********************************************************************** + + 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()); +} Property changes on: miniinit.c ___________________________________________________________________ Added: svn:eol-style + LF Index: localeinit.c =================================================================== --- localeinit.c (revision 0) +++ localeinit.c (revision 41973) @@ -0,0 +1,65 @@ https://github.com/ruby/ruby/blob/trunk/localeinit.c#L1 +/********************************************************************** + + 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; +} Property changes on: localeinit.c ___________________________________________________________________ Added: svn:eol-style + LF Index: common.mk =================================================================== --- common.mk (revision 41972) +++ common.mk (revision 41973) @@ -33,7 +33,7 @@ MAINOBJ = $(NORMALMAINOBJ) https://github.com/ruby/ruby/blob/trunk/common.mk#L33 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) \ https://github.com/ruby/ruby/blob/trunk/common.mk#L43 complex.$(OBJEXT) \ dir.$(OBJEXT) \ dln_find.$(OBJEXT) \ + encoding.$(OBJEXT) \ enum.$(OBJEXT) \ enumerator.$(OBJEXT) \ error.$(OBJEXT) \ @@ -99,7 +100,7 @@ COMMONOBJS = array.$(OBJEXT) \ https://github.com/ruby/ruby/blob/trunk/common.mk#L100 $(MISSING) EXPORTOBJS = $(DLNOBJ) \ - encoding.$(OBJEXT) \ + localeinit.$(OBJEXT) \ loadpath.$(OBJEXT) \ $(COMMONOBJS) @@ -659,9 +660,6 @@ dln.$(OBJEXT): {$(VPATH)}dln.c {$(VPATH) https://github.com/ruby/ruby/blob/trunk/common.mk#L660 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 $ https://github.com/ruby/ruby/blob/trunk/common.mk#L775 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 \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/