diff options
| author | Eli Zaretskii | 2020-04-09 12:18:30 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-09 12:18:30 +0300 |
| commit | faf996dc6e963a8dd74e9e794ded0467dd78ea18 (patch) | |
| tree | 05414568c1e99a0226101e37fb94dc4ade687699 /test/src/coding-tests.el | |
| parent | 1aeb1819353418ebed635f18a009048700ba1ad0 (diff) | |
| download | emacs-faf996dc6e963a8dd74e9e794ded0467dd78ea18.tar.gz emacs-faf996dc6e963a8dd74e9e794ded0467dd78ea18.zip | |
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/src/coding-tests.el')
| -rw-r--r-- | test/src/coding-tests.el | 17 |
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 @@ | |||
| 388 | (let* ((uni (apply #'string (number-sequence 0 127))) | 388 | (let* ((uni (apply #'string (number-sequence 0 127))) |
| 389 | (multi (string-to-multibyte uni))) | 389 | (multi (string-to-multibyte uni))) |
| 390 | (dolist (s (list uni multi)) | 390 | (dolist (s (list uni multi)) |
| 391 | (dolist (coding '(us-ascii-unix iso-latin-1-unix utf-8-unix)) | ||
| 392 | (should-not (eq (decode-coding-string s coding nil) s)) | ||
| 393 | (should-not (eq (encode-coding-string s coding nil) s)) | ||
| 394 | (should (eq (decode-coding-string s coding t) s)) | ||
| 395 | (should (eq (encode-coding-string s coding t) s))))) | ||
| 396 | (let* ((uni (apply #'string (number-sequence 15 127))) | ||
| 397 | (multi (string-to-multibyte uni))) | ||
| 398 | (dolist (s (list uni multi)) | ||
| 399 | (dolist (coding '(us-ascii iso-latin-1 utf-8)) | ||
| 400 | (should-not (eq (decode-coding-string s coding nil) s)) | ||
| 401 | (should-not (eq (encode-coding-string s coding nil) s)) | ||
| 402 | (should (eq (decode-coding-string s coding t) s)) | ||
| 403 | (should (eq (encode-coding-string s coding t) s))))) | ||
| 404 | (let* ((uni (apply #'string (number-sequence 0 127))) | ||
| 405 | (multi (string-to-multibyte uni)) | ||
| 406 | (inhibit-eol-conversion t)) | ||
| 407 | (dolist (s (list uni multi)) | ||
| 391 | (dolist (coding '(us-ascii iso-latin-1 utf-8)) | 408 | (dolist (coding '(us-ascii iso-latin-1 utf-8)) |
| 392 | (should-not (eq (decode-coding-string s coding nil) s)) | 409 | (should-not (eq (decode-coding-string s coding nil) s)) |
| 393 | (should-not (eq (encode-coding-string s coding nil) s)) | 410 | (should-not (eq (encode-coding-string s coding nil) s)) |