[前][次][番号順一覧][スレッド一覧]

ruby-changes:9770

From: nobu <ko1@a...>
Date: Sun, 4 Jan 2009 15:41:58 +0900 (JST)
Subject: [ruby-changes:9770] Ruby:r21311 (trunk): * encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses

nobu	2009-01-04 15:41:43 +0900 (Sun, 04 Jan 2009)

  New Revision: 21311

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21311

  Log:
    * encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses
      codepage on cygwin.  [ruby-core:20994]

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/encoding.c

Index: encoding.c
===================================================================
--- encoding.c	(revision 21310)
+++ encoding.c	(revision 21311)
@@ -13,11 +13,19 @@
 #include "ruby/encoding.h"
 #include "regenc.h"
 #include <ctype.h>
-#ifdef HAVE_LANGINFO_H
+#ifndef NO_LOCALE_CHARMAP
+#if defined __CYGWIN__
+#include <windows.h>
+#elif defined HAVE_LANGINFO_H
 #include <langinfo.h>
 #endif
+#endif
 #include "ruby/util.h"
 
+#if defined _WIN32 || defined __CYGWIN__
+#define USE_CODEPAGE_LOCALE 1
+#endif
+
 static ID id_encoding;
 VALUE rb_cEncoding;
 static VALUE rb_encoding_list;
@@ -1025,7 +1033,7 @@
 rb_filesystem_encoding(void)
 {
     rb_encoding *enc;
-#if defined _WIN32
+#if defined USE_CODEPAGE_LOCALE
     enc = rb_locale_encoding();
 #elif defined __APPLE__
     enc = rb_enc_find("UTF8-MAC");
@@ -1204,12 +1212,12 @@
 {
 #if defined NO_LOCALE_CHARMAP
     return rb_usascii_str_new2("ASCII-8BIT");
+#elif defined USE_CODEPAGE_LOCALE
+    return rb_sprintf("CP%d", GetACP());
 #elif defined HAVE_LANGINFO_H
     char *codeset;
     codeset = nl_langinfo(CODESET);
     return rb_usascii_str_new2(codeset);
-#elif defined _WIN32
-    return rb_sprintf("CP%d", GetACP());
 #else
     return Qnil;
 #endif
Index: configure.in
===================================================================
--- configure.in	(revision 21310)
+++ configure.in	(revision 21311)
@@ -565,7 +565,8 @@
 		esac
 		LIBS="$LIBS" # m lib is include in root under BeOS/Haiku
 		;;
-cygwin*)	;;
+cygwin*)	ac_cv_header_langinfo_h=no # nl_langinfo(CODESET) returns US-ASCII regardless locale. 
+		;;
 mingw*)		LIBS="-lshell32 -lws2_32 $LIBS"
 		ac_cv_header_a_out_h=no
 		ac_cv_header_pwd_h=no
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21310)
+++ ChangeLog	(revision 21311)
@@ -1,3 +1,8 @@
+Sun Jan  4 15:41:37 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses
+	  codepage on cygwin.  [ruby-core:20994]
+
 Sun Jan  4 11:58:43 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* numeric.c (ruby_float_step): extracted from num_step().

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]