aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-01-25 16:47:37 +0200
committerEli Zaretskii2013-01-25 16:47:37 +0200
commit26854e9c9ee5469474bcaa496b94273082772c18 (patch)
tree0cf9be34b5e64540f11fc98a2b140b068ed5f21c /src
parent6ee4509abf626f26ef56527ca0269614285a8404 (diff)
downloademacs-26854e9c9ee5469474bcaa496b94273082772c18.tar.gz
emacs-26854e9c9ee5469474bcaa496b94273082772c18.zip
Use file-name-coding-system when decoding symlinks on MS-Windows.
src/w32.c (readlink): Use the current file-name-coding-system, not the ANSI codepage, to decode and handle targets of symlinks.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog2
-rw-r--r--src/w32.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2294a473f53..cd71fa73db0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -2,6 +2,8 @@
2 2
3 * w32.c (w32_get_long_filename, init_environment, readlink): 3 * w32.c (w32_get_long_filename, init_environment, readlink):
4 Support file names encoded in DBCS codepages. 4 Support file names encoded in DBCS codepages.
5 (readlink): Use the current file-name-coding-system, not the ANSI
6 codepage, to decode and handle targets of symlinks.
5 7
62013-01-23 Eli Zaretskii <eliz@gnu.org> 82013-01-23 Eli Zaretskii <eliz@gnu.org>
7 9
diff --git a/src/w32.c b/src/w32.c
index 98ec573f553..86b4ea72a22 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4305,6 +4305,8 @@ readlink (const char *name, char *buf, size_t buf_size)
4305 WCHAR *lwname_src = 4305 WCHAR *lwname_src =
4306 reparse_data->SymbolicLinkReparseBuffer.PathBuffer 4306 reparse_data->SymbolicLinkReparseBuffer.PathBuffer
4307 + reparse_data->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR); 4307 + reparse_data->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR);
4308 /* This updates file_name_codepage which we need below. */
4309 int dbcs_p = max_filename_mbslen () > 1;
4308 4310
4309 /* According to MSDN, PrintNameLength does not include the 4311 /* According to MSDN, PrintNameLength does not include the
4310 terminating null character. */ 4312 terminating null character. */
@@ -4312,9 +4314,7 @@ readlink (const char *name, char *buf, size_t buf_size)
4312 memcpy (lwname, lwname_src, lwname_len); 4314 memcpy (lwname, lwname_src, lwname_len);
4313 lwname[lwname_len/sizeof(WCHAR)] = 0; /* null-terminate */ 4315 lwname[lwname_len/sizeof(WCHAR)] = 0; /* null-terminate */
4314 4316
4315 /* FIXME: Should we use the current file-name coding system 4317 lname_len = WideCharToMultiByte (file_name_codepage, 0, lwname, -1,
4316 instead of the fixed value of the ANSI codepage? */
4317 lname_len = WideCharToMultiByte (w32_ansi_code_page, 0, lwname, -1,
4318 lname, MAX_PATH, NULL, NULL); 4318 lname, MAX_PATH, NULL, NULL);
4319 if (!lname_len) 4319 if (!lname_len)
4320 { 4320 {
@@ -4342,12 +4342,11 @@ readlink (const char *name, char *buf, size_t buf_size)
4342 size_t size_to_copy = buf_size; 4342 size_t size_to_copy = buf_size;
4343 BYTE *p = lname, *p2; 4343 BYTE *p = lname, *p2;
4344 BYTE *pend = p + lname_len; 4344 BYTE *pend = p + lname_len;
4345 int dbcs_p = max_filename_mbslen () > 1;
4346 4345
4347 /* Normalize like dostounix_filename does, but we don't 4346 /* Normalize like dostounix_filename does, but we don't
4348 want to assume that lname is null-terminated. */ 4347 want to assume that lname is null-terminated. */
4349 if (dbcs_p) 4348 if (dbcs_p)
4350 p2 = CharNextExA (w32_ansi_code_page, p, 0); 4349 p2 = CharNextExA (file_name_codepage, p, 0);
4351 else 4350 else
4352 p2 = p + 1; 4351 p2 = p + 1;
4353 if (*p && *p2 == ':' && *p >= 'A' && *p <= 'Z') 4352 if (*p && *p2 == ':' && *p >= 'A' && *p <= 'Z')
@@ -4361,7 +4360,7 @@ readlink (const char *name, char *buf, size_t buf_size)
4361 *p = '/'; 4360 *p = '/';
4362 if (dbcs_p) 4361 if (dbcs_p)
4363 { 4362 {
4364 p = CharNextExA (w32_ansi_code_page, p, 0); 4363 p = CharNextExA (file_name_codepage, p, 0);
4365 /* CharNextExA doesn't advance at null character. */ 4364 /* CharNextExA doesn't advance at null character. */
4366 if (!*p) 4365 if (!*p)
4367 break; 4366 break;