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

ruby-changes:36570

From: nobu <ko1@a...>
Date: Sun, 30 Nov 2014 00:02:45 +0900 (JST)
Subject: [ruby-changes:36570] nobu:r48651 (trunk): ruby.c: translit_char_bin

nobu	2014-11-30 00:02:25 +0900 (Sun, 30 Nov 2014)

  New Revision: 48651

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

  Log:
    ruby.c: translit_char_bin
    
    * ruby.c (translit_char_bin): should not use code page dependent
      CharNext on UTF-8 string.  [ruby-dev:48752] [Bug #10555]

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48650)
+++ ChangeLog	(revision 48651)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov 30 00:02:22 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (translit_char_bin): should not use code page dependent
+	  CharNext on UTF-8 string.  [ruby-dev:48752] [Bug #10555]
+
 Sat Nov 29 16:53:14 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* ruby.c (ruby_set_argv): convert argv from UTF-8.
Index: ruby.c
===================================================================
--- ruby.c	(revision 48650)
+++ ruby.c	(revision 48651)
@@ -329,6 +329,16 @@ rb_libruby_handle(void) https://github.com/ruby/ruby/blob/trunk/ruby.c#L329
     return libruby;
 }
 
+static inline void
+translit_char_bin(char *p, int from, int to)
+{
+    while (*p) {
+	if ((unsigned char)*p == from)
+	    *p = to;
+	p++;
+    }
+}
+
 # define UTF8_PATH 1
 #endif
 
@@ -1338,7 +1348,10 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby.c#L1348
 
     opt->script_name = rb_str_new_cstr(opt->script);
     opt->script = RSTRING_PTR(opt->script_name);
-#if defined DOSISH || defined __CYGWIN__
+
+#if _WIN32
+    translit_char_bin(RSTRING_PTR(opt->script_name), '\\', '/');
+#elif defined DOSISH
     translit_char(RSTRING_PTR(opt->script_name), '\\', '/');
 #endif
 

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

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