commit 0adb15c7a1beb325a6a14a9d23f4b955f6b7ceb7
parent 1e48df388e93bd8b2e44277923bdd6bfdb044ae0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 11 Jun 2019 16:51:41 +0200
display: properly show all characters in a non-UTF-8 build
Also, don't use mblen() directly, to not get stuck when it returns -1,
which it will when running a non-UTF-8 build in a UTF-8 locale.
This fixes https://savannah.gnu.org/bugs/?56472.
Bug existed since commit cd094822 from yesterday.
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -1924,9 +1924,15 @@ char *display_string(const char *buf, size_t column, size_t span,
#endif
}
+#ifdef ENABLE_UTF8
+#define ISO8859_CHAR FALSE
+#else
+#define ISO8859_CHAR ((unsigned char)*buf > 0x9F)
+#endif
+
while (*buf != '\0' && (column < beyond || mbwidth(buf) == 0)) {
/* A plain printable ASCII character is one byte, one column. */
- if ((signed char)*buf > 0x20 && *buf != DEL_CODE) {
+ if (((signed char)*buf > 0x20 && *buf != DEL_CODE) || ISO8859_CHAR) {
converted[index++] = *(buf++);
column++;
continue;
@@ -1971,7 +1977,7 @@ char *display_string(const char *buf, size_t column, size_t span,
if (is_cntrl_mbchar(buf)) {
converted[index++] = '^';
converted[index++] = control_mbrep(buf, isdata);
- buf += mblen(buf, MAXCHARLEN);
+ buf += char_length(buf);
column += 2;
continue;
}