about summary refs log tree commit diff
path: root/src/ctype/iswalpha.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-04-23 15:25:23 -0400
committerRich Felker <dalias@aerifal.cx>2012-04-23 15:25:23 -0400
commit7e38b1ea2bf1a0817942275cea89c959bf446d87 (patch)
tree1f35fdc54a5eb360956b3ab9ce142a29ebf2dc62 /src/ctype/iswalpha.c
parenta5d10eb1f587a13a513504ffb5d8e6a8738eee6f (diff)
downloadmusl-7e38b1ea2bf1a0817942275cea89c959bf446d87.tar.gz
musl-7e38b1ea2bf1a0817942275cea89c959bf446d87.tar.xz
musl-7e38b1ea2bf1a0817942275cea89c959bf446d87.zip
destubify iswalpha and update iswpunct to unicode 6.1
alpha is defined as unicode property "Alphabetic" plus category Nd
minus ASCII digits minus 2 special-cased Thai punctuation marks
supposedly misclassified by Unicode as letters.

punct is defined as all of unicode except control, alphanumeric, and
space characters.

the tables were generated by a simple tool based on the code posted
previously to the mailing list. in the future, this and other code
used for maintaining locale/iconv/i18n data will be published either
in the main source repository or in a separate locale data generation
repository.
Diffstat (limited to 'src/ctype/iswalpha.c')
-rw-r--r--src/ctype/iswalpha.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ctype/iswalpha.c b/src/ctype/iswalpha.c
index 0f031eac..4007c8a6 100644
--- a/src/ctype/iswalpha.c
+++ b/src/ctype/iswalpha.c
@@ -1,6 +1,14 @@
 #include <wctype.h>
 
+static unsigned char table[] = {
+#include "alpha.h"
+};
+
 int iswalpha(wint_t wc)
 {
-	return (32U|wc)-'a'<26;
+	if (wc<0x20000U)
+		return (table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1;
+	if (wc<0x2fffeU)
+		return 1;
+	return 0;
 }