aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-02-03 00:03:44 +0100
committerJoakim Verona2013-02-03 00:03:44 +0100
commitcfefa7e817861c3fdf541becf7fbcfa00fa16858 (patch)
tree1a3ed70e7761f27ff2e882ba5148bdb3e4b62231
parent9aa1f4ecdb156a4135c3f7f6125a2b5a40258038 (diff)
parent8ea41ea99608c7483ef5c91e230a760cf90bfb54 (diff)
downloademacs-cfefa7e817861c3fdf541becf7fbcfa00fa16858.tar.gz
emacs-cfefa7e817861c3fdf541becf7fbcfa00fa16858.zip
auto upstream
-rw-r--r--lisp/ChangeLog45
-rw-r--r--lisp/cedet/cedet.el14
-rw-r--r--lisp/cedet/ede.el4
-rw-r--r--lisp/cedet/semantic.el4
-rw-r--r--lisp/cedet/srecode.el4
-rw-r--r--lisp/emacs-lisp/eieio.el4
-rw-r--r--lisp/isearch.el1
-rw-r--r--lisp/mouse.el2
-rw-r--r--lisp/net/tramp.el4
-rw-r--r--lisp/progmodes/cc-awk.el5
-rw-r--r--lisp/progmodes/compile.el16
-rw-r--r--lisp/progmodes/grep.el4
-rw-r--r--lisp/progmodes/make-mode.el6
-rw-r--r--lisp/progmodes/python.el2
-rw-r--r--lisp/replace.el102
-rw-r--r--lisp/simple.el2
-rw-r--r--lisp/textmodes/remember.el3
-rw-r--r--src/ChangeLog65
-rw-r--r--src/callproc.c50
-rw-r--r--src/dired.c4
-rw-r--r--src/emacs.c2
-rw-r--r--src/fileio.c144
-rw-r--r--src/msdos.c6
-rw-r--r--src/msdos.h2
-rw-r--r--src/termcap.c2
-rw-r--r--src/unexw32.c2
-rw-r--r--src/w32.c23
-rw-r--r--src/w32.h2
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32proc.c8
30 files changed, 336 insertions, 198 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9fba2817b1e..fdf12be0a1c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,48 @@
12013-02-02 Christopher Schmidt <christopher@ch.ristopher.com>
2
3 * progmodes/compile.el (compilation-error-regexp-alist-alist):
4 Identify g++ template instantiation trace. (Bug#12287)
5 (compilation-mode-hook, compilation-start-hook)
6 (compilation-window-height): Simplify docstrings. (Bug#13379)
7
82013-02-02 Stefan Monnier <monnier@iro.umontreal.ca>
9
10 * mouse.el (mouse-drag-track): Always deactivate the mark before
11 running the final event's command since that command is in charge of
12 activating the mark if needed (bug#13523).
13
142013-02-02 Juri Linkov <juri@jurta.org>
15
16 * replace.el (perform-replace): Move let-bindings of isearch-*
17 variables deeper to the loop that searches for the next match.
18 Add bindings for `isearch-nonincremental' and `isearch-adjusted'.
19 Use `isearch-search-fun-default' instead of `isearch-search-fun'.
20 (Bug#13579)
21
22 * isearch.el (isearch-search-fun-default): Check for null
23 first element of isearch-cmds as a precaution when it's used
24 with inactive isearch.
25
262013-02-02 Andrew W. Nosenko <andrew.w.nosenko@gmail.com> (tiny change)
27
28 * net/tramp.el (tramp-check-for-regexp): Avoid "Args out of range"
29 error when buffer in question is narrowed so position 1 is out of
30 visible part.
31
322013-02-02 Glenn Morris <rgm@gnu.org>
33
34 * textmodes/remember.el (remember-clipboard): Doc fix.
35
362013-02-02 Stefan Monnier <monnier@iro.umontreal.ca>
37
38 * progmodes/make-mode.el (makefile-fill-paragraph): Reset syntax-table
39 properties (bug#13179).
40
412013-02-02 Juri Linkov <juri@jurta.org>
42
43 * progmodes/grep.el (grep-regexp-alist): Use variable grep-match-face
44 instead of hard-coded default face `match'. (Bug#9438)
45
12012-02-01 Christopher Schmidt <christopher@ch.ristopher.com> 462012-02-01 Christopher Schmidt <christopher@ch.ristopher.com>
2 47
3 * vc/vc-arch.el (vc-arch-registered): 48 * vc/vc-arch.el (vc-arch-registered):
diff --git a/lisp/cedet/cedet.el b/lisp/cedet/cedet.el
index d876b65303c..e8720bc6624 100644
--- a/lisp/cedet/cedet.el
+++ b/lisp/cedet/cedet.el
@@ -4,7 +4,7 @@
4 4
5;; Author: David Ponce <david@dponce.com> 5;; Author: David Ponce <david@dponce.com>
6;; Maintainer: Eric M. Ludlam <zappo@gnu.org> 6;; Maintainer: Eric M. Ludlam <zappo@gnu.org>
7;; Version: 1.1 7;; Version: 2.0
8;; Keywords: OO, lisp 8;; Keywords: OO, lisp
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -35,7 +35,7 @@
35 35
36(declare-function inversion-find-version "inversion") 36(declare-function inversion-find-version "inversion")
37 37
38(defconst cedet-version "1.1" 38(defconst cedet-version "2.0"
39 "Current version of CEDET.") 39 "Current version of CEDET.")
40 40
41(defconst cedet-packages 41(defconst cedet-packages
@@ -43,12 +43,12 @@
43 ;;PACKAGE MIN-VERSION INSTALLDIR DOCDIR 43 ;;PACKAGE MIN-VERSION INSTALLDIR DOCDIR
44 (cedet ,cedet-version "common" "common" ) 44 (cedet ,cedet-version "common" "common" )
45 (eieio "1.4" nil "eieio" ) 45 (eieio "1.4" nil "eieio" )
46 (semantic "2.1" nil "semantic/doc") 46 (semantic "2.2" nil "semantic/doc")
47 (srecode "1.1" nil "srecode" ) 47 (srecode "1.2" nil "srecode" )
48 (ede "1.1" nil "ede" ) 48 (ede "1.2" nil "ede" )
49 (speedbar "1.0.4" nil "speedbar" ) 49 (speedbar "1.0.4" nil "speedbar" )
50 (cogre "1.1" nil "cogre" ) 50 (cogre "1.2" nil "cogre" )
51 (cedet-contrib "1.1" "contrib" nil ) 51 (cedet-contrib "1.2" "contrib" nil )
52 ) 52 )
53 "Table of CEDET packages to install.") 53 "Table of CEDET packages to install.")
54 54
diff --git a/lisp/cedet/ede.el b/lisp/cedet/ede.el
index 12b8f558d65..3867f628b93 100644
--- a/lisp/cedet/ede.el
+++ b/lisp/cedet/ede.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Eric M. Ludlam <zappo@gnu.org> 5;; Author: Eric M. Ludlam <zappo@gnu.org>
6;; Keywords: project, make 6;; Keywords: project, make
7;; Version: 1.0 7;; Version: 1.2
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10 10
@@ -60,7 +60,7 @@
60(declare-function ede-up-directory "ede/files") 60(declare-function ede-up-directory "ede/files")
61(declare-function semantic-lex-make-spp-table "semantic/lex-spp") 61(declare-function semantic-lex-make-spp-table "semantic/lex-spp")
62 62
63(defconst ede-version "1.0" 63(defconst ede-version "1.2"
64 "Current version of the Emacs EDE.") 64 "Current version of the Emacs EDE.")
65 65
66;;; Code: 66;;; Code:
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index decd3b15812..edf2d0cb21a 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Eric M. Ludlam <zappo@gnu.org> 5;; Author: Eric M. Ludlam <zappo@gnu.org>
6;; Keywords: syntax tools 6;; Keywords: syntax tools
7;; Version: 2.1beta 7;; Version: 2.2
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10 10
@@ -38,7 +38,7 @@
38(require 'semantic/tag) 38(require 'semantic/tag)
39(require 'semantic/lex) 39(require 'semantic/lex)
40 40
41(defvar semantic-version "2.1beta" 41(defvar semantic-version "2.2"
42 "Current version of Semantic.") 42 "Current version of Semantic.")
43 43
44(declare-function inversion-test "inversion") 44(declare-function inversion-test "inversion")
diff --git a/lisp/cedet/srecode.el b/lisp/cedet/srecode.el
index 3201374bc92..2e2cb8a3f80 100644
--- a/lisp/cedet/srecode.el
+++ b/lisp/cedet/srecode.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Eric M. Ludlam <zappo@gnu.org> 5;; Author: Eric M. Ludlam <zappo@gnu.org>
6;; Keywords: codegeneration 6;; Keywords: codegeneration
7;; Version: 1.0 7;; Version: 1.2
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10 10
@@ -41,7 +41,7 @@
41(require 'mode-local) 41(require 'mode-local)
42(load "srecode/loaddefs" nil 'nomessage) 42(load "srecode/loaddefs" nil 'nomessage)
43 43
44(defvar srecode-version "1.0" 44(defvar srecode-version "1.2"
45 "Current version of the Semantic Recoder.") 45 "Current version of the Semantic Recoder.")
46 46
47;;; Code: 47;;; Code:
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 7a22e1222c9..626bc0f6dc6 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -4,7 +4,7 @@
4;; Copyright (C) 1995-1996, 1998-2013 Free Software Foundation, Inc. 4;; Copyright (C) 1995-1996, 1998-2013 Free Software Foundation, Inc.
5 5
6;; Author: Eric M. Ludlam <zappo@gnu.org> 6;; Author: Eric M. Ludlam <zappo@gnu.org>
7;; Version: 1.3 7;; Version: 1.4
8;; Keywords: OO, lisp 8;; Keywords: OO, lisp
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -46,7 +46,7 @@
46 46
47(eval-when-compile (require 'cl)) ;FIXME: Use cl-lib! 47(eval-when-compile (require 'cl)) ;FIXME: Use cl-lib!
48 48
49(defvar eieio-version "1.3" 49(defvar eieio-version "1.4"
50 "Current version of EIEIO.") 50 "Current version of EIEIO.")
51 51
52(defun eieio-version () 52(defun eieio-version ()
diff --git a/lisp/isearch.el b/lisp/isearch.el
index e16e3840d0d..31b1918429f 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2520,6 +2520,7 @@ Can be changed via `isearch-search-fun-function' for special needs."
2520 ;; the user adds and removes characters in the search string 2520 ;; the user adds and removes characters in the search string
2521 ;; (or when using nonincremental word isearch) 2521 ;; (or when using nonincremental word isearch)
2522 (let ((lax (not (or isearch-nonincremental 2522 (let ((lax (not (or isearch-nonincremental
2523 (null (car isearch-cmds))
2523 (eq (length isearch-string) 2524 (eq (length isearch-string)
2524 (length (isearch--state-string 2525 (length (isearch--state-string
2525 (car isearch-cmds)))))))) 2526 (car isearch-cmds))))))))
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 9c7bf6f9c36..a1aa104495a 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -880,9 +880,9 @@ DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by
880 (copy-region-as-kill (mark) (point))))) 880 (copy-region-as-kill (mark) (point)))))
881 881
882 ;; Otherwise, run binding of terminating up-event. 882 ;; Otherwise, run binding of terminating up-event.
883 (deactivate-mark)
883 (if do-multi-click 884 (if do-multi-click
884 (goto-char start-point) 885 (goto-char start-point)
885 (deactivate-mark)
886 (unless moved-off-start 886 (unless moved-off-start
887 (pop-mark))) 887 (pop-mark)))
888 888
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 4f31e95aeff..1dee9e89676 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3413,7 +3413,9 @@ Erase echoed commands if exists."
3413 0 (min tramp-echo-mark-marker-length (1- (point-max)))) 3413 0 (min tramp-echo-mark-marker-length (1- (point-max))))
3414 (tramp-compat-funcall 3414 (tramp-compat-funcall
3415 'buffer-substring-no-properties 3415 'buffer-substring-no-properties
3416 1 (min (1+ tramp-echo-mark-marker-length) (point-max)))))) 3416 (point-min)
3417 (min (+ (point-min) tramp-echo-mark-marker-length)
3418 (point-max))))))
3417 ;; No echo to be handled, now we can look for the regexp. 3419 ;; No echo to be handled, now we can look for the regexp.
3418 ;; Sometimes, lines are much to long, and we run into a "Stack 3420 ;; Sometimes, lines are much to long, and we run into a "Stack
3419 ;; overflow in regexp matcher". For example, //DIRED// lines of 3421 ;; overflow in regexp matcher". For example, //DIRED// lines of
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el
index 0711bc983e8..4b3fc91b0ff 100644
--- a/lisp/progmodes/cc-awk.el
+++ b/lisp/progmodes/cc-awk.el
@@ -142,7 +142,7 @@
142 142
143(defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]") 143(defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]")
144;; Matches any character but a _, #, /, ", \, or newline. N.B. _" starts a 144;; Matches any character but a _, #, /, ", \, or newline. N.B. _" starts a
145;; localisation string in gawk 3.1 145;; localization string in gawk 3.1
146(defconst c-awk-harmless-line-string*-re 146(defconst c-awk-harmless-line-string*-re
147 (concat "\\(" c-awk-harmless-line-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")) 147 (concat "\\(" c-awk-harmless-line-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*"))
148;; Matches a (possibly empty) sequence of chars without unescaped /, ", \, 148;; Matches a (possibly empty) sequence of chars without unescaped /, ", \,
@@ -795,7 +795,8 @@
795 (setq anchor (point)) 795 (setq anchor (point))
796 (search-forward-regexp c-awk-harmless-string*-here-re nil t) 796 (search-forward-regexp c-awk-harmless-string*-here-re nil t)
797 ;; We are now looking at either a " or a / or a brace/paren/semicolon. 797 ;; We are now looking at either a " or a / or a brace/paren/semicolon.
798 ;; Do our thing on the string, regexp or divsion sign or update our state. 798 ;; Do our thing on the string, regexp or division sign or update
799 ;; our state.
799 (setq anchor-state-/div 800 (setq anchor-state-/div
800 (cond 801 (cond
801 ((looking-at "_?\"") 802 ((looking-at "_?\"")
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index eb73b77bf52..d2a9617e28e 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -42,24 +42,21 @@
42 42
43;;;###autoload 43;;;###autoload
44(defcustom compilation-mode-hook nil 44(defcustom compilation-mode-hook nil
45 "List of hook functions run by `compilation-mode' (see `run-mode-hooks')." 45 "List of hook functions run by `compilation-mode'."
46 :type 'hook 46 :type 'hook
47 :group 'compilation) 47 :group 'compilation)
48 48
49;;;###autoload 49;;;###autoload
50(defcustom compilation-start-hook nil 50(defcustom compilation-start-hook nil
51 "List of hook functions run by `compilation-start' on the compilation process. 51 "Hook run after starting a new compilation process.
52\(See `run-hook-with-args'). 52The hook is run with one argument, the new process."
53If you use \"omake -P\" and do not want \\[save-buffers-kill-terminal] to ask whether you want
54the compilation to be killed, you can use this hook:
55 (add-hook 'compilation-start-hook
56 (lambda (process) (set-process-query-on-exit-flag process nil)) nil t)"
57 :type 'hook 53 :type 'hook
58 :group 'compilation) 54 :group 'compilation)
59 55
60;;;###autoload 56;;;###autoload
61(defcustom compilation-window-height nil 57(defcustom compilation-window-height nil
62 "Number of lines in a compilation window. If nil, use Emacs default." 58 "Number of lines in a compilation window.
59If nil, use Emacs default."
63 :type '(choice (const :tag "Default" nil) 60 :type '(choice (const :tag "Default" nil)
64 integer) 61 integer)
65 :group 'compilation) 62 :group 'compilation)
@@ -265,7 +262,8 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
265\\([0-9]+\\)\\(?:-\\(?4:[0-9]+\\)\\(?:\\.\\(?5:[0-9]+\\)\\)?\ 262\\([0-9]+\\)\\(?:-\\(?4:[0-9]+\\)\\(?:\\.\\(?5:[0-9]+\\)\\)?\
266\\|[.:]\\(?3:[0-9]+\\)\\(?:-\\(?:\\(?4:[0-9]+\\)\\.\\)?\\(?5:[0-9]+\\)\\)?\\)?:\ 263\\|[.:]\\(?3:[0-9]+\\)\\(?:-\\(?:\\(?4:[0-9]+\\)\\.\\)?\\(?5:[0-9]+\\)\\)?\\)?:\
267\\(?: *\\(\\(?:Future\\|Runtime\\)?[Ww]arning\\|W:\\)\\|\ 264\\(?: *\\(\\(?:Future\\|Runtime\\)?[Ww]arning\\|W:\\)\\|\
268 *\\([Ii]nfo\\(?:\\>\\|rmationa?l?\\)\\|I:\\|instantiated from\\|[Nn]ote\\)\\|\ 265 *\\([Ii]nfo\\(?:\\>\\|rmationa?l?\\)\\|I:\\|\\[ skipping .+ \\]\\|\
266\\(?:instantiated\\|required\\) from\\|[Nn]ote\\)\\|\
269 *[Ee]rror\\|[0-9]?\\(?:[^0-9\n]\\|$\\)\\|[0-9][0-9][0-9]\\)" 267 *[Ee]rror\\|[0-9]?\\(?:[^0-9\n]\\|$\\)\\|[0-9][0-9][0-9]\\)"
270 1 (2 . 4) (3 . 5) (6 . 7)) 268 1 (2 . 4) (3 . 5) (6 . 7))
271 269
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index ef321addf24..d8c39f2ddef 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -359,7 +359,7 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
359 (when grep-highlight-matches 359 (when grep-highlight-matches
360 (let* ((beg (match-end 0)) 360 (let* ((beg (match-end 0))
361 (end (save-excursion (goto-char beg) (line-end-position))) 361 (end (save-excursion (goto-char beg) (line-end-position)))
362 (mbeg (text-property-any beg end 'font-lock-face 'match))) 362 (mbeg (text-property-any beg end 'font-lock-face grep-match-face)))
363 (when mbeg 363 (when mbeg
364 (- mbeg beg))))) 364 (- mbeg beg)))))
365 . 365 .
@@ -367,7 +367,7 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
367 (when grep-highlight-matches 367 (when grep-highlight-matches
368 (let* ((beg (match-end 0)) 368 (let* ((beg (match-end 0))
369 (end (save-excursion (goto-char beg) (line-end-position))) 369 (end (save-excursion (goto-char beg) (line-end-position)))
370 (mbeg (text-property-any beg end 'font-lock-face 'match)) 370 (mbeg (text-property-any beg end 'font-lock-face grep-match-face))
371 (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) 371 (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end))))
372 (when mend 372 (when mend
373 (- mend beg))))))) 373 (- mend beg)))))))
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index be718135f99..20673866bc4 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -1304,6 +1304,12 @@ Fill comments, backslashed lines, and variable definitions specially."
1304 (save-restriction 1304 (save-restriction
1305 (narrow-to-region beginning end) 1305 (narrow-to-region beginning end)
1306 (makefile-backslash-region (point-min) (point-max) t) 1306 (makefile-backslash-region (point-min) (point-max) t)
1307 ;; Backslashed newlines are marked as punctuation, so when
1308 ;; fill-delete-newlines turns the LF into SPC, we end up with spaces
1309 ;; which back-to-indentation (called via fill-newline ->
1310 ;; fill-indent-to-left-margin -> indent-line-to) thinks are real code
1311 ;; (bug#13179).
1312 (remove-text-properties (point-min) (point-max) '(syntax-table))
1307 (let ((fill-paragraph-function nil) 1313 (let ((fill-paragraph-function nil)
1308 ;; Adjust fill-column to allow space for the backslash. 1314 ;; Adjust fill-column to allow space for the backslash.
1309 (fill-column (- fill-column 1))) 1315 (fill-column (- fill-column 1)))
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 2cb108cc316..35c5ba19e33 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2334,7 +2334,7 @@ Argument OUTPUT is a string with the output from the comint process."
2334 ;; encounters an exception, it prints the _entire_ stack 2334 ;; encounters an exception, it prints the _entire_ stack
2335 ;; trace. To handle all of these cases, we want to find 2335 ;; trace. To handle all of these cases, we want to find
2336 ;; the _last_ stack frame printed in the most recent 2336 ;; the _last_ stack frame printed in the most recent
2337 ;; batch of output, then jump to the corrsponding 2337 ;; batch of output, then jump to the corresponding
2338 ;; file/line number. 2338 ;; file/line number.
2339 (goto-char (point-max)) 2339 (goto-char (point-max))
2340 (when (re-search-backward python-pdbtrack-stacktrace-info-regexp nil t) 2340 (when (re-search-backward python-pdbtrack-stacktrace-info-regexp nil t)
diff --git a/lisp/replace.el b/lisp/replace.el
index fb251821445..7757426cf95 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1819,19 +1819,6 @@ make, or the user didn't cancel the call."
1819 case-fold-search)) 1819 case-fold-search))
1820 (nocasify (not (and case-replace case-fold-search))) 1820 (nocasify (not (and case-replace case-fold-search)))
1821 (literal (or (not regexp-flag) (eq regexp-flag 'literal))) 1821 (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
1822 (search-function
1823 (or (if regexp-flag
1824 replace-re-search-function
1825 replace-search-function)
1826 (let ((isearch-regexp regexp-flag)
1827 (isearch-word delimited-flag)
1828 (isearch-lax-whitespace
1829 replace-lax-whitespace)
1830 (isearch-regexp-lax-whitespace
1831 replace-regexp-lax-whitespace)
1832 (isearch-case-fold-search case-fold-search)
1833 (isearch-forward t))
1834 (isearch-search-fun))))
1835 (search-string from-string) 1822 (search-string from-string)
1836 (real-match-data nil) ; The match data for the current match. 1823 (real-match-data nil) ; The match data for the current match.
1837 (next-replacement nil) 1824 (next-replacement nil)
@@ -1894,39 +1881,62 @@ make, or the user didn't cancel the call."
1894 ;; Loop finding occurrences that perhaps should be replaced. 1881 ;; Loop finding occurrences that perhaps should be replaced.
1895 (while (and keep-going 1882 (while (and keep-going
1896 (not (or (eobp) (and limit (>= (point) limit)))) 1883 (not (or (eobp) (and limit (>= (point) limit))))
1897 ;; Use the next match if it is already known; 1884 ;; Let-bind global isearch-* variables to values used
1898 ;; otherwise, search for a match after moving forward 1885 ;; to search the next replacement. These let-bindings
1899 ;; one char if progress is required. 1886 ;; should be effective both at the time of calling
1900 (setq real-match-data 1887 ;; `isearch-search-fun-default' and also at the
1901 (cond ((consp match-again) 1888 ;; time of funcalling `search-function'.
1902 (goto-char (nth 1 match-again)) 1889 ;; These isearch-* bindings can't be placed higher
1903 (replace-match-data 1890 ;; outside of this loop because then another I-search
1904 t real-match-data match-again)) 1891 ;; used after `recursive-edit' might override them.
1905 ;; MATCH-AGAIN non-nil means accept an 1892 (let* ((isearch-regexp regexp-flag)
1906 ;; adjacent match. 1893 (isearch-word delimited-flag)
1907 (match-again 1894 (isearch-lax-whitespace
1908 (and 1895 replace-lax-whitespace)
1909 (funcall search-function search-string 1896 (isearch-regexp-lax-whitespace
1910 limit t) 1897 replace-regexp-lax-whitespace)
1911 ;; For speed, use only integers and 1898 (isearch-case-fold-search case-fold-search)
1912 ;; reuse the list used last time. 1899 (isearch-adjusted nil)
1913 (replace-match-data t real-match-data))) 1900 (isearch-nonincremental t) ; don't use lax word mode
1914 ((and (< (1+ (point)) (point-max)) 1901 (isearch-forward t)
1915 (or (null limit) 1902 (search-function
1916 (< (1+ (point)) limit))) 1903 (or (if regexp-flag
1917 ;; If not accepting adjacent matches, 1904 replace-re-search-function
1918 ;; move one char to the right before 1905 replace-search-function)
1919 ;; searching again. Undo the motion 1906 (isearch-search-fun-default))))
1920 ;; if the search fails. 1907 ;; Use the next match if it is already known;
1921 (let ((opoint (point))) 1908 ;; otherwise, search for a match after moving forward
1922 (forward-char 1) 1909 ;; one char if progress is required.
1923 (if (funcall 1910 (setq real-match-data
1924 search-function search-string 1911 (cond ((consp match-again)
1925 limit t) 1912 (goto-char (nth 1 match-again))
1926 (replace-match-data 1913 (replace-match-data
1927 t real-match-data) 1914 t real-match-data match-again))
1928 (goto-char opoint) 1915 ;; MATCH-AGAIN non-nil means accept an
1929 nil)))))) 1916 ;; adjacent match.
1917 (match-again
1918 (and
1919 (funcall search-function search-string
1920 limit t)
1921 ;; For speed, use only integers and
1922 ;; reuse the list used last time.
1923 (replace-match-data t real-match-data)))
1924 ((and (< (1+ (point)) (point-max))
1925 (or (null limit)
1926 (< (1+ (point)) limit)))
1927 ;; If not accepting adjacent matches,
1928 ;; move one char to the right before
1929 ;; searching again. Undo the motion
1930 ;; if the search fails.
1931 (let ((opoint (point)))
1932 (forward-char 1)
1933 (if (funcall
1934 search-function search-string
1935 limit t)
1936 (replace-match-data
1937 t real-match-data)
1938 (goto-char opoint)
1939 nil)))))))
1930 1940
1931 ;; Record whether the match is nonempty, to avoid an infinite loop 1941 ;; Record whether the match is nonempty, to avoid an infinite loop
1932 ;; repeatedly matching the same empty string. 1942 ;; repeatedly matching the same empty string.
diff --git a/lisp/simple.el b/lisp/simple.el
index 3481a736648..d7541f68778 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -802,7 +802,7 @@ other words, it will work just like `just-one-space' command."
802 (unless (= start end) 802 (unless (= start end)
803 (cons orig-pos (buffer-substring start (point))))) 803 (cons orig-pos (buffer-substring start (point)))))
804 ;; If this run causes no change in buffer content, delete all spaces, 804 ;; If this run causes no change in buffer content, delete all spaces,
805 ;; otherwise delete all excees spaces. 805 ;; otherwise delete all excess spaces.
806 (delete-region (if (and (not single-shot) (zerop n) (= mid end)) 806 (delete-region (if (and (not single-shot) (zerop n) (= mid end))
807 start mid) end) 807 start mid) end)
808 (insert (make-string n ?\s)))) 808 (insert (make-string n ?\s))))
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 6ff4c720b71..eeb04ef250f 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -432,8 +432,7 @@ If you want to remember a region, supply a universal prefix to
432;;;###autoload 432;;;###autoload
433(defun remember-clipboard () 433(defun remember-clipboard ()
434 "Remember the contents of the current clipboard. 434 "Remember the contents of the current clipboard.
435Most useful for remembering things from Netscape or other X Windows 435Most useful for remembering things from other applications."
436application."
437 (interactive) 436 (interactive)
438 (remember (current-kill 0))) 437 (remember (current-kill 0)))
439 438
diff --git a/src/ChangeLog b/src/ChangeLog
index b4c3195973c..092302d6492 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,68 @@
12013-02-02 Paul Eggert <eggert@cs.ucla.edu>
2
3 Avoid file time stamp bug on MS-Windows (Bug#13149).
4 * fileio.c (Fwrite_region): Don't use the heuristic on empty files,
5 as FAT32 doesn't update time stamps when truncating them.
6 Also, check that a file time stamp is not a multiple of 100 ns;
7 this should catch all instances of the problem on MS-Windows,
8 as its native file system resolution is 100 ns or worse, and
9 checking for a non-multiple of 100 ns should impose only a small
10 overhead on systems with ns resolution.
11
122013-02-02 Eli Zaretskii <eliz@gnu.org>
13
14 Avoid encoding file names on MS-Windows when they need to be run
15 through dostounix_filename.
16 * w32.c (normalize_filename): Accept an additional argument
17 MULTIBYTE; if non-zero, traverse the file name by bytes and don't
18 downcase it even if w32-downcase-file-names is non-nil.
19 (dostounix_filename): Accept an additional argument MULTIBYTE and
20 pass it to normalize_filename.
21 (emacs_root_dir): Adjust.
22
23 * msdos.h (dostounix_filename): Adjust prototype.
24
25 * w32.h (dostounix_filename): Adjust prototype.
26
27 * msdos.c (dostounix_filename): Accept an additional argument and
28 ignore it.
29 (init_environment): Adjust callers of dostounix_filename.
30
31 * fileio.c (Ffile_name_directory, file_name_as_directory)
32 (directory_file_name, Fexpand_file_name)
33 (Fsubstitute_in_file_name): [DOS_NT] Adjust call to
34 dostounix_filename.
35 [WINDOWSNT]: Downcase file names if w32-downcase-file-names is
36 non-nil.
37 (Fsubstitute_in_file_name): [DOS_NT] Don't downcase environment
38 variables, as egetenv is case-insensitive for DOS_NT.
39
40 * dired.c (file_name_completion): Don't call Fdirectory_file_name
41 with an encoded file name.
42
43 * w32proc.c (Fw32_short_file_name, Fw32_long_file_name): Adjust
44 calls to dostounix_filename.
45
46 * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename.
47
48 * unexw32.c (unexec): Adjust call to dostounix_filename.
49
50 * termcap.c (tgetent) [MSDOS]: Adjust call to dostounix_filename.
51
52 * emacs.c (decode_env_path) [DOS_NT]: Adjust call to
53 dostounix_filename.
54
55 * callproc.c (Fcall_process) [MSDOS]: Adjust call to
56 dostounix_filename.
57
58 * callproc.c (Fcall_process): Make sure program name in PATH and
59 new_argv[0] is encoded, if needed. Otherwise, un-encoded string
60 is passed to exec/spawnve, which fails unless the file-name
61 encoding is UTF-8.
62
63 * w32proc.c (sys_spawnve): Make sure escape_char is initialized,
64 even if w32-quote-process-args is nil.
65
12013-02-01 Paul Eggert <eggert@cs.ucla.edu> 662013-02-01 Paul Eggert <eggert@cs.ucla.edu>
2 67
3 Fix timestamp bug when write-region appends nothing (Bug#13149). 68 Fix timestamp bug when write-region appends nothing (Bug#13149).
diff --git a/src/callproc.c b/src/callproc.c
index 5eba3271358..ea79da7ff5a 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -445,28 +445,34 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
445 path = Fsubstring (path, make_number (2), Qnil); 445 path = Fsubstring (path, make_number (2), Qnil);
446 446
447 new_argv = SAFE_ALLOCA ((nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); 447 new_argv = SAFE_ALLOCA ((nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv);
448 if (nargs > 4)
449 {
450 ptrdiff_t i;
451 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
452 448
453 GCPRO5 (infile, buffer, current_dir, path, error_file); 449 {
454 argument_coding.dst_multibyte = 0; 450 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
455 for (i = 4; i < nargs; i++) 451
456 { 452 GCPRO5 (infile, buffer, current_dir, path, error_file);
457 argument_coding.src_multibyte = STRING_MULTIBYTE (args[i]); 453 if (nargs > 4)
458 if (CODING_REQUIRE_ENCODING (&argument_coding)) 454 {
459 /* We must encode this argument. */ 455 ptrdiff_t i;
460 args[i] = encode_coding_string (&argument_coding, args[i], 1); 456
461 } 457 argument_coding.dst_multibyte = 0;
462 UNGCPRO; 458 for (i = 4; i < nargs; i++)
463 for (i = 4; i < nargs; i++) 459 {
464 new_argv[i - 3] = SSDATA (args[i]); 460 argument_coding.src_multibyte = STRING_MULTIBYTE (args[i]);
465 new_argv[i - 3] = 0; 461 if (CODING_REQUIRE_ENCODING (&argument_coding))
466 } 462 /* We must encode this argument. */
467 else 463 args[i] = encode_coding_string (&argument_coding, args[i], 1);
468 new_argv[1] = 0; 464 }
469 new_argv[0] = SSDATA (path); 465 for (i = 4; i < nargs; i++)
466 new_argv[i - 3] = SSDATA (args[i]);
467 new_argv[i - 3] = 0;
468 }
469 else
470 new_argv[1] = 0;
471 if (STRING_MULTIBYTE (path))
472 path = ENCODE_FILE (path);
473 new_argv[0] = SSDATA (path);
474 UNGCPRO;
475 }
470 476
471#ifdef MSDOS /* MW, July 1993 */ 477#ifdef MSDOS /* MW, July 1993 */
472 478
@@ -481,7 +487,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
481 tempfile = alloca (20); 487 tempfile = alloca (20);
482 *tempfile = '\0'; 488 *tempfile = '\0';
483 } 489 }
484 dostounix_filename (tempfile); 490 dostounix_filename (tempfile, 0);
485 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/') 491 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/')
486 strcat (tempfile, "/"); 492 strcat (tempfile, "/");
487 strcat (tempfile, "detmp.XXX"); 493 strcat (tempfile, "detmp.XXX");
diff --git a/src/dired.c b/src/dired.c
index ed0571fe9fe..0e37568f211 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -484,9 +484,9 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
484 on the encoded file name. */ 484 on the encoded file name. */
485 encoded_file = STRING_MULTIBYTE (file) ? ENCODE_FILE (file) : file; 485 encoded_file = STRING_MULTIBYTE (file) ? ENCODE_FILE (file) : file;
486 486
487 encoded_dir = ENCODE_FILE (dirname); 487 encoded_dir = ENCODE_FILE (Fdirectory_file_name (dirname));
488 488
489 d = open_directory (SSDATA (Fdirectory_file_name (encoded_dir)), &fd); 489 d = open_directory (SSDATA (encoded_dir), &fd);
490 if (!d) 490 if (!d)
491 report_file_error ("Opening directory", Fcons (dirname, Qnil)); 491 report_file_error ("Opening directory", Fcons (dirname, Qnil));
492 492
diff --git a/src/emacs.c b/src/emacs.c
index 21c7a7cec03..ff29a042ea0 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2158,7 +2158,7 @@ decode_env_path (const char *evarname, const char *defalt)
2158 { 2158 {
2159 char *path_copy = alloca (strlen (path) + 1); 2159 char *path_copy = alloca (strlen (path) + 1);
2160 strcpy (path_copy, path); 2160 strcpy (path_copy, path);
2161 dostounix_filename (path_copy); 2161 dostounix_filename (path_copy, 0);
2162 path = path_copy; 2162 path = path_copy;
2163 } 2163 }
2164#endif 2164#endif
diff --git a/src/fileio.c b/src/fileio.c
index fb6ecfedeb4..e76f2bc2420 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -383,11 +383,13 @@ Given a Unix syntax file name, returns a string ending in slash. */)
383 383
384 if (getdefdir (c_toupper (*beg) - 'A' + 1, r)) 384 if (getdefdir (c_toupper (*beg) - 'A' + 1, r))
385 { 385 {
386 if (!IS_DIRECTORY_SEP (res[strlen (res) - 1])) 386 size_t l = strlen (res);
387
388 if (l > 3 || !IS_DIRECTORY_SEP (res[l - 1]))
387 strcat (res, "/"); 389 strcat (res, "/");
388 beg = res; 390 beg = res;
389 p = beg + strlen (beg); 391 p = beg + strlen (beg);
390 dostounix_filename (beg); 392 dostounix_filename (beg, 0);
391 tem_fn = make_specified_string (beg, -1, p - beg, 393 tem_fn = make_specified_string (beg, -1, p - beg,
392 STRING_MULTIBYTE (filename)); 394 STRING_MULTIBYTE (filename));
393 } 395 }
@@ -397,13 +399,16 @@ Given a Unix syntax file name, returns a string ending in slash. */)
397 } 399 }
398 else if (STRING_MULTIBYTE (filename)) 400 else if (STRING_MULTIBYTE (filename))
399 { 401 {
400 tem_fn = ENCODE_FILE (make_specified_string (beg, -1, p - beg, 1)); 402 tem_fn = make_specified_string (beg, -1, p - beg, 1);
401 dostounix_filename (SSDATA (tem_fn)); 403 dostounix_filename (SSDATA (tem_fn), 1);
402 tem_fn = DECODE_FILE (tem_fn); 404#ifdef WINDOWSNT
405 if (!NILP (Vw32_downcase_file_names))
406 tem_fn = Fdowncase (tem_fn);
407#endif
403 } 408 }
404 else 409 else
405 { 410 {
406 dostounix_filename (beg); 411 dostounix_filename (beg, 0);
407 tem_fn = make_specified_string (beg, -1, p - beg, 0); 412 tem_fn = make_specified_string (beg, -1, p - beg, 0);
408 } 413 }
409 return tem_fn; 414 return tem_fn;
@@ -507,17 +512,7 @@ file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen,
507 srclen++; 512 srclen++;
508 } 513 }
509#ifdef DOS_NT 514#ifdef DOS_NT
510 if (multibyte) 515 dostounix_filename (dst, multibyte);
511 {
512 Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1);
513
514 tem_fn = ENCODE_FILE (tem_fn);
515 dostounix_filename (SSDATA (tem_fn));
516 tem_fn = DECODE_FILE (tem_fn);
517 memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1);
518 }
519 else
520 dostounix_filename (dst);
521#endif 516#endif
522 return srclen; 517 return srclen;
523} 518}
@@ -552,6 +547,10 @@ For a Unix-syntax file name, just appends a slash. */)
552 error ("Invalid handler in `file-name-handler-alist'"); 547 error ("Invalid handler in `file-name-handler-alist'");
553 } 548 }
554 549
550#ifdef WINDOWSNT
551 if (!NILP (Vw32_downcase_file_names))
552 file = Fdowncase (file);
553#endif
555 buf = alloca (SBYTES (file) + 10); 554 buf = alloca (SBYTES (file) + 10);
556 length = file_name_as_directory (buf, SSDATA (file), SBYTES (file), 555 length = file_name_as_directory (buf, SSDATA (file), SBYTES (file),
557 STRING_MULTIBYTE (file)); 556 STRING_MULTIBYTE (file));
@@ -580,17 +579,7 @@ directory_file_name (char *dst, char *src, ptrdiff_t srclen, bool multibyte)
580 srclen--; 579 srclen--;
581 } 580 }
582#ifdef DOS_NT 581#ifdef DOS_NT
583 if (multibyte) 582 dostounix_filename (dst, multibyte);
584 {
585 Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1);
586
587 tem_fn = ENCODE_FILE (tem_fn);
588 dostounix_filename (SSDATA (tem_fn));
589 tem_fn = DECODE_FILE (tem_fn);
590 memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1);
591 }
592 else
593 dostounix_filename (dst);
594#endif 583#endif
595 return srclen; 584 return srclen;
596} 585}
@@ -625,6 +614,10 @@ In Unix-syntax, this function just removes the final slash. */)
625 error ("Invalid handler in `file-name-handler-alist'"); 614 error ("Invalid handler in `file-name-handler-alist'");
626 } 615 }
627 616
617#ifdef WINDOWSNT
618 if (!NILP (Vw32_downcase_file_names))
619 directory = Fdowncase (directory);
620#endif
628 buf = alloca (SBYTES (directory) + 20); 621 buf = alloca (SBYTES (directory) + 20);
629 length = directory_file_name (buf, SSDATA (directory), SBYTES (directory), 622 length = directory_file_name (buf, SSDATA (directory), SBYTES (directory),
630 STRING_MULTIBYTE (directory)); 623 STRING_MULTIBYTE (directory));
@@ -925,6 +918,11 @@ filesystem tree, not (expand-file-name ".." dirname). */)
925 } 918 }
926 } 919 }
927 920
921#ifdef WINDOWSNT
922 if (!NILP (Vw32_downcase_file_names))
923 default_directory = Fdowncase (default_directory);
924#endif
925
928 /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ 926 /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */
929 nm = alloca (SBYTES (name) + 1); 927 nm = alloca (SBYTES (name) + 1);
930 memcpy (nm, SSDATA (name), SBYTES (name) + 1); 928 memcpy (nm, SSDATA (name), SBYTES (name) + 1);
@@ -1008,18 +1006,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1008#ifdef DOS_NT 1006#ifdef DOS_NT
1009 /* Make sure directories are all separated with /, but 1007 /* Make sure directories are all separated with /, but
1010 avoid allocation of a new string when not required. */ 1008 avoid allocation of a new string when not required. */
1011 if (multibyte) 1009 dostounix_filename (nm, multibyte);
1012 {
1013 Lisp_Object tem_name = make_specified_string (nm, -1, strlen (nm),
1014 multibyte);
1015
1016 tem_name = ENCODE_FILE (tem_name);
1017 dostounix_filename (SSDATA (tem_name));
1018 tem_name = DECODE_FILE (tem_name);
1019 memcpy (nm, SSDATA (tem_name), SBYTES (tem_name) + 1);
1020 }
1021 else
1022 dostounix_filename (nm);
1023#ifdef WINDOWSNT 1010#ifdef WINDOWSNT
1024 if (IS_DIRECTORY_SEP (nm[1])) 1011 if (IS_DIRECTORY_SEP (nm[1]))
1025 { 1012 {
@@ -1037,6 +1024,10 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1037 temp[0] = DRIVE_LETTER (drive); 1024 temp[0] = DRIVE_LETTER (drive);
1038 name = concat2 (build_string (temp), name); 1025 name = concat2 (build_string (temp), name);
1039 } 1026 }
1027#ifdef WINDOWSNT
1028 if (!NILP (Vw32_downcase_file_names))
1029 name = Fdowncase (name);
1030#endif
1040 return name; 1031 return name;
1041#else /* not DOS_NT */ 1032#else /* not DOS_NT */
1042 if (strcmp (nm, SSDATA (name)) == 0) 1033 if (strcmp (nm, SSDATA (name)) == 0)
@@ -1400,14 +1391,11 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1400 target[1] = ':'; 1391 target[1] = ':';
1401 } 1392 }
1402 result = make_specified_string (target, -1, o - target, multibyte); 1393 result = make_specified_string (target, -1, o - target, multibyte);
1403 if (multibyte) 1394 dostounix_filename (SSDATA (result), multibyte);
1404 { 1395#ifdef WINDOWSNT
1405 result = ENCODE_FILE (result); 1396 if (!NILP (Vw32_downcase_file_names))
1406 dostounix_filename (SSDATA (result)); 1397 result = Fdowncase (result);
1407 result = DECODE_FILE (result); 1398#endif
1408 }
1409 else
1410 dostounix_filename (SSDATA (result));
1411#else /* !DOS_NT */ 1399#else /* !DOS_NT */
1412 result = make_specified_string (target, -1, o - target, multibyte); 1400 result = make_specified_string (target, -1, o - target, multibyte);
1413#endif /* !DOS_NT */ 1401#endif /* !DOS_NT */
@@ -1689,24 +1677,8 @@ those `/' is discarded. */)
1689 memcpy (nm, SDATA (filename), SBYTES (filename) + 1); 1677 memcpy (nm, SDATA (filename), SBYTES (filename) + 1);
1690 1678
1691#ifdef DOS_NT 1679#ifdef DOS_NT
1692 if (multibyte) 1680 dostounix_filename (nm, multibyte);
1693 { 1681 substituted = (memcmp (nm, SDATA (filename), SBYTES (filename)) != 0);
1694 Lisp_Object encoded_filename = ENCODE_FILE (filename);
1695 Lisp_Object tem_fn;
1696
1697 dostounix_filename (SDATA (encoded_filename));
1698 tem_fn = DECODE_FILE (encoded_filename);
1699 nm = alloca (SBYTES (tem_fn) + 1);
1700 memcpy (nm, SDATA (tem_fn), SBYTES (tem_fn) + 1);
1701 substituted = (memcmp (nm, SDATA (filename), SBYTES (filename)) != 0);
1702 if (substituted)
1703 filename = tem_fn;
1704 }
1705 else
1706 {
1707 dostounix_filename (nm);
1708 substituted = (memcmp (nm, SDATA (filename), SBYTES (filename)) != 0);
1709 }
1710#endif 1682#endif
1711 endp = nm + SBYTES (filename); 1683 endp = nm + SBYTES (filename);
1712 1684
@@ -1780,7 +1752,13 @@ those `/' is discarded. */)
1780 } 1752 }
1781 1753
1782 if (!substituted) 1754 if (!substituted)
1783 return filename; 1755 {
1756#ifdef WINDOWSNT
1757 if (!NILP (Vw32_downcase_file_names))
1758 filename = Fdowncase (filename);
1759#endif
1760 return filename;
1761 }
1784 1762
1785 /* If substitution required, recopy the string and do it. */ 1763 /* If substitution required, recopy the string and do it. */
1786 /* Make space in stack frame for the new copy. */ 1764 /* Make space in stack frame for the new copy. */
@@ -1819,9 +1797,6 @@ those `/' is discarded. */)
1819 target = alloca (s - o + 1); 1797 target = alloca (s - o + 1);
1820 memcpy (target, o, s - o); 1798 memcpy (target, o, s - o);
1821 target[s - o] = 0; 1799 target[s - o] = 0;
1822#ifdef DOS_NT
1823 strupr (target); /* $home == $HOME etc. */
1824#endif /* DOS_NT */
1825 1800
1826 /* Get variable value. */ 1801 /* Get variable value. */
1827 o = egetenv (target); 1802 o = egetenv (target);
@@ -1858,6 +1833,16 @@ those `/' is discarded. */)
1858 need to quote some $ to $$ first. */ 1833 need to quote some $ to $$ first. */
1859 xnm = p; 1834 xnm = p;
1860 1835
1836#ifdef WINDOWSNT
1837 if (!NILP (Vw32_downcase_file_names))
1838 {
1839 Lisp_Object xname = make_specified_string (xnm, -1, x - xnm, multibyte);
1840
1841 xname = Fdowncase (xname);
1842 return xname;
1843 }
1844 else
1845#endif
1861 return make_specified_string (xnm, -1, x - xnm, multibyte); 1846 return make_specified_string (xnm, -1, x - xnm, multibyte);
1862 1847
1863 badsubst: 1848 badsubst:
@@ -5035,11 +5020,22 @@ This calls `write-region-annotate-functions' at the start, and
5035 if (fstat (desc1, &st1) == 0 5020 if (fstat (desc1, &st1) == 0
5036 && st.st_dev == st1.st_dev && st.st_ino == st1.st_ino) 5021 && st.st_dev == st1.st_dev && st.st_ino == st1.st_ino)
5037 { 5022 {
5023 /* Use the heuristic if it appears to be valid. With neither
5024 O_EXCL nor O_TRUNC, if Emacs happened to write nothing to the
5025 file, the time stamp won't change. Also, some non-POSIX
5026 systems don't update an empty file's time stamp when
5027 truncating it. Finally, file systems with 100 ns or worse
5028 resolution sometimes seem to have bugs: on a system with ns
5029 resolution, checking ns % 100 incorrectly avoids the heuristic
5030 1% of the time, but the problem should be temporary as we will
5031 try again on the next time stamp. */
5032 bool use_heuristic
5033 = ((open_flags & (O_EXCL | O_TRUNC)) != 0
5034 && st.st_size != 0
5035 && EMACS_NSECS (modtime) % 100 != 0);
5036
5038 EMACS_TIME modtime1 = get_stat_mtime (&st1); 5037 EMACS_TIME modtime1 = get_stat_mtime (&st1);
5039 /* If neither O_EXCL nor O_TRUNC is used, and Emacs happened to 5038 if (use_heuristic
5040 write nothing to the file, the file's time stamp won't change
5041 so it should not be used in this heuristic. */
5042 if ((open_flags & (O_EXCL | O_TRUNC)) != 0
5043 && EMACS_TIME_EQ (modtime, modtime1) 5039 && EMACS_TIME_EQ (modtime, modtime1)
5044 && st.st_size == st1.st_size) 5040 && st.st_size == st1.st_size)
5045 { 5041 {
diff --git a/src/msdos.c b/src/msdos.c
index 5174bc4dfcd..1b2deaf7478 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -3339,7 +3339,7 @@ void msdos_downcase_filename (unsigned char *);
3339/* Destructively turn backslashes into slashes. */ 3339/* Destructively turn backslashes into slashes. */
3340 3340
3341void 3341void
3342dostounix_filename (char *p) 3342dostounix_filename (char *p, int ignore)
3343{ 3343{
3344 msdos_downcase_filename (p); 3344 msdos_downcase_filename (p);
3345 3345
@@ -3603,7 +3603,7 @@ init_environment (int argc, char **argv, int skip_args)
3603 if (!s) s = "c:/command.com"; 3603 if (!s) s = "c:/command.com";
3604 t = alloca (strlen (s) + 1); 3604 t = alloca (strlen (s) + 1);
3605 strcpy (t, s); 3605 strcpy (t, s);
3606 dostounix_filename (t); 3606 dostounix_filename (t, 0);
3607 setenv ("SHELL", t, 0); 3607 setenv ("SHELL", t, 0);
3608 3608
3609 /* PATH is also downcased and backslashes mirrored. */ 3609 /* PATH is also downcased and backslashes mirrored. */
@@ -3613,7 +3613,7 @@ init_environment (int argc, char **argv, int skip_args)
3613 /* Current directory is always considered part of MsDos's path but it is 3613 /* Current directory is always considered part of MsDos's path but it is
3614 not normally mentioned. Now it is. */ 3614 not normally mentioned. Now it is. */
3615 strcat (strcpy (t, ".;"), s); 3615 strcat (strcpy (t, ".;"), s);
3616 dostounix_filename (t); /* Not a single file name, but this should work. */ 3616 dostounix_filename (t, 0); /* Not a single file name, but this should work. */
3617 setenv ("PATH", t, 1); 3617 setenv ("PATH", t, 1);
3618 3618
3619 /* In some sense all dos users have root privileges, so... */ 3619 /* In some sense all dos users have root privileges, so... */
diff --git a/src/msdos.h b/src/msdos.h
index 57609d62218..ee0d49464ae 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -29,7 +29,7 @@ void dos_set_window_size (int *, int *);
29 29
30int getdefdir (int, char*); 30int getdefdir (int, char*);
31void unixtodos_filename (char *); 31void unixtodos_filename (char *);
32void dostounix_filename (char *); 32void dostounix_filename (char *, int);
33char *rootrelativepath (char *); 33char *rootrelativepath (char *);
34void init_environment (int, char **, int); 34void init_environment (int, char **, int);
35void internal_terminal_init (void); 35void internal_terminal_init (void);
diff --git a/src/termcap.c b/src/termcap.c
index 82c2b1fda07..99bbfce27f5 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -393,7 +393,7 @@ tgetent (char *bp, const char *name)
393 if (termcap_name && (*termcap_name == '\\' 393 if (termcap_name && (*termcap_name == '\\'
394 || *termcap_name == '/' 394 || *termcap_name == '/'
395 || termcap_name[1] == ':')) 395 || termcap_name[1] == ':'))
396 dostounix_filename (termcap_name); 396 dostounix_filename (termcap_name, 0);
397#endif 397#endif
398 398
399 filep = termcap_name && valid_filename_p (termcap_name); 399 filep = termcap_name && valid_filename_p (termcap_name);
diff --git a/src/unexw32.c b/src/unexw32.c
index 66071295727..e8b553a87d3 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -722,7 +722,7 @@ unexec (const char *new_name, const char *old_name)
722 /* Ignore old_name, and get our actual location from the OS. */ 722 /* Ignore old_name, and get our actual location from the OS. */
723 if (!GetModuleFileName (NULL, in_filename, MAX_PATH)) 723 if (!GetModuleFileName (NULL, in_filename, MAX_PATH))
724 abort (); 724 abort ();
725 dostounix_filename (in_filename); 725 dostounix_filename (in_filename, 0);
726 strcpy (out_filename, in_filename); 726 strcpy (out_filename, in_filename);
727 727
728 /* Change the base of the output filename to match the requested name. */ 728 /* Change the base of the output filename to match the requested name. */
diff --git a/src/w32.c b/src/w32.c
index 64f8a0335ac..8b89bd3e660 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1598,12 +1598,17 @@ max_filename_mbslen (void)
1598 case path name components to lower case. */ 1598 case path name components to lower case. */
1599 1599
1600static void 1600static void
1601normalize_filename (register char *fp, char path_sep) 1601normalize_filename (register char *fp, char path_sep, int multibyte)
1602{ 1602{
1603 char sep; 1603 char sep;
1604 char *elem, *p2; 1604 char *elem, *p2;
1605 int dbcs_p = max_filename_mbslen () > 1; 1605 int dbcs_p = max_filename_mbslen () > 1;
1606 1606
1607 /* Multibyte file names are in the Emacs internal representation, so
1608 we can traverse them by bytes with no problems. */
1609 if (multibyte)
1610 dbcs_p = 0;
1611
1607 /* Always lower-case drive letters a-z, even if the filesystem 1612 /* Always lower-case drive letters a-z, even if the filesystem
1608 preserves case in filenames. 1613 preserves case in filenames.
1609 This is so filenames can be compared by string comparison 1614 This is so filenames can be compared by string comparison
@@ -1620,7 +1625,7 @@ normalize_filename (register char *fp, char path_sep)
1620 fp += 2; 1625 fp += 2;
1621 } 1626 }
1622 1627
1623 if (NILP (Vw32_downcase_file_names)) 1628 if (multibyte || NILP (Vw32_downcase_file_names))
1624 { 1629 {
1625 while (*fp) 1630 while (*fp)
1626 { 1631 {
@@ -1668,18 +1673,20 @@ normalize_filename (register char *fp, char path_sep)
1668 } while (*fp); 1673 } while (*fp);
1669} 1674}
1670 1675
1671/* Destructively turn backslashes into slashes. */ 1676/* Destructively turn backslashes into slashes. MULTIBYTE non-zero
1677 means the file name is a multibyte string in Emacs's internal
1678 representation. */
1672void 1679void
1673dostounix_filename (register char *p) 1680dostounix_filename (register char *p, int multibyte)
1674{ 1681{
1675 normalize_filename (p, '/'); 1682 normalize_filename (p, '/', multibyte);
1676} 1683}
1677 1684
1678/* Destructively turn slashes into backslashes. */ 1685/* Destructively turn slashes into backslashes. */
1679void 1686void
1680unixtodos_filename (register char *p) 1687unixtodos_filename (register char *p)
1681{ 1688{
1682 normalize_filename (p, '\\'); 1689 normalize_filename (p, '\\', 0);
1683} 1690}
1684 1691
1685/* Remove all CR's that are followed by a LF. 1692/* Remove all CR's that are followed by a LF.
@@ -2222,7 +2229,7 @@ emacs_root_dir (void)
2222 emacs_abort (); 2229 emacs_abort ();
2223 strcpy (root_dir, p); 2230 strcpy (root_dir, p);
2224 root_dir[parse_root (root_dir, NULL)] = '\0'; 2231 root_dir[parse_root (root_dir, NULL)] = '\0';
2225 dostounix_filename (root_dir); 2232 dostounix_filename (root_dir, 0);
2226 return root_dir; 2233 return root_dir;
2227} 2234}
2228 2235
@@ -4280,7 +4287,7 @@ fstatat (int fd, char const *name, struct stat *st, int flags)
4280 /* Rely on a hack: an open directory is modeled as file descriptor 0. 4287 /* Rely on a hack: an open directory is modeled as file descriptor 0.
4281 This is good enough for the current usage in Emacs, but is fragile. 4288 This is good enough for the current usage in Emacs, but is fragile.
4282 4289
4283 FIXME: Add proper support for fdopendir, fstatatat, readlinkat. 4290 FIXME: Add proper support for fdopendir, fstatat, readlinkat.
4284 Gnulib does this and can serve as a model. */ 4291 Gnulib does this and can serve as a model. */
4285 char fullname[MAX_PATH]; 4292 char fullname[MAX_PATH];
4286 4293
diff --git a/src/w32.h b/src/w32.h
index 895e7f31d63..6bf165f52ba 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -180,7 +180,7 @@ extern void init_environment (char **);
180extern void check_windows_init_file (void); 180extern void check_windows_init_file (void);
181extern void syms_of_ntproc (void); 181extern void syms_of_ntproc (void);
182extern void syms_of_ntterm (void); 182extern void syms_of_ntterm (void);
183extern void dostounix_filename (register char *); 183extern void dostounix_filename (register char *, int);
184extern void unixtodos_filename (register char *); 184extern void unixtodos_filename (register char *);
185extern BOOL init_winsock (int load_now); 185extern BOOL init_winsock (int load_now);
186extern void srandom (int); 186extern void srandom (int);
diff --git a/src/w32fns.c b/src/w32fns.c
index 6c098cae3a3..0841ad3468e 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6254,7 +6254,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
6254 /* we get one of the two final 0 bytes for free. */ 6254 /* we get one of the two final 0 bytes for free. */
6255 1 + sizeof (wchar_t) * wcslen (filename_buf))); 6255 1 + sizeof (wchar_t) * wcslen (filename_buf)));
6256#else /* !NTGUI_UNICODE */ 6256#else /* !NTGUI_UNICODE */
6257 dostounix_filename (filename_buf); 6257 dostounix_filename (filename_buf, 0);
6258 filename = DECODE_FILE (build_string (filename_buf)); 6258 filename = DECODE_FILE (build_string (filename_buf));
6259#endif /* NTGUI_UNICODE */ 6259#endif /* NTGUI_UNICODE */
6260 6260
diff --git a/src/w32proc.c b/src/w32proc.c
index 0fcb2993020..8bf57602927 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1541,7 +1541,6 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
1541 child_process *cp; 1541 child_process *cp;
1542 int is_dos_app, is_cygnus_app, is_gui_app; 1542 int is_dos_app, is_cygnus_app, is_gui_app;
1543 int do_quoting = 0; 1543 int do_quoting = 0;
1544 char escape_char;
1545 /* We pass our process ID to our children by setting up an environment 1544 /* We pass our process ID to our children by setting up an environment
1546 variable in their environment. */ 1545 variable in their environment. */
1547 char ppid_env_var_buffer[64]; 1546 char ppid_env_var_buffer[64];
@@ -1554,6 +1553,8 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
1554 Some extra whitespace characters need quoting in Cygwin programs, 1553 Some extra whitespace characters need quoting in Cygwin programs,
1555 so this list is conditionally modified below. */ 1554 so this list is conditionally modified below. */
1556 char *sepchars = " \t*?"; 1555 char *sepchars = " \t*?";
1556 /* This is for native w32 apps; modified below for Cygwin apps. */
1557 char escape_char = '\\';
1557 1558
1558 /* We don't care about the other modes */ 1559 /* We don't care about the other modes */
1559 if (mode != _P_NOWAIT) 1560 if (mode != _P_NOWAIT)
@@ -2557,8 +2558,9 @@ All path elements in FILENAME are converted to their short names. */)
2557 if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname, MAX_PATH) == 0) 2558 if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname, MAX_PATH) == 0)
2558 return Qnil; 2559 return Qnil;
2559 2560
2560 dostounix_filename (shortname); 2561 dostounix_filename (shortname, 0);
2561 2562
2563 /* No need to DECODE_FILE, because 8.3 names are pure ASCII. */
2562 return build_string (shortname); 2564 return build_string (shortname);
2563} 2565}
2564 2566
@@ -2585,7 +2587,7 @@ All path elements in FILENAME are converted to their long names. */)
2585 if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname, MAX_PATH)) 2587 if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname, MAX_PATH))
2586 return Qnil; 2588 return Qnil;
2587 2589
2588 dostounix_filename (longname); 2590 dostounix_filename (longname, 0);
2589 2591
2590 /* If we were passed only a drive, make sure that a slash is not appended 2592 /* If we were passed only a drive, make sure that a slash is not appended
2591 for consistency with directories. Allow for drive mapping via SUBST 2593 for consistency with directories. Allow for drive mapping via SUBST