aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorEli Zaretskii2020-04-09 12:20:24 +0300
committerEli Zaretskii2020-04-09 12:20:24 +0300
commit20eb4247cdc2eeada43c3de8abf9c577be38c98f (patch)
tree677cbf525a8028236e54fb01daaa141495af93dd /src/coding.c
parentfaf996dc6e963a8dd74e9e794ded0467dd78ea18 (diff)
downloademacs-20eb4247cdc2eeada43c3de8abf9c577be38c98f.tar.gz
emacs-20eb4247cdc2eeada43c3de8abf9c577be38c98f.zip
Fix decoding of 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 more tests for bug#40519.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/coding.c b/src/coding.c
index 24a832ff3ee..c24c70c0899 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9471,7 +9471,7 @@ not fully specified.) */)
9471 return code_convert_region (start, end, coding_system, destination, 1, 0); 9471 return code_convert_region (start, end, coding_system, destination, 1, 0);
9472} 9472}
9473 9473
9474/* Non-zero if STR contains only characterss in the 0..127 range. 9474/* Non-zero if STR contains only characters in the 0..127 range.
9475 Positive if STR includes characters that don't need EOL conversion 9475 Positive if STR includes characters that don't need EOL conversion
9476 on decoding, negative otherwise. */ 9476 on decoding, negative otherwise. */
9477static int 9477static int
@@ -9523,7 +9523,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
9523 if (EQ (dst_object, Qt)) 9523 if (EQ (dst_object, Qt))
9524 { 9524 {
9525 /* Fast path for ASCII-only input and an ASCII-compatible coding: 9525 /* Fast path for ASCII-only input and an ASCII-compatible coding:
9526 act as identity. */ 9526 act as identity if no EOL conversion is neede. */
9527 int ascii_p; 9527 int ascii_p;
9528 Lisp_Object attrs = CODING_ID_ATTRS (coding.id); 9528 Lisp_Object attrs = CODING_ID_ATTRS (coding.id);
9529 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs)) 9529 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))