summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2020-04-09 12:18:30 +0300
committerEli Zaretskii <eliz@gnu.org>2020-04-09 12:18:30 +0300
commitfaf996dc6e963a8dd74e9e794ded0467dd78ea18 (patch)
tree05414568c1e99a0226101e37fb94dc4ade687699 /test
parent1aeb1819353418ebed635f18a009048700ba1ad0 (diff)
downloademacs-faf996dc6e963a8dd74e9e794ded0467dd78ea18.tar.gz
Fix decoding ASCII strings with embedded CR characters
* src/coding.c (string_ascii_p): Return a negative value if an all-ASCII string STR includes the CR character, otherwise a positive value. (code_convert_string): If the string is ASCII, but includes CR characters, use the fast path only if EOL doesn't need to be decoded. (Bug#40519) * test/src/coding-tests.el (coding-nocopy-ascii): Add tests for bug#40519.
Diffstat (limited to 'test')
-rw-r--r--test/src/coding-tests.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el
index 93e6709d442..83a06b8179e 100644
--- a/test/src/coding-tests.el
+++ b/test/src/coding-tests.el
@@ -388,6 +388,23 @@
(let* ((uni (apply #'string (number-sequence 0 127)))
(multi (string-to-multibyte uni)))
(dolist (s (list uni multi))
+ (dolist (coding '(us-ascii-unix iso-latin-1-unix utf-8-unix))
+ (should-not (eq (decode-coding-string s coding nil) s))
+ (should-not (eq (encode-coding-string s coding nil) s))
+ (should (eq (decode-coding-string s coding t) s))
+ (should (eq (encode-coding-string s coding t) s)))))
+ (let* ((uni (apply #'string (number-sequence 15 127)))
+ (multi (string-to-multibyte uni)))
+ (dolist (s (list uni multi))
+ (dolist (coding '(us-ascii iso-latin-1 utf-8))
+ (should-not (eq (decode-coding-string s coding nil) s))
+ (should-not (eq (encode-coding-string s coding nil) s))
+ (should (eq (decode-coding-string s coding t) s))
+ (should (eq (encode-coding-string s coding t) s)))))
+ (let* ((uni (apply #'string (number-sequence 0 127)))
+ (multi (string-to-multibyte uni))
+ (inhibit-eol-conversion t))
+ (dolist (s (list uni multi))
(dolist (coding '(us-ascii iso-latin-1 utf-8))
(should-not (eq (decode-coding-string s coding nil) s))
(should-not (eq (encode-coding-string s coding nil) s))