#
# usage: make-precompose.h.pl UnicodeData.txt > precompose.h
#
-# (c) 2008-2010 by HAT <hat@fa2.so-net.ne.jp>
+# (c) 2008-2011 by HAT <hat@fa2.so-net.ne.jp>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
print ("\/\* http\:\/\/www.unicode.org\/Public\/UNIDATA\/UnicodeData.txt \*\/\n");
print ("\n");
-print ("\#define HANGUL_SBASE 0xAC00\n");
-print ("\#define HANGUL_LBASE 0x1100\n");
-print ("\#define HANGUL_VBASE 0x1161\n");
-print ("\#define HANGUL_TBASE 0x11A7\n");
-print ("\#define HANGUL_LCOUNT 19\n");
-print ("\#define HANGUL_VCOUNT 21\n");
-print ("\#define HANGUL_TCOUNT 28\n");
-print ("\#define HANGUL_NCOUNT 588 \/\* (HANGUL_VCOUNT \* HANGUL_TCOUNT) \*\/\n");
-print ("\#define HANGUL_SCOUNT 11172 \/\* (HANGUL_LCOUNT \* HANGUL_NCOUNT) \*\/\n");
+print ("\#define SBASE 0xAC00\n");
+print ("\#define LBASE 0x1100\n");
+print ("\#define VBASE 0x1161\n");
+print ("\#define TBASE 0x11A7\n");
+print ("\#define LCOUNT 19\n");
+print ("\#define VCOUNT 21\n");
+print ("\#define TCOUNT 28\n");
+print ("\#define NCOUNT 588 \/\* (VCOUNT \* TCOUNT) \*\/\n");
+print ("\#define SCOUNT 11172 \/\* (LCOUNT \* NCOUNT) \*\/\n");
print ("\n");
printf ("\#define PRECOMP_COUNT %d\n", $comp_count);
/* UnicodeData.txt is got from */
/* http://www.unicode.org/Public/UNIDATA/UnicodeData.txt */
-#define HANGUL_SBASE 0xAC00
-#define HANGUL_LBASE 0x1100
-#define HANGUL_VBASE 0x1161
-#define HANGUL_TBASE 0x11A7
-#define HANGUL_LCOUNT 19
-#define HANGUL_VCOUNT 21
-#define HANGUL_TCOUNT 28
-#define HANGUL_NCOUNT 588 /* (HANGUL_VCOUNT * HANGUL_TCOUNT) */
-#define HANGUL_SCOUNT 11172 /* (HANGUL_LCOUNT * HANGUL_NCOUNT) */
+#define SBASE 0xAC00
+#define LBASE 0x1100
+#define VBASE 0x1161
+#define TBASE 0x11A7
+#define LCOUNT 19
+#define VCOUNT 21
+#define TCOUNT 28
+#define NCOUNT 588 /* (VCOUNT * TCOUNT) */
+#define SCOUNT 11172 /* (LCOUNT * NCOUNT) */
#define PRECOMP_COUNT 955
#define DECOMP_COUNT 955
ucs2_t base, comb;
u_int32_t base_sp, comb_sp;
ucs2_t *in, *out;
- ucs2_t hangul_lindex, hangul_vindex;
+ ucs2_t lindex, vindex;
ucs2_t result;
u_int32_t result_sp;
size_t o_len = *outlen;
/* Unicode Standard Annex #15 A10.3 Hangul Composition */
/* Step 1 <L,V> */
- else if ((HANGUL_VBASE <= comb) && (comb <= HANGUL_VBASE + HANGUL_VCOUNT)) {
- if ((HANGUL_LBASE <= base) && (base < HANGUL_LBASE + HANGUL_LCOUNT)) {
+ else if ((VBASE <= comb) && (comb <= VBASE + VCOUNT)) {
+ if ((LBASE <= base) && (base < LBASE + LCOUNT)) {
result = 1;
- hangul_lindex = base - HANGUL_LBASE;
- hangul_vindex = comb - HANGUL_VBASE;
- base = HANGUL_SBASE + (hangul_lindex * HANGUL_VCOUNT + hangul_vindex) * HANGUL_TCOUNT;
+ lindex = base - LBASE;
+ vindex = comb - VBASE;
+ base = SBASE + (lindex * VCOUNT + vindex) * TCOUNT;
}
}
/* Step 2 <LV,T> */
- else if ((HANGUL_TBASE < comb) && (comb < HANGUL_TBASE + HANGUL_TCOUNT)) {
- if ((HANGUL_SBASE <= base) && (base < HANGUL_SBASE +HANGUL_SCOUNT) && (((base - HANGUL_SBASE) % HANGUL_TCOUNT) == 0)) {
+ else if ((TBASE < comb) && (comb < TBASE + TCOUNT)) {
+ if ((SBASE <= base) && (base < SBASE + SCOUNT) && (((base - SBASE) % TCOUNT) == 0)) {
result = 1;
- base += comb - HANGUL_TBASE;
+ base += comb - TBASE;
}
}
size_t comblen;
ucs2_t base, comb[COMBBUFLEN];
u_int32_t base_sp;
- ucs2_t hangul_sindex, tjamo;
+ ucs2_t sindex, tjamo;
ucs2_t *in, *out;
unsigned int result;
u_int64_t result_sp;
if (base <= 0x007f) ;
/* Unicode Standard Annex #15 A10.2 Hangul Decomposition */
- else if ((HANGUL_SBASE <= base) && (base < HANGUL_SBASE + HANGUL_SCOUNT)) {
- hangul_sindex = base - HANGUL_SBASE;
- base = HANGUL_LBASE + hangul_sindex / HANGUL_NCOUNT;
- comb[COMBBUFLEN-2] = HANGUL_VBASE + (hangul_sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT;
+ else if ((SBASE <= base) && (base < SBASE + SCOUNT)) {
+ sindex = base - SBASE;
+ base = LBASE + sindex / NCOUNT;
+ comb[COMBBUFLEN-2] = VBASE + (sindex % NCOUNT) / TCOUNT;
/* <L,V> */
- if ((tjamo = HANGUL_TBASE + hangul_sindex % HANGUL_TCOUNT) == HANGUL_TBASE) {
+ if ((tjamo = TBASE + sindex % TCOUNT) == TBASE) {
comb[COMBBUFLEN-1] = comb[COMBBUFLEN-2];
comblen = 1;
}