1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 23:10:47 -08:00

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.
This commit is contained in:
Eli Zaretskii 2020-04-09 12:20:24 +03:00
parent faf996dc6e
commit 20eb4247cd

View file

@ -9471,7 +9471,7 @@ not fully specified.) */)
return code_convert_region (start, end, coding_system, destination, 1, 0);
}
/* Non-zero if STR contains only characterss in the 0..127 range.
/* Non-zero if STR contains only characters in the 0..127 range.
Positive if STR includes characters that don't need EOL conversion
on decoding, negative otherwise. */
static int
@ -9523,7 +9523,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
if (EQ (dst_object, Qt))
{
/* Fast path for ASCII-only input and an ASCII-compatible coding:
act as identity. */
act as identity if no EOL conversion is neede. */
int ascii_p;
Lisp_Object attrs = CODING_ID_ATTRS (coding.id);
if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))