emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114943: Fix bug #15260 with building and installing


From: Eli Zaretskii
Subject: [Emacs-diffs] trunk r114943: Fix bug #15260 with building and installing Emacs in non-ASCII directories.
Date: Mon, 04 Nov 2013 17:33:05 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114943
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/15260
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Mon 2013-11-04 19:30:33 +0200
message:
  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.
modified:
  ChangeLog                      changelog-20091113204419-o5vbwnq5f7feedwu-1538
  configure.ac                   
configure.in-20091113204419-o5vbwnq5f7feedwu-783
  leim/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1629
  leim/Makefile.in               
makefile.in-20091113204419-o5vbwnq5f7feedwu-1200
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/Makefile.in               
makefile.in-20091113204419-o5vbwnq5f7feedwu-1831
  lisp/loadup.el                 loadup.el-20091113204419-o5vbwnq5f7feedwu-49
  lisp/startup.el                startup.el-20091113204419-o5vbwnq5f7feedwu-260
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/buffer.c                   buffer.c-20091113204419-o5vbwnq5f7feedwu-264
  src/callproc.c                 callproc.c-20091113204419-o5vbwnq5f7feedwu-248
  src/coding.h                   coding.h-20091113204419-o5vbwnq5f7feedwu-1078
  src/emacs.c                    emacs.c-20091113204419-o5vbwnq5f7feedwu-241
  src/fileio.c                   fileio.c-20091113204419-o5vbwnq5f7feedwu-210
  src/lread.c                    lread.c-20091113204419-o5vbwnq5f7feedwu-266
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'ChangeLog'
--- a/ChangeLog 2013-11-04 06:09:03 +0000
+++ b/ChangeLog 2013-11-04 17:30:33 +0000
@@ -1,3 +1,8 @@
+2013-11-04  Eli Zaretskii  <address@hidden>
+
+       * configure.ac: Don't disallow builds in non-ASCII directories.
+       (Bug#15260)
+
 2013-11-04  Paul Eggert  <address@hidden>
 
        Port to stricter C99 platforms.

=== modified file 'configure.ac'
--- a/configure.ac      2013-10-31 21:39:10 +0000
+++ b/configure.ac      2013-11-04 17:30:33 +0000
@@ -73,30 +73,6 @@
 dnl --program-transform-name options
 AC_ARG_PROGRAM
 
-dnl http://debbugs.gnu.org/15260
-dnl I think we have to check, eg, both exec_prefix and bindir,
-dnl because the latter by default is not yet expanded, but the user
-dnl may have specified a value for it via --bindir.
-dnl At first glance, _installing_ in non-ASCII seems ok, but in fact
-dnl it is not; see http://debbugs.gnu.org/15260#61
-dnl Note that abs_srcdir and abs_builddir are not yet defined. :(
-
-dnl "`cd \"$srcdir\"`" is not portable.
-dnl See autoconf manual "Shell Substitutions":
-dnl "There is just no portable way to use double-quoted strings inside
-dnl double-quoted back-quoted expressions (pfew!)."
-temp_srcdir=`cd "$srcdir"; pwd`
-
-for var in "`pwd`" "$temp_srcdir" "$prefix" "$exec_prefix" \
-    "$datarootdir" "$bindir" "$datadir" "$sharedstatedir" "$libexecdir"; do
-
-  dnl configure sets LC_ALL=C early on, so this range should work.
-  case "$var" in
-    *[[!\ -~]]*) AC_MSG_ERROR([Emacs cannot be built or installed in a 
directory whose name contains non-ASCII characters: $var]) ;;
-  esac
-
-done
-
 dnl It is important that variables on the RHS not be expanded here,
 dnl hence the single quotes.  This is per the GNU coding standards, see
 dnl (autoconf) Installation Directory Variables

=== modified file 'leim/ChangeLog'
--- a/leim/ChangeLog    2013-11-03 19:25:29 +0000
+++ b/leim/ChangeLog    2013-11-04 17:30:33 +0000
@@ -1,3 +1,7 @@
+2013-11-04  Eli Zaretskii  <address@hidden>
+
+       * Makefile.in (RUN_EMACS): Don't set LC_ALL=C.  (Bug#15260)
+
 2013-11-03  Glenn Morris  <address@hidden>
 
        * Makefile.in (abs_srcdir): Remove.

=== modified file 'leim/Makefile.in'
--- a/leim/Makefile.in  2013-11-03 19:25:29 +0000
+++ b/leim/Makefile.in  2013-11-04 17:30:33 +0000
@@ -32,7 +32,7 @@
 
 # How to run Emacs.
 # Prevent any setting of EMACSLOADPATH in user environment causing problems.
-RUN_EMACS = unset EMACSLOADPATH; LC_ALL=C "${EMACS}" -batch \
+RUN_EMACS = unset EMACSLOADPATH; "${EMACS}" -batch \
        --no-site-file --no-site-lisp
 
 MKDIR_P = @MKDIR_P@

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-11-04 16:04:09 +0000
+++ b/lisp/ChangeLog    2013-11-04 17:30:33 +0000
@@ -1,3 +1,16 @@
+2013-11-04  Eli Zaretskii  <address@hidden>
+
+       * 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].
+
+       * loadup.el: Error out if default-directory is a multibyte string
+       when we are dumping.
+
+       * Makefile.in (emacs): Don't set LC_ALL=C.  (Bug#15260)
+
 2013-11-04  Teodor Zlatanov  <address@hidden>
 
        * emacs-lisp/package.el (package-menu-mode)

=== modified file 'lisp/Makefile.in'
--- a/lisp/Makefile.in  2013-11-03 19:25:29 +0000
+++ b/lisp/Makefile.in  2013-11-04 17:30:33 +0000
@@ -106,7 +106,7 @@
 
 # The actual Emacs command run in the targets below.
 # Prevent any setting of EMACSLOADPATH in user environment causing problems.
-emacs = unset EMACSLOADPATH; LC_ALL=C "$(EMACS)" $(EMACSOPT)
+emacs = unset EMACSLOADPATH; "$(EMACS)" $(EMACSOPT)
 
 # Common command to find subdirectories
 setwins=subdirs=`find . -type d -print`; \

=== modified file 'lisp/loadup.el'
--- a/lisp/loadup.el    2013-10-08 15:11:29 +0000
+++ b/lisp/loadup.el    2013-11-04 17:30:33 +0000
@@ -286,6 +286,20 @@
 ;For other systems, you must edit ../src/Makefile.in.
 (load "site-load" t)
 
+;; Make sure default-directory is unibyte when dumping.  This is
+;; because we cannot decode and encode it correctly (since the locale
+;; environment is not, and should not be, set up).  default-directory
+;; is used every time we call expand-file-name, which we do in every
+;; file primitive.  So the only workable solution to support building
+;; in non-ASCII directories is to manipulate unibyte strings in the
+;; current locale's encoding.
+(if (and (or (equal (nth 3 command-line-args) "dump")
+            (equal (nth 4 command-line-args) "dump")
+            (equal (nth 3 command-line-args) "bootstrap")
+            (equal (nth 4 command-line-args) "bootstrap"))
+        (multibyte-string-p default-directory))
+    (error "default-directory must be unibyte when dumping Emacs!"))
+
 ;; Determine which last version number to use
 ;; based on the executables that now exist.
 (if (and (or (equal (nth 3 command-line-args) "dump")

=== modified file 'lisp/startup.el'
--- a/lisp/startup.el   2013-11-04 01:36:14 +0000
+++ b/lisp/startup.el   2013-11-04 17:30:33 +0000
@@ -489,6 +489,63 @@
   (if command-line-processed
       (message "Back to top level.")
     (setq command-line-processed t)
+
+    ;; Set the default strings to display in mode line for end-of-line
+    ;; formats that aren't native to this platform.  This should be
+    ;; done before calling set-locale-environment, as the latter might
+    ;; use these mnemonics.
+    (cond
+     ((memq system-type '(ms-dos windows-nt))
+      (setq eol-mnemonic-unix "(Unix)"
+           eol-mnemonic-mac  "(Mac)"))
+     (t                                   ; this is for Unix/GNU/Linux systems
+      (setq eol-mnemonic-dos  "(DOS)"
+           eol-mnemonic-mac  "(Mac)")))
+
+    (set-locale-environment nil)
+    ;; Decode all default-directory's (probably, only *scratch* exists
+    ;; at this point).  default-directory of *scratch* is the basis
+    ;; for many other file-name variables and directory lists, so it
+    ;; is important to decode it ASAP.
+    (when locale-coding-system
+      (save-excursion
+       (dolist (elt (buffer-list))
+         (set-buffer elt)
+         (if default-directory
+             (setq default-directory
+                   (decode-coding-string default-directory
+                                         locale-coding-system t)))))
+
+      ;; Decode all the important variables and directory lists, now
+      ;; that we know the locale's encoding.  This is because the
+      ;; values of these variables are until here unibyte undecoded
+      ;; strings created by build_unibyte_string.  data-directory in
+      ;; particular is used to construct many other standard directory
+      ;; names, so it must be decoded ASAP.
+      ;; Note that charset-map-path cannot be decoded here, since we
+      ;; could then be trapped in infinite recursion below, when we
+      ;; load subdirs.el, because encoding a directory name might need
+      ;; to load a charset map, which will want to encode
+      ;; charset-map-path, which will want to load the same charset
+      ;; map...  So decoding of charset-map-path is delayed until
+      ;; further down below.
+      (dolist (pathsym '(load-path exec-path))
+       (let ((path (symbol-value pathsym)))
+         (if (listp path)
+             (set pathsym (mapcar (lambda (dir)
+                                    (decode-coding-string
+                                     dir
+                                     locale-coding-system t))
+                               path)))))
+      (dolist (filesym '(data-directory doc-directory exec-directory
+                                       installation-directory
+                                       invocation-directory invocation-name
+                                       source-directory
+                                       shared-game-score-directory))
+       (let ((file (symbol-value filesym)))
+         (if (stringp file)
+             (set filesym (decode-coding-string file locale-coding-system 
t))))))
+
     (let ((dir default-directory))
       (with-current-buffer "*Messages*"
         (messages-buffer-mode)
@@ -536,6 +593,16 @@
               (setq process-environment
                     (delete (concat "PWD=" pwd)
                             process-environment)))))
+    ;; Now, that other directories were searched, and any charsets we
+    ;; need for encoding them are already loaded, we are ready to
+    ;; decode charset-map-path.
+    (if (listp charset-map-path)
+       (setq charset-map-path
+             (mapcar (lambda (dir)
+                       (decode-coding-string
+                        dir
+                        locale-coding-system t))
+                     charset-map-path)))
     (setq default-directory (abbreviate-file-name default-directory))
     (let ((old-face-font-rescale-alist face-font-rescale-alist))
       (unwind-protect
@@ -756,18 +823,6 @@
   ;;! ;; Choose a good default value for split-window-keep-point.
   ;;! (setq split-window-keep-point (> baud-rate 2400))
 
-  ;; Set the default strings to display in mode line for
-  ;; end-of-line formats that aren't native to this platform.
-  (cond
-   ((memq system-type '(ms-dos windows-nt))
-    (setq eol-mnemonic-unix "(Unix)"
-          eol-mnemonic-mac  "(Mac)"))
-   (t                                   ; this is for Unix/GNU/Linux systems
-    (setq eol-mnemonic-dos  "(DOS)"
-          eol-mnemonic-mac  "(Mac)")))
-
-  (set-locale-environment nil)
-
   ;; Convert preloaded file names in load-history to absolute.
   (let ((simple-file-name
         ;; Look for simple.el or simple.elc and use their directory
@@ -801,7 +856,7 @@
                    load-history))))
 
   ;; Convert the arguments to Emacs internal representation.
-  (let ((args (cdr command-line-args)))
+  (let ((args command-line-args))
     (while args
       (setcar args
              (decode-coding-string (car args) locale-coding-system t))
@@ -1211,19 +1266,6 @@
   (setq after-init-time (current-time))
   (run-hooks 'after-init-hook)
 
-  ;; Decode all default-directory.
-  (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
-      (save-excursion
-       (dolist (elt (buffer-list))
-         (set-buffer elt)
-         (if default-directory
-             (setq default-directory
-                   (decode-coding-string default-directory
-                                         locale-coding-system t))))
-       (setq command-line-default-directory
-             (decode-coding-string command-line-default-directory
-                                   locale-coding-system t))))
-
   ;; If *scratch* exists and init file didn't change its mode, initialize it.
   (if (get-buffer "*scratch*")
       (with-current-buffer "*scratch*"

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-11-04 06:09:03 +0000
+++ b/src/ChangeLog     2013-11-04 17:30:33 +0000
@@ -1,3 +1,34 @@
+2013-11-04  Eli Zaretskii  <address@hidden>
+
+       * xdisp.c (message3_nolog, message_with_string): Encode the string
+       before writing it to the terminal in a non-interactive session.
+
+       * lread.c (openp): If both FILENAME and SUFFIX are unibyte, make
+       sure we concatenate them into a unibyte string.
+
+       * 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.
+
+       * emacs.c (init_cmdargs): Use build_unibyte_string to make sure we
+       create unibyte strings from default paths and directory/file
+       names.
+
+       * coding.h (ENCODE_FILE): Do not attempt to encode a unibyte
+       string.
+
+       * callproc.c (init_callproc): Use build_unibyte_string to make
+       sure we create unibyte strings from default paths and
+       directory/file names.
+
+       * buffer.c (init_buffer): Don't store default-directory of
+       8scratch* 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.  (Bug#15260)
+
 2013-11-04  Paul Eggert  <address@hidden>
 
        Port to stricter C99 platforms.

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2013-11-04 06:09:03 +0000
+++ b/src/buffer.c      2013-11-04 17:30:33 +0000
@@ -5349,13 +5349,10 @@
       len++;
     }
 
+  /* At this moment, we still don't know how to decode the directory
+     name.  So, we keep the bytes in unibyte form so that file I/O
+     routines correctly get the original bytes.  */
   bset_directory (current_buffer, make_unibyte_string (pwd, len));
-  if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))
-    /* At this moment, we still don't know how to decode the
-       directory name.  So, we keep the bytes in multibyte form so
-       that ENCODE_FILE correctly gets the original bytes.  */
-    bset_directory
-      (current_buffer, string_to_multibyte (BVAR (current_buffer, directory)));
 
   /* Add /: to the front of the name
      if it would otherwise be treated as magic.  */

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2013-08-23 17:57:07 +0000
+++ b/src/callproc.c    2013-11-04 17:30:33 +0000
@@ -1612,14 +1612,14 @@
       Lisp_Object tem, tem1, srcdir;
 
       srcdir = Fexpand_file_name (build_string ("../src/"),
-                                 build_string (PATH_DUMPLOADSEARCH));
+                                 build_unibyte_string (PATH_DUMPLOADSEARCH));
       tem = Fexpand_file_name (build_string ("GNU"), Vdata_directory);
       tem1 = Ffile_exists_p (tem);
       if (!NILP (Fequal (srcdir, Vinvocation_directory)) || NILP (tem1))
        {
          Lisp_Object newdir;
          newdir = Fexpand_file_name (build_string ("../etc/"),
-                                     build_string (PATH_DUMPLOADSEARCH));
+                                     build_unibyte_string 
(PATH_DUMPLOADSEARCH));
          tem = Fexpand_file_name (build_string ("GNU"), newdir);
          tem1 = Ffile_exists_p (tem);
          if (!NILP (tem1))
@@ -1646,7 +1646,7 @@
 #ifdef DOS_NT
   Vshared_game_score_directory = Qnil;
 #else
-  Vshared_game_score_directory = build_string (PATH_GAME);
+  Vshared_game_score_directory = build_unibyte_string (PATH_GAME);
   if (NILP (Ffile_accessible_directory_p (Vshared_game_score_directory)))
     Vshared_game_score_directory = Qnil;
 #endif

=== modified file 'src/coding.h'
--- a/src/coding.h      2013-10-08 06:40:09 +0000
+++ b/src/coding.h      2013-11-04 17:30:33 +0000
@@ -670,14 +670,16 @@
     (code) = (s1 << 8) | s2;                           \
   } while (0)
 
-/* Encode the file name NAME using the specified coding system
-   for file names, if any.  */
-#define ENCODE_FILE(name)                                                 \
-  (! NILP (Vfile_name_coding_system)                                      \
-   ? code_convert_string_norecord (name, Vfile_name_coding_system, 1)     \
-   : (! NILP (Vdefault_file_name_coding_system)                                
   \
-      ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 
1) \
-      : name))
+/* Encode the file name NAME using the specified coding system for
+   file names, if any.  If NAME is a unibyte string, return NAME.  */
+#define ENCODE_FILE(name)                                              \
+    (! STRING_MULTIBYTE (name)                                         \
+     ? name                                                            \
+     : (! NILP (Vfile_name_coding_system)                              \
+       ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
+       : (! NILP (Vdefault_file_name_coding_system)                    \
+          ? code_convert_string_norecord (name, 
Vdefault_file_name_coding_system, 1) \
+          : name)))
 
 
 /* Decode the file name NAME using the specified coding system

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2013-11-04 01:38:16 +0000
+++ b/src/emacs.c       2013-11-04 17:30:33 +0000
@@ -393,7 +393,7 @@
   initial_argv = argv;
   initial_argc = argc;
 
-  raw_name = build_string (argv[0]);
+  raw_name = build_unibyte_string (argv[0]);
 
   /* Add /: to the front of the name
      if it would otherwise be treated as magic.  */
@@ -427,7 +427,9 @@
     /* Emacs was started with relative path, like ./emacs.
        Make it absolute.  */
     {
-      Lisp_Object odir = original_pwd ? build_string (original_pwd) : Qnil;
+      Lisp_Object odir =
+       original_pwd ? build_unibyte_string (original_pwd) : Qnil;
+
       Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, odir);
     }
 
@@ -2206,7 +2208,7 @@
       p = strchr (path, SEPCHAR);
       if (!p)
        p = path + strlen (path);
-      element = (p - path ? make_string (path, p - path)
+      element = (p - path ? make_unibyte_string (path, p - path)
                 : build_string ("."));
 #ifdef WINDOWSNT
       /* Relative file names in the default path are interpreted as
@@ -2216,7 +2218,7 @@
        element = Fexpand_file_name (Fsubstring (element,
                                                 make_number (emacs_dir_len),
                                                 Qnil),
-                                    build_string (emacs_dir));
+                                    build_unibyte_string (emacs_dir));
 #endif
 
       /* Add /: to the front of the name

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2013-10-17 06:42:21 +0000
+++ b/src/fileio.c      2013-11-04 17:30:33 +0000
@@ -732,8 +732,8 @@
 Lisp_Object
 make_temp_name (Lisp_Object prefix, bool base64_p)
 {
-  Lisp_Object val;
-  int len, clen;
+  Lisp_Object val, encoded_prefix;
+  int len;
   printmax_t pid;
   char *p, *data;
   char pidbuf[INT_BUFSIZE_BOUND (printmax_t)];
@@ -767,12 +767,11 @@
 #endif
     }
 
-  len = SBYTES (prefix); clen = SCHARS (prefix);
-  val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen);
-  if (!STRING_MULTIBYTE (prefix))
-    STRING_SET_UNIBYTE (val);
+  encoded_prefix = ENCODE_FILE (prefix);
+  len = SBYTES (encoded_prefix);
+  val = make_uninit_string (len + 3 + pidlen);
   data = SSDATA (val);
-  memcpy (data, SSDATA (prefix), len);
+  memcpy (data, SSDATA (encoded_prefix), len);
   p = data + len;
 
   memcpy (p, pidbuf, pidlen);
@@ -810,7 +809,7 @@
        {
          /* We want to return only if errno is ENOENT.  */
          if (errno == ENOENT)
-           return val;
+           return DECODE_FILE (val);
          else
            /* The error here is dubious, but there is little else we
               can do.  The alternatives are to return nil, which is
@@ -987,7 +986,26 @@
   if (multibyte != STRING_MULTIBYTE (default_directory))
     {
       if (multibyte)
-       default_directory = string_to_multibyte (default_directory);
+       {
+         unsigned char *p = SDATA (name);
+
+         while (*p && ASCII_BYTE_P (*p))
+           p++;
+         if (*p == '\0')
+           {
+             /* NAME is a pure ASCII string, and DEFAULT_DIRECTORY is
+                unibyte.  Do not convert DEFAULT_DIRECTORY to
+                multibyte; instead, convert NAME to a unibyte string,
+                so that the result of this function is also a unibyte
+                string.  This is needed during bootstraping and
+                dumping, when Emacs cannot decode file names, because
+                the locale environment is not set up.  */
+             name = make_unibyte_string (SSDATA (name), SBYTES (name));
+             multibyte = 0;
+           }
+         else
+           default_directory = string_to_multibyte (default_directory);
+       }
       else
        {
          name = string_to_multibyte (name);

=== modified file 'src/lread.c'
--- a/src/lread.c       2013-11-04 06:09:03 +0000
+++ b/src/lread.c       2013-11-04 17:30:33 +0000
@@ -1500,7 +1500,8 @@
       for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes;
           CONSP (tail); tail = XCDR (tail))
        {
-         ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail));
+         Lisp_Object suffix = XCAR (tail);
+         ptrdiff_t fnlen, lsuffix = SBYTES (suffix);
          Lisp_Object handler;
 
          /* Concatenate path element/specified name with the suffix.
@@ -1511,7 +1512,7 @@
                           ? 2 : 0);
          fnlen = SBYTES (filename) - prefixlen;
          memcpy (fn, SDATA (filename) + prefixlen, fnlen);
-         memcpy (fn + fnlen, SDATA (XCAR (tail)), lsuffix + 1);
+         memcpy (fn + fnlen, SDATA (suffix), lsuffix + 1);
          fnlen += lsuffix;
          /* Check that the file exists and is not a directory.  */
          /* We used to only check for handlers on non-absolute file names:
@@ -1521,7 +1522,18 @@
                  handler = Ffind_file_name_handler (filename, Qfile_exists_p);
             It's not clear why that was the case and it breaks things like
             (load "/bar.el") where the file is actually "/bar.el.gz".  */
-         string = make_string (fn, fnlen);
+         /* make_string has its own ideas on when to return a unibyte
+            string and when a multibyte string, but we know better.
+            We must have a unibyte string when dumping, since
+            file-name encoding is shaky at best at that time, and in
+            particular default-file-name-coding-system is reset
+            several times during loadup.  We therefore don't want to
+            encode the file before passing it to file I/O library
+            functions.  */
+         if (!STRING_MULTIBYTE (filename) && !STRING_MULTIBYTE (suffix))
+           string = make_unibyte_string (fn, fnlen);
+         else
+           string = make_string (fn, fnlen);
          handler = Ffind_file_name_handler (string, Qfile_exists_p);
          if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate))
             {

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-11-04 06:09:03 +0000
+++ b/src/xdisp.c       2013-11-04 17:30:33 +0000
@@ -9728,7 +9728,11 @@
        putc ('\n', stderr);
       noninteractive_need_newline = 0;
       if (STRINGP (m))
-       fwrite (SDATA (m), SBYTES (m), 1, stderr);
+       {
+         Lisp_Object s = ENCODE_SYSTEM (m);
+
+         fwrite (SDATA (s), SBYTES (s), 1, stderr);
+       }
       if (cursor_in_echo_area == 0)
        fprintf (stderr, "\n");
       fflush (stderr);
@@ -9803,13 +9807,19 @@
     {
       if (m)
        {
+         /* ENCODE_SYSTEM below can GC and/or relocate the Lisp
+            String whose data pointer might be passed to us in M.  So
+            we use a local copy.  */
+         char *fmt = xstrdup (m);
+
          if (noninteractive_need_newline)
            putc ('\n', stderr);
          noninteractive_need_newline = 0;
-         fprintf (stderr, m, SDATA (string));
+         fprintf (stderr, fmt, SDATA (ENCODE_SYSTEM (string)));
          if (!cursor_in_echo_area)
            fprintf (stderr, "\n");
          fflush (stderr);
+         xfree (fmt);
        }
     }
   else if (INTERACTIVE)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]