APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1489277184 0
# Sun Mar 12 00:06:24 2017 +0000
# Node ID f669d096d3d4491cfd04e5d859a4e9bf9a787d63
# Parent a9aed431763dcc4a4b7a79c30c410be07fec9ffb
Fix a bug in #'auto-save-unescape-name, test same.
lisp/ChangeLog addition:
2017-03-12 Aidan Kehoe <kehoea(a)parhasard.net>
* auto-save.el (auto-save-unescape-name):
Fix a bug in this, limit the hex parsing correctly.
tests/ChangeLog addition:
2017-03-12 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/lisp-tests.el:
Add a parenthesis which had gone astray while merging.
Test #'auto-save-escape-name, #'auto-save-unescape-name,
reasonably important functions which previously had no testing.
diff -r a9aed431763d -r f669d096d3d4 lisp/ChangeLog
--- a/lisp/ChangeLog Sat Mar 11 16:28:54 2017 +0000
+++ b/lisp/ChangeLog Sun Mar 12 00:06:24 2017 +0000
@@ -1,3 +1,8 @@
+2017-03-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * auto-save.el (auto-save-unescape-name):
+ Fix a bug in this, limit the hex parsing correctly.
+
2017-03-09 Aidan Kehoe <kehoea(a)parhasard.net>
diff -r a9aed431763d -r f669d096d3d4 lisp/auto-save.el
--- a/lisp/auto-save.el Sat Mar 11 16:28:54 2017 +0000
+++ b/lisp/auto-save.el Sun Mar 12 00:06:24 2017 +0000
@@ -421,7 +421,7 @@
(while (string-match #r"=\([0-9a-f][0-9a-f]\)" str)
(let* ((start (match-beginning 0))
(code (parse-integer str :start (match-beginning 1)
- :end (match-end 2) :radix 16)))
+ :end (match-end 1) :radix 16)))
(setq tmp (concat tmp (substring str 0 start)
(list code))
str (substring str (match-end 0)))))
diff -r a9aed431763d -r f669d096d3d4 tests/ChangeLog
--- a/tests/ChangeLog Sat Mar 11 16:28:54 2017 +0000
+++ b/tests/ChangeLog Sun Mar 12 00:06:24 2017 +0000
@@ -1,3 +1,10 @@
+2017-03-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * automated/lisp-tests.el:
+ Add a parenthesis which had gone astray while merging.
+ Test #'auto-save-escape-name, #'auto-save-unescape-name,
+ reasonably important functions which previously had no testing.
+
2017-03-03 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/regexp-tests.el:
diff -r a9aed431763d -r f669d096d3d4 tests/automated/lisp-tests.el
--- a/tests/automated/lisp-tests.el Sat Mar 11 16:28:54 2017 +0000
+++ b/tests/automated/lisp-tests.el Sun Mar 12 00:06:24 2017 +0000
@@ -3830,7 +3830,7 @@
(Assert (>= 35 max) "checking base 36 is supported,
`digit-fixnum-map'")
(Assert (<= min 2) "checking base two supported, `digit-fixnum-map'")
(Assert (eql (digit-char-p max-char (1+ max)) max))
- (Assert (eql (digit-char-p min-char (1+ min)) min))
+ (Assert (eql (digit-char-p min-char (1+ min)) min)))
(let ((binary-table
(copy-char-table #s(char-table :type generic :default -1 :data ()))))
@@ -4201,4 +4201,65 @@
'#:g3456)))
(eval form)))
+;;-----------------------------------------------------
+;; Test `auto-save-escape-name', `auto-save-unescape-name'
+;;-----------------------------------------------------
+
+(Assert (equal (auto-save-escape-name "abcdefghijk") "abcdefghijk"))
+
+;; We don't check whether auto-save-escape-name creates a new string object
+;; when there are no characters that need escaping.
+
+(Assert (equal (auto-save-escape-name "") ""))
+
+(Assert (equal (auto-save-escape-name "���") "���"))
+
+(Assert (not (eq (auto-save-escape-name "abcdefghijk")
"abcdefghijk")))
+
+(macrolet
+ ((create-individual-char-tests (&rest characters)
+ (cons
+ 'progn
+ (loop for char in characters
+ nconc `((Assert (equal (auto-save-escape-name
+ ,(format "hello %c there" char))
+ ,(format "hello=20=%02X=20there" char)))
+ (Assert (equal (auto-save-unescape-name
+ ,(format "hello=20=%02X=20there" char))
+ ,(format "hello %c there" char)))
+ (Assert (equal (auto-save-escape-name
+ ,(format "hello %c" char))
+ ,(format "hello=20=%02X" char)))
+ (Assert (equal (auto-save-unescape-name
+ ,(format "hello=20=%02X" char))
+ ,(format "hello %c" char)))
+ (Assert (equal (auto-save-escape-name
+ ,(format "hello %cab" char))
+ ,(format "hello=20=%02Xab" char)))
+ (Assert (equal (auto-save-unescape-name
+ ,(format "hello=20=%02Xab" char))
+ ,(format "hello %cab" char))))))))
+ (create-individual-char-tests
+ ;; This is the value of auto-save-reserved-chars. Don't reference the
+ ;; variable from the test code, we want the set to be stable.
+ ?\0 ?\1 ?\2 ?\3 ?\4 ?\5 ?\6 ?\7 ?\10 ?\11 ?\12 ?\13 ?\14 ?\15 ?\16
+ ?\17 ?\20 ?\21 ?\22 ?\23 ?\24 ?\25 ?\26 ?\27 ?\30 ?\31 ?\32 ?\33
+ ?\34 ?\35 ?\36 ?\37 ?\40 ?? ?* ?: ?< ?> ?| ?/ ?\\ ?& ?^ ?% ?= ?\"))
+
+(when (featurep 'mule)
+ (let ((file-name-alias (coding-system-aliasee 'file-name))
+ (complicated-file-name
+ (decode-coding-string "/hel\xc5\x82o\n" 'utf-8)))
+ (unwind-protect
+ (progn
+ ;; Check that we preserve data that may be lost by the file-name
+ ;; coding system.
+ (define-coding-system-alias 'file-name 'iso-8859-1)
+ (Assert (equal complicated-file-name
+ (auto-save-unescape-name
+ (encode-coding-string
+ (auto-save-escape-name complicated-file-name)
+ 'file-name t)))))
+ (define-coding-system-alias 'file-name file-name-alias))))
+
;;; end of lisp-tests.el
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)
Show replies by date