The iswblank() call was added to mutt_format_string() in commit
7074b571, more recently than all the mbyte.[ch] substitution code
added about 25 years ago.
Unfortunately, when added, it wasn't included in the HAVE_WC_FUNCS
tests, and a replacement was not created in mbyte.c for when mutt is
configured with --without-wc-funcs. This led to a compilation error
in that (apparently rarely used) configuration, because wctype.h is
not included in that case.
Honestly the code is a little bit confusing, but I've preserved the
existing conventions for this stable branch fix.
---
Note: this is a stable branch fix I'll include in 2.3.1 in the next week
or two.
I haven't done very much work in this mbyte.[ch] code before. So I've
tried to keep it simple and modeled the changes after the iswspace()
replacement code. It feels like a lot of this "replacement stuff" could
be tossed out at this point, but that's a different discussion.
This should fix the compilation error Vsevolod Volkov reported when he
configured --without-wc-funcs.
configure.ac | 2 +-
curs_lib.c | 2 --
mbyte.c | 8 ++++++++
mbyte.h | 4 ++++
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 66df29ed..8608edf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1562,7 +1562,7 @@ if test "$wc_funcs" != yes && test "$wc_funcs" != no; then
#endif
#ifdef HAVE_WCTYPE_H
#include <wctype.h>
-#endif]], [[mbrtowc(0, 0, 0, 0); wctomb(0, 0); wcwidth(0);
+#endif]], [[mbrtowc(0, 0, 0, 0); wctomb(0, 0); wcwidth(0); iswblank(0);
iswprint(0); iswspace(0); towlower(0); towupper(0);
iswalnum(0)]])],[mutt_cv_wc_funcs=yes],[]))
wc_funcs=$mutt_cv_wc_funcs
fi
diff --git a/curs_lib.c b/curs_lib.c
index 246cb6be..1a5caad8 100644
--- a/curs_lib.c
+++ b/curs_lib.c
@@ -1380,11 +1380,9 @@ void mutt_format_string (char *dest, size_t destlen,
w = 1; /* hack */
else
{
-#ifdef HAVE_ISWBLANK
if (iswblank (wc))
wc = ' ';
else
-#endif
if (!IsWPrint (wc))
wc = '?';
w = wcwidth (wc);
diff --git a/mbyte.c b/mbyte.c
index 16645feb..b39c2a04 100644
--- a/mbyte.c
+++ b/mbyte.c
@@ -270,6 +270,14 @@ int iswspace (wint_t wc)
return (0 <= wc && wc < 256) ? isspace (wc) : 0;
}
+int iswblank (wint_t wc)
+{
+ if (Charset_is_utf8 || charset_is_ja)
+ return wc == 9 || wc == 32;
+ else
+ return (0 <= wc && wc < 256) ? isblank (wc) : 0;
+}
+
static wint_t towupper_ucs (wint_t x)
{
/* Only works for x < 0x130 */
diff --git a/mbyte.h b/mbyte.h
index 9c58c9ec..1580d223 100644
--- a/mbyte.h
+++ b/mbyte.h
@@ -23,6 +23,9 @@
#ifdef iswspace
# undef iswspace
#endif
+#ifdef iswblank
+# undef iswblank
+#endif
#ifdef iswalnum
# undef iswalnum
#endif
@@ -36,6 +39,7 @@ size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
int iswprint (wint_t wc);
int iswspace (wint_t wc);
+int iswblank (wint_t wc);
int iswalnum (wint_t wc);
int iswalpha (wint_t wc);
int iswupper (wint_t wc);
--
2.52.0