]> granicus.if.org Git - neomutt/commitdiff
Isprint-related changes. Suggested by Andrew Nosenko, adapted by EGE.
authorThomas Roessler <roessler@does-not-exist.org>
Fri, 12 May 2000 13:38:16 +0000 (13:38 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Fri, 12 May 2000 13:38:16 +0000 (13:38 +0000)
mbyte.c
mbyte.h
wcwidth.c

diff --git a/mbyte.c b/mbyte.c
index 272c1045ba871f375a9c011e4b95ffc04138f919..c7e7f156de89dd7c91a0a9a61cc715978556877b 100644 (file)
--- 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 d3b24652d8b094a29e25b32016f1c499910809bb..464085ac86f393b1e8298cc4e87f84ac22fe8e97 100644 (file)
--- 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);
 
index 217de459294a24ad293eb02c3a096faaeef9187b..6b0933bbecbdc1c1328593500011116d78482d8d 100644 (file)
--- 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;