mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Don’t adjust CRLF in file names
* doc/misc/gnus.texi (Non-ASCII Group Names): * etc/NEWS: * test/lisp/net/tramp-tests.el (tramp--test-utf8): Use utf-8-unix, not utf-8, for default-file-name-coding-system, so that CRLF in file names is left alone. * lisp/international/mule-cmds.el (set-default-coding-systems): Do not alter CRLF in file name coding systems. (prefer-coding-system): Ignore differences in CRLF processing when checking whether we used the user-specified file name coding system. * test/src/fileio-tests.el: New file.
This commit is contained in:
parent
1c382c096b
commit
83f0d60e49
5 changed files with 67 additions and 10 deletions
|
|
@ -4340,10 +4340,10 @@ does not necessarily need to be the same value that is determined by
|
||||||
@code{gnus-group-name-charset-group-alist}.
|
@code{gnus-group-name-charset-group-alist}.
|
||||||
|
|
||||||
If @code{default-file-name-coding-system} or this variable is
|
If @code{default-file-name-coding-system} or this variable is
|
||||||
initialized by default to @code{iso-latin-1} for example, although you
|
initialized by default to @code{iso-latin-1-unix} for example, although you
|
||||||
want to subscribe to the groups spelled in Chinese, that is the most
|
want to subscribe to the groups spelled in Chinese, that is the most
|
||||||
typical case where you have to customize
|
typical case where you have to customize
|
||||||
@code{nnmail-pathname-coding-system}. The @code{utf-8} coding system is
|
@code{nnmail-pathname-coding-system}. The @code{utf-8-unix} coding system is
|
||||||
a good candidate for it. Otherwise, you may change the locale in your
|
a good candidate for it. Otherwise, you may change the locale in your
|
||||||
system so that @code{default-file-name-coding-system} or this variable
|
system so that @code{default-file-name-coding-system} or this variable
|
||||||
may be initialized to an appropriate value.
|
may be initialized to an appropriate value.
|
||||||
|
|
|
||||||
6
etc/NEWS
6
etc/NEWS
|
|
@ -1197,6 +1197,12 @@ this variable.
|
||||||
accepts Lisp symbols which begin with the following quotation
|
accepts Lisp symbols which begin with the following quotation
|
||||||
characters: ‘’‛“”‟〞"', unless they are escaped with backslash.
|
characters: ‘’‛“”‟〞"', unless they are escaped with backslash.
|
||||||
|
|
||||||
|
+++
|
||||||
|
** 'default-file-name-coding-system' now defaults to a coding system
|
||||||
|
that does not process CRLF. For example, it defaults to utf-8-unix
|
||||||
|
instead of to utf-8. Before this change, Emacs would sometimes
|
||||||
|
mishandle file names containing these control characters.
|
||||||
|
|
||||||
+++
|
+++
|
||||||
** Module functions are now implemented slightly differently; in
|
** Module functions are now implemented slightly differently; in
|
||||||
particular, the function 'internal--module-call' has been removed.
|
particular, the function 'internal--module-call' has been removed.
|
||||||
|
|
|
||||||
|
|
@ -354,11 +354,12 @@ This also sets the following values:
|
||||||
|
|
||||||
(if (eq system-type 'darwin)
|
(if (eq system-type 'darwin)
|
||||||
;; The file-name coding system on Darwin systems is always utf-8.
|
;; The file-name coding system on Darwin systems is always utf-8.
|
||||||
(setq default-file-name-coding-system 'utf-8)
|
(setq default-file-name-coding-system 'utf-8-unix)
|
||||||
(if (and (default-value 'enable-multibyte-characters)
|
(if (and (default-value 'enable-multibyte-characters)
|
||||||
(or (not coding-system)
|
(or (not coding-system)
|
||||||
(coding-system-get coding-system 'ascii-compatible-p)))
|
(coding-system-get coding-system 'ascii-compatible-p)))
|
||||||
(setq default-file-name-coding-system coding-system)))
|
(setq default-file-name-coding-system
|
||||||
|
(coding-system-change-eol-conversion coding-system 'unix))))
|
||||||
(setq default-terminal-coding-system coding-system)
|
(setq default-terminal-coding-system coding-system)
|
||||||
;; Prevent default-terminal-coding-system from converting ^M to ^J.
|
;; Prevent default-terminal-coding-system from converting ^M to ^J.
|
||||||
(setq default-keyboard-coding-system
|
(setq default-keyboard-coding-system
|
||||||
|
|
@ -414,7 +415,7 @@ To prefer, for instance, utf-8, say the following:
|
||||||
(coding-system-change-eol-conversion base eol-type)))
|
(coding-system-change-eol-conversion base eol-type)))
|
||||||
(set-default-coding-systems base)
|
(set-default-coding-systems base)
|
||||||
(if (called-interactively-p 'interactive)
|
(if (called-interactively-p 'interactive)
|
||||||
(or (eq base default-file-name-coding-system)
|
(or (eq base (coding-system-type default-file-name-coding-system))
|
||||||
(message "The default value of `file-name-coding-system' was not changed because the specified coding system is not suitable for file names.")))))
|
(message "The default value of `file-name-coding-system' was not changed because the specified coding system is not suitable for file names.")))))
|
||||||
|
|
||||||
(defvar sort-coding-systems-predicate nil
|
(defvar sort-coding-systems-predicate nil
|
||||||
|
|
@ -1797,9 +1798,9 @@ The default status is as follows:
|
||||||
|
|
||||||
(set-default-coding-systems nil)
|
(set-default-coding-systems nil)
|
||||||
(setq default-sendmail-coding-system 'iso-latin-1)
|
(setq default-sendmail-coding-system 'iso-latin-1)
|
||||||
;; On Darwin systems, this should be utf-8, but when this file is loaded
|
;; On Darwin systems, this should be utf-8-unix, but when this file is loaded
|
||||||
;; utf-8 is not yet defined, so we set it in set-locale-environment instead.
|
;; that is not yet defined, so we set it in set-locale-environment instead.
|
||||||
(setq default-file-name-coding-system 'iso-latin-1)
|
(setq default-file-name-coding-system 'iso-latin-1-unix)
|
||||||
;; Preserve eol-type from existing default-process-coding-systems.
|
;; Preserve eol-type from existing default-process-coding-systems.
|
||||||
;; On non-unix-like systems in particular, these may have been set
|
;; On non-unix-like systems in particular, these may have been set
|
||||||
;; carefully by the user, or by the startup code, to deal with the
|
;; carefully by the user, or by the startup code, to deal with the
|
||||||
|
|
@ -2722,7 +2723,7 @@ See also `locale-charset-language-names', `locale-language-names',
|
||||||
(when (eq system-type 'darwin)
|
(when (eq system-type 'darwin)
|
||||||
;; On Darwin, file names are always encoded in utf-8, no matter
|
;; On Darwin, file names are always encoded in utf-8, no matter
|
||||||
;; the locale.
|
;; the locale.
|
||||||
(setq default-file-name-coding-system 'utf-8)
|
(setq default-file-name-coding-system 'utf-8-unix)
|
||||||
;; macOS's Terminal.app by default uses utf-8 regardless of
|
;; macOS's Terminal.app by default uses utf-8 regardless of
|
||||||
;; the locale.
|
;; the locale.
|
||||||
(when (and (null window-system)
|
(when (and (null window-system)
|
||||||
|
|
|
||||||
|
|
@ -3719,7 +3719,8 @@ Use the `ls' command."
|
||||||
'utf-8-hfs 'utf-8))
|
'utf-8-hfs 'utf-8))
|
||||||
(coding-system-for-read utf8)
|
(coding-system-for-read utf8)
|
||||||
(coding-system-for-write utf8)
|
(coding-system-for-write utf8)
|
||||||
(file-name-coding-system utf8))
|
(file-name-coding-system
|
||||||
|
(coding-system-change-eol-conversion utf8 'unix)))
|
||||||
(tramp--test-check-files
|
(tramp--test-check-files
|
||||||
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
|
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
|
||||||
(unless (tramp--test-hpux-p)
|
(unless (tramp--test-hpux-p)
|
||||||
|
|
|
||||||
49
test/src/fileio-tests.el
Normal file
49
test/src/fileio-tests.el
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
;;; unit tests for src/fileio.c -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Copyright 2017 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
;; This file is part of GNU Emacs.
|
||||||
|
|
||||||
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
|
||||||
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
(require 'ert)
|
||||||
|
|
||||||
|
(defun try-char (char link)
|
||||||
|
(let ((target (string char)))
|
||||||
|
(make-symbolic-link target link)
|
||||||
|
(let* ((read-link (file-symlink-p link))
|
||||||
|
(failure (unless (string-equal target read-link)
|
||||||
|
(list 'string-equal target read-link))))
|
||||||
|
(delete-file link)
|
||||||
|
failure)))
|
||||||
|
|
||||||
|
(defun fileio-tests--symlink-failure ()
|
||||||
|
(let* ((dir (make-temp-file "fileio" t))
|
||||||
|
(link (expand-file-name "link" dir)))
|
||||||
|
(unwind-protect
|
||||||
|
(let ((failure
|
||||||
|
(let ((default-file-name-coding-system 'utf-8-unix))
|
||||||
|
(try-char (unibyte-char-to-multibyte 128) link)))
|
||||||
|
(char 0))
|
||||||
|
(while (and (not failure) (< char 300))
|
||||||
|
(setq char (1+ char))
|
||||||
|
(unless (= char ?~)
|
||||||
|
(setq failure (try-char char link))))
|
||||||
|
failure)
|
||||||
|
(delete-directory dir t))))
|
||||||
|
|
||||||
|
(ert-deftest fileio-tests--odd-symlink-chars ()
|
||||||
|
"Check that any non-NULL ASCII character can appear in a symlink.
|
||||||
|
Also check that an encoding error can appear in a symlink."
|
||||||
|
(should (equal nil (fileio-tests--symlink-failure))))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue