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

ruby-changes:34463

From: nobu <ko1@a...>
Date: Wed, 25 Jun 2014 03:02:44 +0900 (JST)
Subject: [ruby-changes:34463] nobu:r46544 (trunk): hash.c: env_str_transcode

nobu	2014-06-25 03:02:31 +0900 (Wed, 25 Jun 2014)

  New Revision: 46544

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

  Log:
    hash.c: env_str_transcode
    
    * hash.c (env_str_transcode): convert with replacing invalid/undef
      characters, on Windows.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 46543)
+++ hash.c	(revision 46544)
@@ -2500,13 +2500,20 @@ extern char **environ; https://github.com/ruby/ruby/blob/trunk/hash.c#L2500
 #define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0)
 #endif
 
+#ifdef _WIN32
+static VALUE
+env_str_transcode(VALUE str, rb_encoding *enc)
+{
+    return rb_str_conv_enc_opts(str, rb_utf8_encoding(), enc,
+				ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE, Qnil);
+}
+#endif
+
 static VALUE
 env_str_new(const char *ptr, long len)
 {
 #ifdef _WIN32
-    VALUE str = rb_str_conv_enc_opts(rb_str_new(ptr, len),
-				     rb_utf8_encoding(), rb_locale_encoding(),
-				     ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE, Qnil);
+    VALUE str = env_str_transcode(rb_str_new(ptr, len), rb_locale_encoding());
 #else
     VALUE str = rb_locale_str_new(ptr, len);
 #endif
@@ -2519,9 +2526,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/hash.c#L2526
 env_path_str_new(const char *ptr)
 {
 #ifdef _WIN32
-    VALUE str = rb_str_conv_enc_opts(rb_str_new_cstr(ptr),
-				     rb_utf8_encoding(), rb_filesystem_encoding(),
-				     ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE, Qnil);
+    VALUE str = env_str_transcode(rb_str_new_cstr(ptr), rb_filesystem_encoding());
 #else
     VALUE str = rb_filesystem_str_new_cstr(ptr);
 #endif

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

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