From 24e5f956d0d017eb34963a2f5294f0d55bcd72f0 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 8 Jan 2021 12:05:55 +0100 Subject: [PATCH] build: fix compilation when configured with --disable-utf8 This fixes https://savannah.gnu.org/bugs/?59842. Reported-by: Ruben van Wyk Bug existed since commit 5129e718 from two days ago. --- src/chars.c | 6 ++++-- src/winio.c | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/chars.c b/src/chars.c index 99554551..cde5a808 100644 --- a/src/chars.c +++ b/src/chars.c @@ -286,7 +286,7 @@ int collect_char(const char *string, char *thechar) int advance_over(const char *string, size_t *column) { #ifdef ENABLE_UTF8 - if ((unsigned char)*string > 0xC1) { + if ((signed char)*string < 0) { int charlen = mblen(string, MAXCHARLEN); if (charlen > 0) { @@ -310,8 +310,10 @@ int advance_over(const char *string, size_t *column) *column += 2; } else if (*string == 0x7F) *column += 2; - else if (!use_utf8 && 0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0) +#ifndef ENABLE_UTF8 + else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0) *column += 2; +#endif else *column += 1; diff --git a/src/winio.c b/src/winio.c index b26db1be..1c05ad7a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2075,7 +2075,9 @@ void minibar(void) size_t namewidth, placewidth; size_t tallywidth = 0; size_t padding = 2; +#ifdef ENABLE_UTF8 wchar_t widecode; +#endif /* Draw a colored bar over the full width of the screen. */ wattron(bottomwin, interface_color_pair[TITLE_BAR]); @@ -2139,7 +2141,10 @@ void minibar(void) if (*this_position == '\0') sprintf(hexadecimal, openfile->current->next ? - (using_utf8() ? "U+000A" : " 0x0A") : " ----"); +#ifdef ENABLE_UTF8 + using_utf8() ? "U+000A" : +#endif + " 0x0A" : " ----"); else if (*this_position == '\n') sprintf(hexadecimal, " 0x00"); #ifdef ENABLE_UTF8