summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbyte.c7
-rw-r--r--mbyte.h1
-rw-r--r--wcwidth.c15
3 files changed, 20 insertions, 3 deletions
diff --git a/mbyte.c b/mbyte.c
index 272c1045..c7e7f156 100644
--- a/mbyte.c
+++ b/mbyte.c
@@ -70,10 +70,13 @@ size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
int iswprint (wint_t wc)
{
- return ((0x20 <= wc && wc < 0x7f) || 0xa0 <= wc);
+ if (Charset_is_utf8)
+ return ((0x20 <= wc && wc < 0x7f) || 0xa0 <= wc);
+ else
+ return (0 <= wc && wc < 256) ? IsPrint(wc) : 0;
}
-#endif /* HAVE_MBYTE */
+#endif /* !HAVE_WC_FUNCS */
#if !defined(HAVE_MBYTE) || !defined(HAVE_ICONV)
diff --git a/mbyte.h b/mbyte.h
index d3b24652..464085ac 100644
--- a/mbyte.h
+++ b/mbyte.h
@@ -2,6 +2,7 @@
#define _MBYTE_H
void mutt_set_charset (char *charset);
+extern int Charset_is_utf8;
size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps);
diff --git a/wcwidth.c b/wcwidth.c
index 217de459..6b0933bb 100644
--- a/wcwidth.c
+++ b/wcwidth.c
@@ -6,6 +6,10 @@
* Markus Kuhn -- 2000-02-08 -- public domain
*/
+/* Adapted for Mutt by Edmund Grimley Evans.
+ * wcwidth() now refers to Charset_is_utf8.
+ */
+
#include "mutt.h"
#include "mbyte.h"
@@ -78,9 +82,18 @@ int wcwidth(wchar_t ucs)
int max = sizeof(combining) / sizeof(struct interval) - 1;
int mid;
- /* test for 8-bit control characters */
if (ucs == 0)
return 0;
+
+ /* non-UCS case */
+ if (!Charset_is_utf8) {
+ if (0 <= ucs && ucs < 256)
+ return IsPrint(wc) ? 1 : -1;
+ else
+ return -1;
+ }
+
+ /* test for 8-bit control characters */
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
return -1;