aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-01-25 12:27:16 +0200
committerEli Zaretskii2013-01-25 12:27:16 +0200
commit69bb66c12e42e8196cdf440b83e367635f901bff (patch)
treef2f8bf4358723ce75f39008288950bb110638c5e /src/w32.c
parentd8cd7742b31178d670a677debb851b961c0464da (diff)
downloademacs-69bb66c12e42e8196cdf440b83e367635f901bff.tar.gz
emacs-69bb66c12e42e8196cdf440b83e367635f901bff.zip
w32.c (readlink): Support DBCS codepages.
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/w32.c b/src/w32.c
index f722bc5f397..dc9233ee001 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4639,18 +4639,34 @@ readlink (const char *name, char *buf, size_t buf_size)
4639 else 4639 else
4640 { 4640 {
4641 size_t size_to_copy = buf_size; 4641 size_t size_to_copy = buf_size;
4642 BYTE *p = lname; 4642 BYTE *p = lname, *p2;
4643 BYTE *pend = p + lname_len; 4643 BYTE *pend = p + lname_len;
4644 int dbcs_p = max_filename_mbslen () > 1;
4644 4645
4645 /* Normalize like dostounix_filename does, but we don't 4646 /* Normalize like dostounix_filename does, but we don't
4646 want to assume that lname is null-terminated. */ 4647 want to assume that lname is null-terminated. */
4647 if (*p && p[1] == ':' && *p >= 'A' && *p <= 'Z') 4648 if (dbcs_p)
4648 *p += 'a' - 'A'; 4649 p2 = CharNextExA (file_name_codepage, p, 0);
4650 else
4651 p2 = p + 1;
4652 if (*p && *p2 == ':' && *p >= 'A' && *p <= 'Z')
4653 {
4654 *p += 'a' - 'A';
4655 p += 2;
4656 }
4649 while (p <= pend) 4657 while (p <= pend)
4650 { 4658 {
4651 if (*p == '\\') 4659 if (*p == '\\')
4652 *p = '/'; 4660 *p = '/';
4653 ++p; 4661 if (dbcs_p)
4662 {
4663 p = CharNextExA (file_name_codepage, p, 0);
4664 /* CharNextExA doesn't advance at null character. */
4665 if (!*p)
4666 break;
4667 }
4668 else
4669 ++p;
4654 } 4670 }
4655 /* Testing for null-terminated LNAME is paranoia: 4671 /* Testing for null-terminated LNAME is paranoia:
4656 WideCharToMultiByte should always return a 4672 WideCharToMultiByte should always return a