aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2013-11-04 19:30:33 +0200
committerEli Zaretskii2013-11-04 19:30:33 +0200
commitd0065ff1244871c9eb40420b88fc89f9f008b587 (patch)
treea869fa565b559c7b0a9390fd6045d7d827d001ec
parent7397c58760779a3aa83ff58164455761d77cd642 (diff)
downloademacs-d0065ff1244871c9eb40420b88fc89f9f008b587.tar.gz
emacs-d0065ff1244871c9eb40420b88fc89f9f008b587.zip
Fix bug #15260 with building and installing Emacs in non-ASCII directories.
src/xdisp.c (message3_nolog, message_with_string): Encode the string before writing it to the terminal in a non-interactive session. src/lread.c (openp): If both FILENAME and SUFFIX are unibyte, make sure we concatenate them into a unibyte string. src/fileio.c (make_temp_name): Encode PREFIX, and decode the resulting temporary name before returning it to the caller. (Fexpand_file_name): If NAME is pure-ASCII and DEFAULT_DIRECTORY is a unibyte string, convert NAME to a unibyte string to ensure that the result is also a unibyte string. src/emacs.c (init_cmdargs): Use build_unibyte_string to make sure we create unibyte strings from default paths and directory/file names. src/coding.h (ENCODE_FILE): Do not attempt to encode a unibyte string. src/callproc.c (init_callproc): Use build_unibyte_string to make sure we create unibyte strings from default paths and directory/file names. src/buffer.c (init_buffer): Don't store default-directory of *scratch* in multibyte form. The original problem which led to that is described in http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-11/msg00532.html, but it was solved long ago. lisp/startup.el (normal-top-level): Move setting eol-mnemonic-unix, eol-mnemonic-mac, eol-mnemonic-dos, and also setup of the locale environment and decoding all of the default-directory's to here from command-line. (command-line): Decode also argv[0]. lisp/loadup.el: Error out if default-directory is a multibyte string when we are dumping. lisp/Makefile.in (emacs): Don't set LC_ALL=C. leim/Makefile.in (RUN_EMACS): Don't set LC_ALL=C. configure.ac: Don't disallow builds in non-ASCII directories.
-rw-r--r--ChangeLog5
-rw-r--r--configure.ac24
-rw-r--r--leim/ChangeLog4
-rw-r--r--leim/Makefile.in2
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/Makefile.in2
-rw-r--r--lisp/loadup.el14
-rw-r--r--lisp/startup.el94
-rw-r--r--src/ChangeLog31
-rw-r--r--src/buffer.c9
-rw-r--r--src/callproc.c6
-rw-r--r--src/coding.h18
-rw-r--r--src/emacs.c10
-rw-r--r--src/fileio.c36
-rw-r--r--src/lread.c18
-rw-r--r--src/xdisp.c14
16 files changed, 213 insertions, 87 deletions
diff --git a/ChangeLog b/ChangeLog
index 85b30977cad..547f5ce1afc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
12013-11-04 Eli Zaretskii <eliz@gnu.org>
2
3 * configure.ac: Don't disallow builds in non-ASCII directories.
4 (Bug#15260)
5
12013-11-04 Paul Eggert <eggert@cs.ucla.edu> 62013-11-04 Paul Eggert <eggert@cs.ucla.edu>
2 7
3 Port to stricter C99 platforms. 8 Port to stricter C99 platforms.
diff --git a/configure.ac b/configure.ac
index 64efdd8bbd6..2540f185078 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,30 +73,6 @@ dnl Support for --program-prefix, --program-suffix and
73dnl --program-transform-name options 73dnl --program-transform-name options
74AC_ARG_PROGRAM 74AC_ARG_PROGRAM
75 75
76dnl http://debbugs.gnu.org/15260
77dnl I think we have to check, eg, both exec_prefix and bindir,
78dnl because the latter by default is not yet expanded, but the user
79dnl may have specified a value for it via --bindir.
80dnl At first glance, _installing_ in non-ASCII seems ok, but in fact
81dnl it is not; see http://debbugs.gnu.org/15260#61
82dnl Note that abs_srcdir and abs_builddir are not yet defined. :(
83
84dnl "`cd \"$srcdir\"`" is not portable.
85dnl See autoconf manual "Shell Substitutions":
86dnl "There is just no portable way to use double-quoted strings inside
87dnl double-quoted back-quoted expressions (pfew!)."
88temp_srcdir=`cd "$srcdir"; pwd`
89
90for var in "`pwd`" "$temp_srcdir" "$prefix" "$exec_prefix" \
91 "$datarootdir" "$bindir" "$datadir" "$sharedstatedir" "$libexecdir"; do
92
93 dnl configure sets LC_ALL=C early on, so this range should work.
94 case "$var" in
95 *[[!\ -~]]*) AC_MSG_ERROR([Emacs cannot be built or installed in a directory whose name contains non-ASCII characters: $var]) ;;
96 esac
97
98done
99
100dnl It is important that variables on the RHS not be expanded here, 76dnl It is important that variables on the RHS not be expanded here,
101dnl hence the single quotes. This is per the GNU coding standards, see 77dnl hence the single quotes. This is per the GNU coding standards, see
102dnl (autoconf) Installation Directory Variables 78dnl (autoconf) Installation Directory Variables
diff --git a/leim/ChangeLog b/leim/ChangeLog
index 9883995c68b..6b16d71c215 100644
--- a/leim/ChangeLog
+++ b/leim/ChangeLog
@@ -1,3 +1,7 @@
12013-11-04 Eli Zaretskii <eliz@gnu.org>
2
3 * Makefile.in (RUN_EMACS): Don't set LC_ALL=C. (Bug#15260)
4
12013-11-03 Glenn Morris <rgm@gnu.org> 52013-11-03 Glenn Morris <rgm@gnu.org>
2 6
3 * Makefile.in (abs_srcdir): Remove. 7 * Makefile.in (abs_srcdir): Remove.
diff --git a/leim/Makefile.in b/leim/Makefile.in
index c1a79a75d04..a5c05d567ec 100644
--- a/leim/Makefile.in
+++ b/leim/Makefile.in
@@ -32,7 +32,7 @@ EMACS = ../src/emacs
32 32
33# How to run Emacs. 33# How to run Emacs.
34# Prevent any setting of EMACSLOADPATH in user environment causing problems. 34# Prevent any setting of EMACSLOADPATH in user environment causing problems.
35RUN_EMACS = unset EMACSLOADPATH; LC_ALL=C "${EMACS}" -batch \ 35RUN_EMACS = unset EMACSLOADPATH; "${EMACS}" -batch \
36 --no-site-file --no-site-lisp 36 --no-site-file --no-site-lisp
37 37
38MKDIR_P = @MKDIR_P@ 38MKDIR_P = @MKDIR_P@
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4ef439a43c1..965a62668ed 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12013-11-04 Eli Zaretskii <eliz@gnu.org>
2
3 * startup.el (normal-top-level): Move setting eol-mnemonic-unix,
4 eol-mnemonic-mac, eol-mnemonic-dos, and also setup of the locale
5 environment and decoding all of the default-directory's to here
6 from command-line.
7 (command-line): Decode also argv[0].
8
9 * loadup.el: Error out if default-directory is a multibyte string
10 when we are dumping.
11
12 * Makefile.in (emacs): Don't set LC_ALL=C. (Bug#15260)
13
12013-11-04 Teodor Zlatanov <tzz@lifelogs.com> 142013-11-04 Teodor Zlatanov <tzz@lifelogs.com>
2 15
3 * emacs-lisp/package.el (package-menu-mode) 16 * emacs-lisp/package.el (package-menu-mode)
diff --git a/lisp/Makefile.in b/lisp/Makefile.in
index 7b0206a623d..9733495403c 100644
--- a/lisp/Makefile.in
+++ b/lisp/Makefile.in
@@ -106,7 +106,7 @@ COMPILE_FIRST = \
106 106
107# The actual Emacs command run in the targets below. 107# The actual Emacs command run in the targets below.
108# Prevent any setting of EMACSLOADPATH in user environment causing problems. 108# Prevent any setting of EMACSLOADPATH in user environment causing problems.
109emacs = unset EMACSLOADPATH; LC_ALL=C "$(EMACS)" $(EMACSOPT) 109emacs = unset EMACSLOADPATH; "$(EMACS)" $(EMACSOPT)
110 110
111# Common command to find subdirectories 111# Common command to find subdirectories
112setwins=subdirs=`find . -type d -print`; \ 112setwins=subdirs=`find . -type d -print`; \
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 27148ceea75..98e3b877144 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -286,6 +286,20 @@
286;For other systems, you must edit ../src/Makefile.in. 286;For other systems, you must edit ../src/Makefile.in.
287(load "site-load" t) 287(load "site-load" t)
288 288
289;; Make sure default-directory is unibyte when dumping. This is
290;; because we cannot decode and encode it correctly (since the locale
291;; environment is not, and should not be, set up). default-directory
292;; is used every time we call expand-file-name, which we do in every
293;; file primitive. So the only workable solution to support building
294;; in non-ASCII directories is to manipulate unibyte strings in the
295;; current locale's encoding.
296(if (and (or (equal (nth 3 command-line-args) "dump")
297 (equal (nth 4 command-line-args) "dump")
298 (equal (nth 3 command-line-args) "bootstrap")
299 (equal (nth 4 command-line-args) "bootstrap"))
300 (multibyte-string-p default-directory))
301 (error "default-directory must be unibyte when dumping Emacs!"))
302
289;; Determine which last version number to use 303;; Determine which last version number to use
290;; based on the executables that now exist. 304;; based on the executables that now exist.
291(if (and (or (equal (nth 3 command-line-args) "dump") 305(if (and (or (equal (nth 3 command-line-args) "dump")
diff --git a/lisp/startup.el b/lisp/startup.el
index e93c3fa5826..963ee687a3b 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -489,6 +489,63 @@ It is the default value of the variable `top-level'."
489 (if command-line-processed 489 (if command-line-processed
490 (message "Back to top level.") 490 (message "Back to top level.")
491 (setq command-line-processed t) 491 (setq command-line-processed t)
492
493 ;; Set the default strings to display in mode line for end-of-line
494 ;; formats that aren't native to this platform. This should be
495 ;; done before calling set-locale-environment, as the latter might
496 ;; use these mnemonics.
497 (cond
498 ((memq system-type '(ms-dos windows-nt))
499 (setq eol-mnemonic-unix "(Unix)"
500 eol-mnemonic-mac "(Mac)"))
501 (t ; this is for Unix/GNU/Linux systems
502 (setq eol-mnemonic-dos "(DOS)"
503 eol-mnemonic-mac "(Mac)")))
504
505 (set-locale-environment nil)
506 ;; Decode all default-directory's (probably, only *scratch* exists
507 ;; at this point). default-directory of *scratch* is the basis
508 ;; for many other file-name variables and directory lists, so it
509 ;; is important to decode it ASAP.
510 (when locale-coding-system
511 (save-excursion
512 (dolist (elt (buffer-list))
513 (set-buffer elt)
514 (if default-directory
515 (setq default-directory
516 (decode-coding-string default-directory
517 locale-coding-system t)))))
518
519 ;; Decode all the important variables and directory lists, now
520 ;; that we know the locale's encoding. This is because the
521 ;; values of these variables are until here unibyte undecoded
522 ;; strings created by build_unibyte_string. data-directory in
523 ;; particular is used to construct many other standard directory
524 ;; names, so it must be decoded ASAP.
525 ;; Note that charset-map-path cannot be decoded here, since we
526 ;; could then be trapped in infinite recursion below, when we
527 ;; load subdirs.el, because encoding a directory name might need
528 ;; to load a charset map, which will want to encode
529 ;; charset-map-path, which will want to load the same charset
530 ;; map... So decoding of charset-map-path is delayed until
531 ;; further down below.
532 (dolist (pathsym '(load-path exec-path))
533 (let ((path (symbol-value pathsym)))
534 (if (listp path)
535 (set pathsym (mapcar (lambda (dir)
536 (decode-coding-string
537 dir
538 locale-coding-system t))
539 path)))))
540 (dolist (filesym '(data-directory doc-directory exec-directory
541 installation-directory
542 invocation-directory invocation-name
543 source-directory
544 shared-game-score-directory))
545 (let ((file (symbol-value filesym)))
546 (if (stringp file)
547 (set filesym (decode-coding-string file locale-coding-system t))))))
548
492 (let ((dir default-directory)) 549 (let ((dir default-directory))
493 (with-current-buffer "*Messages*" 550 (with-current-buffer "*Messages*"
494 (messages-buffer-mode) 551 (messages-buffer-mode)
@@ -536,6 +593,16 @@ It is the default value of the variable `top-level'."
536 (setq process-environment 593 (setq process-environment
537 (delete (concat "PWD=" pwd) 594 (delete (concat "PWD=" pwd)
538 process-environment))))) 595 process-environment)))))
596 ;; Now, that other directories were searched, and any charsets we
597 ;; need for encoding them are already loaded, we are ready to
598 ;; decode charset-map-path.
599 (if (listp charset-map-path)
600 (setq charset-map-path
601 (mapcar (lambda (dir)
602 (decode-coding-string
603 dir
604 locale-coding-system t))
605 charset-map-path)))
539 (setq default-directory (abbreviate-file-name default-directory)) 606 (setq default-directory (abbreviate-file-name default-directory))
540 (let ((old-face-font-rescale-alist face-font-rescale-alist)) 607 (let ((old-face-font-rescale-alist face-font-rescale-alist))
541 (unwind-protect 608 (unwind-protect
@@ -756,18 +823,6 @@ Amongst another things, it parses the command-line arguments."
756 ;;! ;; Choose a good default value for split-window-keep-point. 823 ;;! ;; Choose a good default value for split-window-keep-point.
757 ;;! (setq split-window-keep-point (> baud-rate 2400)) 824 ;;! (setq split-window-keep-point (> baud-rate 2400))
758 825
759 ;; Set the default strings to display in mode line for
760 ;; end-of-line formats that aren't native to this platform.
761 (cond
762 ((memq system-type '(ms-dos windows-nt))
763 (setq eol-mnemonic-unix "(Unix)"
764 eol-mnemonic-mac "(Mac)"))
765 (t ; this is for Unix/GNU/Linux systems
766 (setq eol-mnemonic-dos "(DOS)"
767 eol-mnemonic-mac "(Mac)")))
768
769 (set-locale-environment nil)
770
771 ;; Convert preloaded file names in load-history to absolute. 826 ;; Convert preloaded file names in load-history to absolute.
772 (let ((simple-file-name 827 (let ((simple-file-name
773 ;; Look for simple.el or simple.elc and use their directory 828 ;; Look for simple.el or simple.elc and use their directory
@@ -801,7 +856,7 @@ please check its value")
801 load-history)))) 856 load-history))))
802 857
803 ;; Convert the arguments to Emacs internal representation. 858 ;; Convert the arguments to Emacs internal representation.
804 (let ((args (cdr command-line-args))) 859 (let ((args command-line-args))
805 (while args 860 (while args
806 (setcar args 861 (setcar args
807 (decode-coding-string (car args) locale-coding-system t)) 862 (decode-coding-string (car args) locale-coding-system t))
@@ -1211,19 +1266,6 @@ the `--debug-init' option to view a complete error backtrace."
1211 (setq after-init-time (current-time)) 1266 (setq after-init-time (current-time))
1212 (run-hooks 'after-init-hook) 1267 (run-hooks 'after-init-hook)
1213 1268
1214 ;; Decode all default-directory.
1215 (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
1216 (save-excursion
1217 (dolist (elt (buffer-list))
1218 (set-buffer elt)
1219 (if default-directory
1220 (setq default-directory
1221 (decode-coding-string default-directory
1222 locale-coding-system t))))
1223 (setq command-line-default-directory
1224 (decode-coding-string command-line-default-directory
1225 locale-coding-system t))))
1226
1227 ;; If *scratch* exists and init file didn't change its mode, initialize it. 1269 ;; If *scratch* exists and init file didn't change its mode, initialize it.
1228 (if (get-buffer "*scratch*") 1270 (if (get-buffer "*scratch*")
1229 (with-current-buffer "*scratch*" 1271 (with-current-buffer "*scratch*"
diff --git a/src/ChangeLog b/src/ChangeLog
index 1c56a7c5996..f6f4dc3ef88 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,34 @@
12013-11-04 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (message3_nolog, message_with_string): Encode the string
4 before writing it to the terminal in a non-interactive session.
5
6 * lread.c (openp): If both FILENAME and SUFFIX are unibyte, make
7 sure we concatenate them into a unibyte string.
8
9 * fileio.c (make_temp_name): Encode PREFIX, and decode the
10 resulting temporary name before returning it to the caller.
11 (Fexpand_file_name): If NAME is pure-ASCII and DEFAULT_DIRECTORY
12 is a unibyte string, convert NAME to a unibyte string to ensure
13 that the result is also a unibyte string.
14
15 * emacs.c (init_cmdargs): Use build_unibyte_string to make sure we
16 create unibyte strings from default paths and directory/file
17 names.
18
19 * coding.h (ENCODE_FILE): Do not attempt to encode a unibyte
20 string.
21
22 * callproc.c (init_callproc): Use build_unibyte_string to make
23 sure we create unibyte strings from default paths and
24 directory/file names.
25
26 * buffer.c (init_buffer): Don't store default-directory of
27 8scratch* in multibyte form. The original problem which led to
28 that is described in
29 http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-11/msg00532.html,
30 but it was solved long ago. (Bug#15260)
31
12013-11-04 Paul Eggert <eggert@cs.ucla.edu> 322013-11-04 Paul Eggert <eggert@cs.ucla.edu>
2 33
3 Port to stricter C99 platforms. 34 Port to stricter C99 platforms.
diff --git a/src/buffer.c b/src/buffer.c
index e5a8af93cf0..63198cd1018 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5349,13 +5349,10 @@ init_buffer (void)
5349 len++; 5349 len++;
5350 } 5350 }
5351 5351
5352 /* At this moment, we still don't know how to decode the directory
5353 name. So, we keep the bytes in unibyte form so that file I/O
5354 routines correctly get the original bytes. */
5352 bset_directory (current_buffer, make_unibyte_string (pwd, len)); 5355 bset_directory (current_buffer, make_unibyte_string (pwd, len));
5353 if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))
5354 /* At this moment, we still don't know how to decode the
5355 directory name. So, we keep the bytes in multibyte form so
5356 that ENCODE_FILE correctly gets the original bytes. */
5357 bset_directory
5358 (current_buffer, string_to_multibyte (BVAR (current_buffer, directory)));
5359 5356
5360 /* Add /: to the front of the name 5357 /* Add /: to the front of the name
5361 if it would otherwise be treated as magic. */ 5358 if it would otherwise be treated as magic. */
diff --git a/src/callproc.c b/src/callproc.c
index d4b4a26ec3a..2740779f513 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1612,14 +1612,14 @@ init_callproc (void)
1612 Lisp_Object tem, tem1, srcdir; 1612 Lisp_Object tem, tem1, srcdir;
1613 1613
1614 srcdir = Fexpand_file_name (build_string ("../src/"), 1614 srcdir = Fexpand_file_name (build_string ("../src/"),
1615 build_string (PATH_DUMPLOADSEARCH)); 1615 build_unibyte_string (PATH_DUMPLOADSEARCH));
1616 tem = Fexpand_file_name (build_string ("GNU"), Vdata_directory); 1616 tem = Fexpand_file_name (build_string ("GNU"), Vdata_directory);
1617 tem1 = Ffile_exists_p (tem); 1617 tem1 = Ffile_exists_p (tem);
1618 if (!NILP (Fequal (srcdir, Vinvocation_directory)) || NILP (tem1)) 1618 if (!NILP (Fequal (srcdir, Vinvocation_directory)) || NILP (tem1))
1619 { 1619 {
1620 Lisp_Object newdir; 1620 Lisp_Object newdir;
1621 newdir = Fexpand_file_name (build_string ("../etc/"), 1621 newdir = Fexpand_file_name (build_string ("../etc/"),
1622 build_string (PATH_DUMPLOADSEARCH)); 1622 build_unibyte_string (PATH_DUMPLOADSEARCH));
1623 tem = Fexpand_file_name (build_string ("GNU"), newdir); 1623 tem = Fexpand_file_name (build_string ("GNU"), newdir);
1624 tem1 = Ffile_exists_p (tem); 1624 tem1 = Ffile_exists_p (tem);
1625 if (!NILP (tem1)) 1625 if (!NILP (tem1))
@@ -1646,7 +1646,7 @@ init_callproc (void)
1646#ifdef DOS_NT 1646#ifdef DOS_NT
1647 Vshared_game_score_directory = Qnil; 1647 Vshared_game_score_directory = Qnil;
1648#else 1648#else
1649 Vshared_game_score_directory = build_string (PATH_GAME); 1649 Vshared_game_score_directory = build_unibyte_string (PATH_GAME);
1650 if (NILP (Ffile_accessible_directory_p (Vshared_game_score_directory))) 1650 if (NILP (Ffile_accessible_directory_p (Vshared_game_score_directory)))
1651 Vshared_game_score_directory = Qnil; 1651 Vshared_game_score_directory = Qnil;
1652#endif 1652#endif
diff --git a/src/coding.h b/src/coding.h
index 0472bec99de..5a921e44950 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -670,14 +670,16 @@ struct coding_system
670 (code) = (s1 << 8) | s2; \ 670 (code) = (s1 << 8) | s2; \
671 } while (0) 671 } while (0)
672 672
673/* Encode the file name NAME using the specified coding system 673/* Encode the file name NAME using the specified coding system for
674 for file names, if any. */ 674 file names, if any. If NAME is a unibyte string, return NAME. */
675#define ENCODE_FILE(name) \ 675#define ENCODE_FILE(name) \
676 (! NILP (Vfile_name_coding_system) \ 676 (! STRING_MULTIBYTE (name) \
677 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ 677 ? name \
678 : (! NILP (Vdefault_file_name_coding_system) \ 678 : (! NILP (Vfile_name_coding_system) \
679 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ 679 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
680 : name)) 680 : (! NILP (Vdefault_file_name_coding_system) \
681 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
682 : name)))
681 683
682 684
683/* Decode the file name NAME using the specified coding system 685/* Decode the file name NAME using the specified coding system
diff --git a/src/emacs.c b/src/emacs.c
index 928babb417c..52d2e76dc87 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -393,7 +393,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd)
393 initial_argv = argv; 393 initial_argv = argv;
394 initial_argc = argc; 394 initial_argc = argc;
395 395
396 raw_name = build_string (argv[0]); 396 raw_name = build_unibyte_string (argv[0]);
397 397
398 /* Add /: to the front of the name 398 /* Add /: to the front of the name
399 if it would otherwise be treated as magic. */ 399 if it would otherwise be treated as magic. */
@@ -427,7 +427,9 @@ init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd)
427 /* Emacs was started with relative path, like ./emacs. 427 /* Emacs was started with relative path, like ./emacs.
428 Make it absolute. */ 428 Make it absolute. */
429 { 429 {
430 Lisp_Object odir = original_pwd ? build_string (original_pwd) : Qnil; 430 Lisp_Object odir =
431 original_pwd ? build_unibyte_string (original_pwd) : Qnil;
432
431 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, odir); 433 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, odir);
432 } 434 }
433 435
@@ -2206,7 +2208,7 @@ decode_env_path (const char *evarname, const char *defalt)
2206 p = strchr (path, SEPCHAR); 2208 p = strchr (path, SEPCHAR);
2207 if (!p) 2209 if (!p)
2208 p = path + strlen (path); 2210 p = path + strlen (path);
2209 element = (p - path ? make_string (path, p - path) 2211 element = (p - path ? make_unibyte_string (path, p - path)
2210 : build_string (".")); 2212 : build_string ("."));
2211#ifdef WINDOWSNT 2213#ifdef WINDOWSNT
2212 /* Relative file names in the default path are interpreted as 2214 /* Relative file names in the default path are interpreted as
@@ -2216,7 +2218,7 @@ decode_env_path (const char *evarname, const char *defalt)
2216 element = Fexpand_file_name (Fsubstring (element, 2218 element = Fexpand_file_name (Fsubstring (element,
2217 make_number (emacs_dir_len), 2219 make_number (emacs_dir_len),
2218 Qnil), 2220 Qnil),
2219 build_string (emacs_dir)); 2221 build_unibyte_string (emacs_dir));
2220#endif 2222#endif
2221 2223
2222 /* Add /: to the front of the name 2224 /* Add /: to the front of the name
diff --git a/src/fileio.c b/src/fileio.c
index a1dcb72b4e4..884af25f9fc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -732,8 +732,8 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p;
732Lisp_Object 732Lisp_Object
733make_temp_name (Lisp_Object prefix, bool base64_p) 733make_temp_name (Lisp_Object prefix, bool base64_p)
734{ 734{
735 Lisp_Object val; 735 Lisp_Object val, encoded_prefix;
736 int len, clen; 736 int len;
737 printmax_t pid; 737 printmax_t pid;
738 char *p, *data; 738 char *p, *data;
739 char pidbuf[INT_BUFSIZE_BOUND (printmax_t)]; 739 char pidbuf[INT_BUFSIZE_BOUND (printmax_t)];
@@ -767,12 +767,11 @@ make_temp_name (Lisp_Object prefix, bool base64_p)
767#endif 767#endif
768 } 768 }
769 769
770 len = SBYTES (prefix); clen = SCHARS (prefix); 770 encoded_prefix = ENCODE_FILE (prefix);
771 val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen); 771 len = SBYTES (encoded_prefix);
772 if (!STRING_MULTIBYTE (prefix)) 772 val = make_uninit_string (len + 3 + pidlen);
773 STRING_SET_UNIBYTE (val);
774 data = SSDATA (val); 773 data = SSDATA (val);
775 memcpy (data, SSDATA (prefix), len); 774 memcpy (data, SSDATA (encoded_prefix), len);
776 p = data + len; 775 p = data + len;
777 776
778 memcpy (p, pidbuf, pidlen); 777 memcpy (p, pidbuf, pidlen);
@@ -810,7 +809,7 @@ make_temp_name (Lisp_Object prefix, bool base64_p)
810 { 809 {
811 /* We want to return only if errno is ENOENT. */ 810 /* We want to return only if errno is ENOENT. */
812 if (errno == ENOENT) 811 if (errno == ENOENT)
813 return val; 812 return DECODE_FILE (val);
814 else 813 else
815 /* The error here is dubious, but there is little else we 814 /* The error here is dubious, but there is little else we
816 can do. The alternatives are to return nil, which is 815 can do. The alternatives are to return nil, which is
@@ -987,7 +986,26 @@ filesystem tree, not (expand-file-name ".." dirname). */)
987 if (multibyte != STRING_MULTIBYTE (default_directory)) 986 if (multibyte != STRING_MULTIBYTE (default_directory))
988 { 987 {
989 if (multibyte) 988 if (multibyte)
990 default_directory = string_to_multibyte (default_directory); 989 {
990 unsigned char *p = SDATA (name);
991
992 while (*p && ASCII_BYTE_P (*p))
993 p++;
994 if (*p == '\0')
995 {
996 /* NAME is a pure ASCII string, and DEFAULT_DIRECTORY is
997 unibyte. Do not convert DEFAULT_DIRECTORY to
998 multibyte; instead, convert NAME to a unibyte string,
999 so that the result of this function is also a unibyte
1000 string. This is needed during bootstraping and
1001 dumping, when Emacs cannot decode file names, because
1002 the locale environment is not set up. */
1003 name = make_unibyte_string (SSDATA (name), SBYTES (name));
1004 multibyte = 0;
1005 }
1006 else
1007 default_directory = string_to_multibyte (default_directory);
1008 }
991 else 1009 else
992 { 1010 {
993 name = string_to_multibyte (name); 1011 name = string_to_multibyte (name);
diff --git a/src/lread.c b/src/lread.c
index b42ac5908e9..618b0cadb53 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1500,7 +1500,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1500 for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes; 1500 for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes;
1501 CONSP (tail); tail = XCDR (tail)) 1501 CONSP (tail); tail = XCDR (tail))
1502 { 1502 {
1503 ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail)); 1503 Lisp_Object suffix = XCAR (tail);
1504 ptrdiff_t fnlen, lsuffix = SBYTES (suffix);
1504 Lisp_Object handler; 1505 Lisp_Object handler;
1505 1506
1506 /* Concatenate path element/specified name with the suffix. 1507 /* Concatenate path element/specified name with the suffix.
@@ -1511,7 +1512,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1511 ? 2 : 0); 1512 ? 2 : 0);
1512 fnlen = SBYTES (filename) - prefixlen; 1513 fnlen = SBYTES (filename) - prefixlen;
1513 memcpy (fn, SDATA (filename) + prefixlen, fnlen); 1514 memcpy (fn, SDATA (filename) + prefixlen, fnlen);
1514 memcpy (fn + fnlen, SDATA (XCAR (tail)), lsuffix + 1); 1515 memcpy (fn + fnlen, SDATA (suffix), lsuffix + 1);
1515 fnlen += lsuffix; 1516 fnlen += lsuffix;
1516 /* Check that the file exists and is not a directory. */ 1517 /* Check that the file exists and is not a directory. */
1517 /* We used to only check for handlers on non-absolute file names: 1518 /* We used to only check for handlers on non-absolute file names:
@@ -1521,7 +1522,18 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1521 handler = Ffind_file_name_handler (filename, Qfile_exists_p); 1522 handler = Ffind_file_name_handler (filename, Qfile_exists_p);
1522 It's not clear why that was the case and it breaks things like 1523 It's not clear why that was the case and it breaks things like
1523 (load "/bar.el") where the file is actually "/bar.el.gz". */ 1524 (load "/bar.el") where the file is actually "/bar.el.gz". */
1524 string = make_string (fn, fnlen); 1525 /* make_string has its own ideas on when to return a unibyte
1526 string and when a multibyte string, but we know better.
1527 We must have a unibyte string when dumping, since
1528 file-name encoding is shaky at best at that time, and in
1529 particular default-file-name-coding-system is reset
1530 several times during loadup. We therefore don't want to
1531 encode the file before passing it to file I/O library
1532 functions. */
1533 if (!STRING_MULTIBYTE (filename) && !STRING_MULTIBYTE (suffix))
1534 string = make_unibyte_string (fn, fnlen);
1535 else
1536 string = make_string (fn, fnlen);
1525 handler = Ffind_file_name_handler (string, Qfile_exists_p); 1537 handler = Ffind_file_name_handler (string, Qfile_exists_p);
1526 if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate)) 1538 if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate))
1527 { 1539 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 9992fa4776a..382f9e7a8e1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9728,7 +9728,11 @@ message3_nolog (Lisp_Object m)
9728 putc ('\n', stderr); 9728 putc ('\n', stderr);
9729 noninteractive_need_newline = 0; 9729 noninteractive_need_newline = 0;
9730 if (STRINGP (m)) 9730 if (STRINGP (m))
9731 fwrite (SDATA (m), SBYTES (m), 1, stderr); 9731 {
9732 Lisp_Object s = ENCODE_SYSTEM (m);
9733
9734 fwrite (SDATA (s), SBYTES (s), 1, stderr);
9735 }
9732 if (cursor_in_echo_area == 0) 9736 if (cursor_in_echo_area == 0)
9733 fprintf (stderr, "\n"); 9737 fprintf (stderr, "\n");
9734 fflush (stderr); 9738 fflush (stderr);
@@ -9803,13 +9807,19 @@ message_with_string (const char *m, Lisp_Object string, int log)
9803 { 9807 {
9804 if (m) 9808 if (m)
9805 { 9809 {
9810 /* ENCODE_SYSTEM below can GC and/or relocate the Lisp
9811 String whose data pointer might be passed to us in M. So
9812 we use a local copy. */
9813 char *fmt = xstrdup (m);
9814
9806 if (noninteractive_need_newline) 9815 if (noninteractive_need_newline)
9807 putc ('\n', stderr); 9816 putc ('\n', stderr);
9808 noninteractive_need_newline = 0; 9817 noninteractive_need_newline = 0;
9809 fprintf (stderr, m, SDATA (string)); 9818 fprintf (stderr, fmt, SDATA (ENCODE_SYSTEM (string)));
9810 if (!cursor_in_echo_area) 9819 if (!cursor_in_echo_area)
9811 fprintf (stderr, "\n"); 9820 fprintf (stderr, "\n");
9812 fflush (stderr); 9821 fflush (stderr);
9822 xfree (fmt);
9813 } 9823 }
9814 } 9824 }
9815 else if (INTERACTIVE) 9825 else if (INTERACTIVE)