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

ruby-changes:43933

From: nobu <ko1@a...>
Date: Thu, 25 Aug 2016 00:42:38 +0900 (JST)
Subject: [ruby-changes:43933] nobu:r56006 (trunk): win32/file.c: remove a codepage argument

nobu	2016-08-25 00:42:33 +0900 (Thu, 25 Aug 2016)

  New Revision: 56006

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

  Log:
    win32/file.c: remove a codepage argument
    
    * win32/file.c (append_wstr): remove a codepage argument, and use
      INVALID_CODE_PAGE for conversion by econv.

  Modified files:
    trunk/ChangeLog
    trunk/win32/file.c
Index: win32/file.c
===================================================================
--- win32/file.c	(revision 56005)
+++ win32/file.c	(revision 56006)
@@ -280,23 +280,23 @@ user_length_in_path(const wchar_t *wuser https://github.com/ruby/ruby/blob/trunk/win32/file.c#L280
 }
 
 static VALUE
-append_wstr(VALUE dst, const WCHAR *ws, ssize_t len, UINT cp, UINT path_cp, rb_encoding *path_encoding)
+append_wstr(VALUE dst, const WCHAR *ws, ssize_t len, UINT cp, rb_encoding *enc)
 {
     long olen, nlen = (long)len;
 
-    if (cp == path_cp) {
+    if (cp != INVALID_CODE_PAGE) {
 	if (len == -1) len = lstrlenW(ws);
 	nlen = WideCharToMultiByte(cp, 0, ws, len, NULL, 0, NULL, NULL);
 	olen = RSTRING_LEN(dst);
 	rb_str_modify_expand(dst, nlen);
 	WideCharToMultiByte(cp, 0, ws, len, RSTRING_PTR(dst) + olen, nlen, NULL, NULL);
-	rb_enc_associate(dst, path_encoding);
+	rb_enc_associate(dst, enc);
 	rb_str_set_len(dst, olen + nlen);
     }
     else {
 	const int replaceflags = ECONV_UNDEF_REPLACE|ECONV_INVALID_REPLACE;
 	char *utf8str = wstr_to_mbstr(CP_UTF8, ws, (int)len, &nlen);
-	rb_econv_t *ec = rb_econv_open("UTF-8", rb_enc_name(path_encoding), replaceflags);
+	rb_econv_t *ec = rb_econv_open("UTF-8", rb_enc_name(enc), replaceflags);
 	dst = rb_econv_append(ec, utf8str, nlen, dst, replaceflags);
 	rb_econv_close(ec);
 	free(utf8str);
@@ -410,7 +410,7 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/win32/file.c#L410
     else if (abs_mode == 0 && wpath_len >= 2 && wpath_pos[0] == L'~') {
 	result = rb_str_new_cstr("can't find user ");
 	result = append_wstr(result, wpath_pos + 1, user_length_in_path(wpath_pos + 1, wpath_len - 1),
-			     cp, path_cp, path_encoding);
+			     path_cp, path_encoding);
 
 	if (wpath)
 	    free(wpath);
@@ -494,7 +494,7 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/win32/file.c#L494
 	else if (abs_mode == 0 && wdir_len >= 2 && wdir_pos[0] == L'~') {
 	    result = rb_str_new_cstr("can't find user ");
 	    result = append_wstr(result, wdir_pos + 1, user_length_in_path(wdir_pos + 1, wdir_len - 1),
-				 cp, path_cp, path_encoding);
+				 path_cp, path_encoding);
 	    if (wpath)
 		free(wpath);
 
@@ -621,7 +621,7 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/win32/file.c#L621
 
     /* convert to VALUE and set the path encoding */
     rb_str_set_len(result, 0);
-    result = append_wstr(result, wfullpath, size, cp, path_cp, path_encoding);
+    result = append_wstr(result, wfullpath, size, path_cp, path_encoding);
 
     /* makes the result object tainted if expanding tainted strings or returning modified path */
     if (tainted)
@@ -687,10 +687,9 @@ rb_readlink(VALUE path, rb_encoding *res https://github.com/ruby/ruby/blob/trunk/win32/file.c#L687
 	    rb_syserr_fail_path(EINVAL, path);
     }
     enc = resultenc;
-    cp = path_cp = code_page(enc);
-    if (cp == INVALID_CODE_PAGE) cp = CP_UTF8;
+    path_cp = code_page(enc);
     len = lstrlenW(wbuf);
-    str = append_wstr(rb_enc_str_new(0, 0, enc), wbuf, len, cp, path_cp, enc);
+    str = append_wstr(rb_enc_str_new(0, 0, enc), wbuf, len, path_cp, enc);
     ALLOCV_END(wtmp);
     return str;
 }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56005)
+++ ChangeLog	(revision 56006)
@@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Thu Aug 25 00:39:50 2016  Nobuyoshi Nakada  <nobu@r...>
+Thu Aug 25 00:42:31 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/file.c (append_wstr): remove a codepage argument, and use
+	  INVALID_CODE_PAGE for conversion by econv.
 
 	* win32/file.c (append_wstr): exclude the terminator from the
 	  result length when input len == -1.

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

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