aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-12-07 16:45:31 +0200
committerEli Zaretskii2013-12-07 16:45:31 +0200
commit080fd64974060e6b47573c94af2b80f1a5f3ef2c (patch)
tree16e92fcf37207dfd19d1ae14e57b0bde2121f3a5 /src/w32.c
parent94ae1542354539a0660b21cf3b7a5143139b8375 (diff)
downloademacs-080fd64974060e6b47573c94af2b80f1a5f3ef2c.tar.gz
emacs-080fd64974060e6b47573c94af2b80f1a5f3ef2c.zip
Fixed initialization code and default-printer-name.
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c53
1 files changed, 44 insertions, 9 deletions
diff --git a/src/w32.c b/src/w32.c
index 0f13703b933..e2649167aee 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1333,7 +1333,8 @@ w32_valid_pointer_p (void *p, int size)
1333 encoding when w32-unicode-filenames is t; this is similar to 1333 encoding when w32-unicode-filenames is t; this is similar to
1334 selection-coding-system. 1334 selection-coding-system.
1335 1335
1336 This arrangement works very well, but it has a few gotchas: 1336 This arrangement works very well, but it has a few gotchas and
1337 limitations:
1337 1338
1338 . Lisp code that encodes or decodes file names manually should 1339 . Lisp code that encodes or decodes file names manually should
1339 normally use 'utf-8' as the coding-system on Windows, 1340 normally use 'utf-8' as the coding-system on Windows,
@@ -1351,6 +1352,12 @@ w32_valid_pointer_p (void *p, int size)
1351 name sfrom UTF-8 to either UTF-16 or ANSI codepage, or going 1352 name sfrom UTF-8 to either UTF-16 or ANSI codepage, or going
1352 through some shadowing function defined here. 1353 through some shadowing function defined here.
1353 1354
1355 . Environment variables stored in Vprocess_environment are encoded
1356 in the ANSI codepage, so if getenv/egetenv is used for a variable
1357 whose value is a file name or a list of directories, it needs to
1358 be converted to UTF-8, before it is used as argument to functions
1359 or decoded into a Lisp string.
1360
1354 . File names passed to external libraries, like the image libraries 1361 . File names passed to external libraries, like the image libraries
1355 and GnuTLS, need special handling. These libraries generally 1362 and GnuTLS, need special handling. These libraries generally
1356 don't support UTF-16 or UTF-8 file names, so they must get file 1363 don't support UTF-16 or UTF-8 file names, so they must get file
@@ -1378,7 +1385,12 @@ w32_valid_pointer_p (void *p, int size)
1378 . For similar reasons, server.el and emacsclient are also limited 1385 . For similar reasons, server.el and emacsclient are also limited
1379 to the current ANSI codepage for now. 1386 to the current ANSI codepage for now.
1380 1387
1381*/ 1388 . Emacs itself can only handle command-line arguments encoded in
1389 the current codepage.
1390
1391 . Turning on w32-unicode-filename on Windows 9X (if it at all
1392 works) requires UNICOWS.DLL, which is currently loaded only in a
1393 GUI session. */
1382 1394
1383 1395
1384 1396
@@ -2365,6 +2377,8 @@ w32_get_resource (char *key, LPDWORD lpdwtype)
2365 return (NULL); 2377 return (NULL);
2366} 2378}
2367 2379
2380/* The argv[] array holds ANSI-encoded strings, and so this function
2381 works with ANS_encoded strings. */
2368void 2382void
2369init_environment (char ** argv) 2383init_environment (char ** argv)
2370{ 2384{
@@ -2508,7 +2522,7 @@ init_environment (char ** argv)
2508 char *p; 2522 char *p;
2509 char modname[MAX_PATH]; 2523 char modname[MAX_PATH];
2510 2524
2511 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 2525 if (!GetModuleFileNameA (NULL, modname, MAX_PATH))
2512 emacs_abort (); 2526 emacs_abort ();
2513 if ((p = _mbsrchr (modname, '\\')) == NULL) 2527 if ((p = _mbsrchr (modname, '\\')) == NULL)
2514 emacs_abort (); 2528 emacs_abort ();
@@ -2672,7 +2686,7 @@ init_environment (char ** argv)
2672 { 2686 {
2673 static char modname[MAX_PATH]; 2687 static char modname[MAX_PATH];
2674 2688
2675 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 2689 if (!GetModuleFileNameA (NULL, modname, MAX_PATH))
2676 emacs_abort (); 2690 emacs_abort ();
2677 argv[0] = modname; 2691 argv[0] = modname;
2678 } 2692 }
@@ -8434,10 +8448,10 @@ check_windows_init_file (void)
8434 8448
8435 /* Implementation note: this function runs early during Emacs 8449 /* Implementation note: this function runs early during Emacs
8436 startup, before startup.el is run. So Vload_path is still in 8450 startup, before startup.el is run. So Vload_path is still in
8437 its initial unibyte form, holding ANSI-encoded file names. 8451 its initial unibyte form, but it holds UTF-8 encoded file
8438 That is why we never bother to ENCODE_FILE here, nor use wide 8452 names, since init_callproc was already called. So we do not
8439 APIs for file names: we will never get UTF-8 encoded file 8453 need to ENCODE_FILE here, but we do need to convert the file
8440 names here. */ 8454 names from UTF-8 to ANSI. */
8441 init_file = build_string ("term/w32-win"); 8455 init_file = build_string ("term/w32-win");
8442 fd = openp (Vload_path, init_file, Fget_load_suffixes (), NULL, Qnil); 8456 fd = openp (Vload_path, init_file, Fget_load_suffixes (), NULL, Qnil);
8443 if (fd < 0) 8457 if (fd < 0)
@@ -8448,6 +8462,8 @@ check_windows_init_file (void)
8448 char *buffer = alloca (1024 8462 char *buffer = alloca (1024
8449 + strlen (init_file_name) 8463 + strlen (init_file_name)
8450 + strlen (load_path)); 8464 + strlen (load_path));
8465 char *msg = buffer;
8466 int needed;
8451 8467
8452 sprintf (buffer, 8468 sprintf (buffer,
8453 "The Emacs Windows initialization file \"%s.el\" " 8469 "The Emacs Windows initialization file \"%s.el\" "
@@ -8459,8 +8475,27 @@ check_windows_init_file (void)
8459 "not unpacked properly.\nSee the README.W32 file in the " 8475 "not unpacked properly.\nSee the README.W32 file in the "
8460 "top-level Emacs directory for more information.", 8476 "top-level Emacs directory for more information.",
8461 init_file_name, load_path); 8477 init_file_name, load_path);
8478 needed = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer,
8479 -1, NULL, 0);
8480 if (needed > 0)
8481 {
8482 wchar_t *msg_w = alloca ((needed + 1) * sizeof (wchar_t));
8483
8484 MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, -1,
8485 msg_w, needed);
8486 needed = WideCharToMultiByte (CP_ACP, 0, msg_w, -1,
8487 NULL, 0, NULL, NULL);
8488 if (needed > 0)
8489 {
8490 char *msg_a = alloca (needed + 1);
8491
8492 WideCharToMultiByte (CP_ACP, 0, msg_w, -1, msg_a, needed,
8493 NULL, NULL);
8494 msg = msg_a;
8495 }
8496 }
8462 MessageBox (NULL, 8497 MessageBox (NULL,
8463 buffer, 8498 msg,
8464 "Emacs Abort Dialog", 8499 "Emacs Abort Dialog",
8465 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); 8500 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
8466 /* Use the low-level system abort. */ 8501 /* Use the low-level system abort. */