Merge from mainline.
authorEli Zaretskii <eliz@gnu.org>
Mon, 18 Nov 2013 16:45:48 +0000 (18:45 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 18 Nov 2013 16:45:48 +0000 (18:45 +0200)
1  2 
src/coding.c
src/emacs.c
src/fileio.c
src/msdos.c
src/w32.c
src/w32fns.c
src/w32term.c

diff --cc src/coding.c
@@@ -9473,49 -9490,6 +9490,55 @@@ code_convert_string_norecord (Lisp_Obje
    return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
  }
  
 +/* Encode or decode a file name, to or from a unibyte string suitable
 +   for passing to C library functions.  */
 +Lisp_Object
 +decode_file_name (Lisp_Object fname)
 +{
 +#ifdef WINDOWSNT
 +  /* The w32 build pretends to use UTF-8 for file-name encoding, and
 +     converts the file names either to UTF-16LE or to the system ANSI
 +     codepage internally, depending on the underlying OS; see w32.c.  */
 +  if (! NILP (Fcoding_system_p (Qutf_8)))
 +    return code_convert_string_norecord (fname, Qutf_8, 0);
 +  return fname;
 +#else  /* !WINDOWSNT */
 +  if (! NILP (Vfile_name_coding_system))
 +    return code_convert_string_norecord (fname, Vfile_name_coding_system, 0);
 +  else if (! NILP (Vdefault_file_name_coding_system))
 +    return code_convert_string_norecord (fname,
 +                                       Vdefault_file_name_coding_system, 0);
 +  else
 +    return fname;
 +#endif
 +}
 +
 +Lisp_Object
 +encode_file_name (Lisp_Object fname)
 +{
++  /* This is especially important during bootstrap and dumping, when
++     file-name encoding is not yet known, and therefore any non-ASCII
++     file names are unibyte strings, and could only be thrashed if we
++     try to encode them.  */
++  if (!STRING_MULTIBYTE (fname))
++    return fname;
 +#ifdef WINDOWSNT
 +  /* The w32 build pretends to use UTF-8 for file-name encoding, and
 +     converts the file names either to UTF-16LE or to the system ANSI
 +     codepage internally, depending on the underlying OS; see w32.c.  */
 +  if (! NILP (Fcoding_system_p (Qutf_8)))
 +    return code_convert_string_norecord (fname, Qutf_8, 1);
 +  return fname;
 +#else  /* !WINDOWSNT */
 +  if (! NILP (Vfile_name_coding_system))
 +    return code_convert_string_norecord (fname, Vfile_name_coding_system, 1);
 +  else if (! NILP (Vdefault_file_name_coding_system))
 +    return code_convert_string_norecord (fname,
 +                                       Vdefault_file_name_coding_system, 1);
 +  else
 +    return fname;
 +#endif
 +}
  
  DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string,
         2, 4, 0,
diff --cc src/emacs.c
Simple merge
diff --cc src/fileio.c
Simple merge
diff --cc src/msdos.c
Simple merge
diff --cc src/w32.c
Simple merge
diff --cc src/w32fns.c
Simple merge
diff --cc src/w32term.c
Simple merge