]> granicus.if.org Git - mutt/commitdiff
Provide legacy implementations for iswalpha() and iswupper()
authorRocco Rutte <pdmef@gmx.net>
Wed, 24 Sep 2008 10:31:44 +0000 (12:31 +0200)
committerRocco Rutte <pdmef@gmx.net>
Wed, 24 Sep 2008 10:31:44 +0000 (12:31 +0200)
In mbyte.h and without using wc functions, only the prototypes were
defined but implementations were missing resulting in build
errors. These new functions are derived from the iswalnum() and
towupper() routines which don't provide full unicode coverage.

ChangeLog
mbyte.c

index 74f136bb32cd8f85bfbf924a26e1298a13f8fac9..b65d8f36312998768efd2e2ce144221b9cc226d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-09-24 12:28 +0200  Rocco Rutte  <pdmef@gmx.net>  (32bfe3700b27)
+
+       * imap/imap.c: Fix an infinite loop for imap searches
+
+       Reported by Emanuele Giaquinta on #mutt.
+
+2008-09-18 08:28 +0200  Rocco Rutte  <pdmef@gmx.net>  (ffefb446142c)
+
+       * ChangeLog, alias.c, init.c, muttlib.c, protos.h: Fix compiler
+       warnings
+
 2008-09-17 22:27 +0200  Thomas Roessler  <roessler@does-not-exist.org>  (77e25415a08a)
 
        * alias.c, globals.h, init.c, mutt_idna.c, muttlib.c, rfc822.h,
diff --git a/mbyte.c b/mbyte.c
index 9bc6f5d3f24f668445820de4cf2fcd6a36234399..a9c25a65b9e8b0069bb04dcc5cc5b15918411a64 100644 (file)
--- a/mbyte.c
+++ b/mbyte.c
@@ -285,6 +285,21 @@ static wint_t towupper_ucs (wint_t x)
     return x;
 }
 
+static int iswupper_ucs (wint_t x)
+{
+  /* Only works for x < 0x130 */
+  if ((0x60 < x && x < 0x7b) || (0xe0 <= x && x < 0xff && x != 0xf7))
+    return 1;
+  else if (0x100 <= x && x < 0x130)
+    return 1;
+  else if (x == 0xb5)
+    return 1;
+  else if (x == 0xff)
+    return 1;
+  else
+    return 0;
+}
+
 static wint_t towlower_ucs (wint_t x)
 {
   /* Only works for x < 0x130 */
@@ -313,6 +328,21 @@ static int iswalnum_ucs (wint_t wc)
     return !(wc == 0xd7 || wc == 0xf7);
 }
 
+static int iswalpha_ucs (wint_t wc)
+{
+  /* Only works for x < 0x220 */
+  if (wc >= 0x100)
+    return 1;
+  else if (wc < 0x3a)
+    return 0;
+  else if (wc < 0xa0)
+    return (0x40 < (wc & ~0x20) && (wc & ~0x20) < 0x5b);
+  else if (wc < 0xc0)
+    return (wc == 0xaa || wc == 0xb5 || wc == 0xba);
+  else
+    return !(wc == 0xd7 || wc == 0xf7);
+}
+
 wint_t towupper (wint_t wc)
 {
   if (Charset_is_utf8 || charset_is_ja)
@@ -337,6 +367,22 @@ int iswalnum (wint_t wc)
     return (0 <= wc && wc < 256) ? isalnum (wc) : 0;
 }
 
+int iswalpha (wint_t wc)
+{
+  if (Charset_is_utf8 || charset_is_ja)
+    return iswalpha_ucs (wc);
+  else
+    return (0 <= wc && wc < 256) ? isalpha (wc) : 0;
+}
+
+int iswupper (wint_t wc)
+{
+  if (Charset_is_utf8 || charset_is_ja)
+    return iswupper_ucs (wc);
+  else
+    return (0 <= wc && wc < 256) ? isupper (wc) : 0;
+}
+
 /*
  * l10n for Japanese:
  *   Symbols, Greek and Cyrillic in JIS X 0208, Japanese Kanji