summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-01-24 20:41:39 -0800
committerGlenn Morris <rgm@gnu.org>2013-01-24 20:41:39 -0800
commit830e46e61ba1316e771c72a15e709d3d12e150b7 (patch)
treec88c21c32f65dc77d8f76c315a41a519a585dc8f /src
parent3d4147bae3f03502acb3d12a5c9747129cc0c6aa (diff)
parent345f866e048bdc11bc38d894a7eaaa47335443e2 (diff)
Merge from emacs-24; up to 2012-12-11T18:52:31Z!monnier@iro.umontreal.ca
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/coding.c29
-rw-r--r--src/w32.c106
-rw-r--r--src/w32heap.c6
4 files changed, 132 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ffa4bdf927f..7d9647cbb11 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,20 @@
+2013-01-25 Eli Zaretskii <eliz@gnu.org>
+
+ * w32.c (max_filename_mbslen): New function.
+ (normalize_filename, readdir): Use it to detect locales where ANSI
+ encoding of file names uses a double-byte character set (DBCS).
+ If a DBCS encoding is used, advance by characters using
+ CharNextExA, instead of incrementing a 'char *' pointer. Use
+ _mbslwr instead of _strlwr. (Bug#13515)
+
+ * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial
+ request of memory reservation to 1.7GB. (Bug#13065)
+
+2013-01-25 Andreas Schwab <schwab@linux-m68k.org>
+
+ * coding.c (detect_coding_iso_2022): Move back mis-reordered code
+ at check_extra_latin label. (Bug#13505)
+
2013-01-24 Dmitry Antipov <dmantipov@yandex.ru>
* nsfont.m (ns_escape_name, ns_unescape_name, ns_registry_to_script):
diff --git a/src/coding.c b/src/coding.c
index a9bf9032a69..93da9db0d36 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -3057,20 +3057,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
}
if (single_shifting)
break;
- check_extra_latin:
- if (! VECTORP (Vlatin_extra_code_table)
- || NILP (AREF (Vlatin_extra_code_table, c)))
- {
- rejected = CATEGORY_MASK_ISO;
- break;
- }
- if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
- & CODING_ISO_FLAG_LATIN_EXTRA)
- found |= CATEGORY_MASK_ISO_8_1;
- else
- rejected |= CATEGORY_MASK_ISO_8_1;
- rejected |= CATEGORY_MASK_ISO_8_2;
- break;
+ goto check_extra_latin;
default:
if (c < 0)
@@ -3121,6 +3108,20 @@ detect_coding_iso_2022 (struct coding_system *coding,
}
break;
}
+ check_extra_latin:
+ if (! VECTORP (Vlatin_extra_code_table)
+ || NILP (AREF (Vlatin_extra_code_table, c)))
+ {
+ rejected = CATEGORY_MASK_ISO;
+ break;
+ }
+ if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
+ & CODING_ISO_FLAG_LATIN_EXTRA)
+ found |= CATEGORY_MASK_ISO_8_1;
+ else
+ rejected |= CATEGORY_MASK_ISO_8_1;
+ rejected |= CATEGORY_MASK_ISO_8_2;
+ break;
}
}
detect_info->rejected |= CATEGORY_MASK_ISO;
diff --git a/src/w32.c b/src/w32.c
index d014609076e..f722bc5f397 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -37,7 +37,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* must include CRT headers *before* config.h */
#include <config.h>
-#include <mbstring.h> /* for _mbspbrk */
+#include <mbstring.h> /* for _mbspbrk and _mbslwr */
#undef access
#undef chdir
@@ -1531,6 +1531,67 @@ srandom (int seed)
srand (seed);
}
+/* Current codepage for encoding file names. */
+static int file_name_codepage;
+
+/* Return the maximum length in bytes of a multibyte character
+ sequence encoded in the current ANSI codepage. This is required to
+ correctly walk the encoded file names one character at a time. */
+static int
+max_filename_mbslen (void)
+{
+ /* A simple cache to avoid calling GetCPInfo every time we need to
+ normalize a file name. The file-name encoding is not supposed to
+ be changed too frequently, if ever. */
+ static Lisp_Object last_file_name_encoding;
+ static int last_max_mbslen;
+ Lisp_Object current_encoding;
+
+ current_encoding = Vfile_name_coding_system;
+ if (NILP (current_encoding))
+ current_encoding = Vdefault_file_name_coding_system;
+
+ if (!EQ (last_file_name_encoding, current_encoding))
+ {
+ CPINFO cp_info;
+
+ last_file_name_encoding = current_encoding;
+ /* Default to the current ANSI codepage. */
+ file_name_codepage = w32_ansi_code_page;
+ if (!NILP (current_encoding))
+ {
+ char *cpname = SDATA (SYMBOL_NAME (current_encoding));
+ char *cp = NULL, *end;
+ int cpnum;
+
+ if (strncmp (cpname, "cp", 2) == 0)
+ cp = cpname + 2;
+ else if (strncmp (cpname, "windows-", 8) == 0)
+ cp = cpname + 8;
+
+ if (cp)
+ {
+ end = cp;
+ cpnum = strtol (cp, &end, 10);
+ if (cpnum && *end == '\0' && end - cp >= 2)
+ file_name_codepage = cpnum;
+ }
+ }
+
+ if (!file_name_codepage)
+ file_name_codepage = CP_ACP; /* CP_ACP = 0, but let's not assume that */
+
+ if (!GetCPInfo (file_name_codepage, &cp_info))
+ {
+ file_name_codepage = CP_ACP;
+ if (!GetCPInfo (file_name_codepage, &cp_info))
+ emacs_abort ();
+ }
+ last_max_mbslen = cp_info.MaxCharSize;
+ }
+
+ return last_max_mbslen;
+}
/* Normalize filename by converting all path separators to
the specified separator. Also conditionally convert upper
@@ -1540,14 +1601,20 @@ static void
normalize_filename (register char *fp, char path_sep)
{
char sep;
- char *elem;
+ char *elem, *p2;
+ int dbcs_p = max_filename_mbslen () > 1;
/* Always lower-case drive letters a-z, even if the filesystem
preserves case in filenames.
This is so filenames can be compared by string comparison
functions that are case-sensitive. Even case-preserving filesystems
do not distinguish case in drive letters. */
- if (fp[1] == ':' && *fp >= 'A' && *fp <= 'Z')
+ if (dbcs_p)
+ p2 = CharNextExA (file_name_codepage, fp, 0);
+ else
+ p2 = fp + 1;
+
+ if (*p2 == ':' && *fp >= 'A' && *fp <= 'Z')
{
*fp += 'a' - 'A';
fp += 2;
@@ -1559,7 +1626,10 @@ normalize_filename (register char *fp, char path_sep)
{
if (*fp == '/' || *fp == '\\')
*fp = path_sep;
- fp++;
+ if (!dbcs_p)
+ fp++;
+ else
+ fp = CharNextExA (file_name_codepage, fp, 0);
}
return;
}
@@ -1582,13 +1652,20 @@ normalize_filename (register char *fp, char path_sep)
if (elem && elem != fp)
{
*fp = 0; /* temporary end of string */
- _strlwr (elem); /* while we convert to lower case */
+ _mbslwr (elem); /* while we convert to lower case */
}
*fp = sep; /* convert (or restore) path separator */
elem = fp + 1; /* next element starts after separator */
sep = path_sep;
}
- } while (*fp++);
+ if (*fp)
+ {
+ if (!dbcs_p)
+ fp++;
+ else
+ fp = CharNextExA (file_name_codepage, fp, 0);
+ }
+ } while (*fp);
}
/* Destructively turn backslashes into slashes. */
@@ -2860,15 +2937,22 @@ readdir (DIR *dirp)
strcpy (dir_static.d_name, dir_find_data.cFileName);
dir_static.d_namlen = strlen (dir_static.d_name);
if (dir_is_fat)
- _strlwr (dir_static.d_name);
+ _mbslwr (dir_static.d_name);
else if (downcase)
{
register char *p;
- for (p = dir_static.d_name; *p; p++)
- if (*p >= 'a' && *p <= 'z')
- break;
+ int dbcs_p = max_filename_mbslen () > 1;
+ for (p = dir_static.d_name; *p; )
+ {
+ if (*p >= 'a' && *p <= 'z')
+ break;
+ if (dbcs_p)
+ p = CharNextExA (file_name_codepage, p, 0);
+ else
+ p++;
+ }
if (!*p)
- _strlwr (dir_static.d_name);
+ _mbslwr (dir_static.d_name);
}
return &dir_static;
diff --git a/src/w32heap.c b/src/w32heap.c
index 9c189dbda6d..81206ce2834 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -98,7 +98,11 @@ allocate_heap (void)
#ifdef _WIN64
size_t size = 0x4000000000i64; /* start by asking for 32GB */
#else
- size_t size = 0x80000000; /* start by asking for 2GB */
+ /* We used to start with 2GB here, but on Windows 7 that would leave
+ too little room in the address space for threads started by
+ Windows on our behalf, e.g. when we pop up the file selection
+ dialog. */
+ size_t size = 0x68000000; /* start by asking for 1.7GB */
#endif
void *ptr = NULL;