aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-28 22:03:48 +0100
committerMattias Andrée <m@maandree.se>2026-01-28 22:03:48 +0100
commit40bf70fb8f23e5ff7212b568c69e0725372e5b57 (patch)
tree0d4be706d0182ddeafd4eaafd073e12c2fa2a9e8
parentMisc stuff (diff)
downloadcharconv-40bf70fb8f23e5ff7212b568c69e0725372e5b57.tar.gz
charconv-40bf70fb8f23e5ff7212b568c69e0725372e5b57.tar.bz2
charconv-40bf70fb8f23e5ff7212b568c69e0725372e5b57.tar.xz
Clean up
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--Makefile4
-rw-r--r--lib-common.h90
-rw-r--r--libcharconv_bold.c17
-rw-r--r--libcharconv_bold_fraktur.c13
-rw-r--r--libcharconv_bold_italic.c13
-rw-r--r--libcharconv_bold_script.c13
-rw-r--r--libcharconv_buginese.c24
-rw-r--r--libcharconv_buhid.c17
-rw-r--r--libcharconv_chess_black.c25
-rw-r--r--libcharconv_chess_neutral.c16
-rw-r--r--libcharconv_chess_white.c25
-rw-r--r--libcharconv_dice.c14
-rw-r--r--libcharconv_double_struck.c45
-rw-r--r--libcharconv_double_struck_italic.c13
-rw-r--r--libcharconv_draughts.c15
-rw-r--r--libcharconv_flipped.c16
-rw-r--r--libcharconv_fraktur.c33
-rw-r--r--libcharconv_ideographic_tally_marks.c13
-rw-r--r--libcharconv_invisible.c12
-rw-r--r--libcharconv_italic.c17
-rw-r--r--libcharconv_latin.c14
-rw-r--r--libcharconv_lycian.c47
-rw-r--r--libcharconv_lydian.c48
-rw-r--r--libcharconv_mandaic.c51
-rw-r--r--libcharconv_monospace.c17
-rw-r--r--libcharconv_ocr.c27
-rw-r--r--libcharconv_region_indicators.c12
-rw-r--r--libcharconv_rotated_45deg_ccw.c79
-rw-r--r--libcharconv_rotated_45deg_cw.c36
-rw-r--r--libcharconv_rotated_90deg_ccw.c150
-rw-r--r--libcharconv_rotated_90deg_cw.c128
-rw-r--r--libcharconv_sans_serif.c14
-rw-r--r--libcharconv_sans_serif_bold.c17
-rw-r--r--libcharconv_sans_serif_bold_italic.c13
-rw-r--r--libcharconv_sans_serif_italic.c13
-rw-r--r--libcharconv_script.c57
-rw-r--r--libcharconv_segmented.c9
-rw-r--r--libcharconv_shogi.c15
-rw-r--r--libcharconv_sora_sompeng.c54
-rw-r--r--libcharconv_subscript.c9
-rw-r--r--libcharconv_superscript.c16
-rw-r--r--libcharconv_tags.c9
-rw-r--r--libcharconv_tally_marks.c11
-rw-r--r--libcharconv_transposed.c8
-rw-r--r--libcharconv_turned.c32
-rw-r--r--libcharconv_vulgar_fractions.c54
-rw-r--r--libcharconv_yijing_digrams.c27
-rw-r--r--libcharconv_yijing_hexagrams.c14
-rw-r--r--libcharconv_yijing_hexagrams_.c14
-rw-r--r--libcharconv_yijing_monograms.c13
50 files changed, 339 insertions, 1104 deletions
diff --git a/Makefile b/Makefile
index af91a7e..0e4a791 100644
--- a/Makefile
+++ b/Makefile
@@ -97,6 +97,7 @@ BIN =\
LIBOBJ =\
libcharconv_decode_utf8_.o\
+ libcharconv_yijing_hexagrams_.o\
libcharconv_shogi.o\
libcharconv_dice.o\
libcharconv_go_white.o\
@@ -193,6 +194,9 @@ $(LIBOBJ): libcharconv.h lib-common.h
$(LOBJ): libcharconv.h lib-common.h
$(BIN): common.o libcharconv.a
+libcharconv_rotated_90deg_ccw.o libcharconv_rotated_90deg_ccw.lo: libcharconv_rotated_90deg_cw.c
+libcharconv_rotated_45deg_ccw.o libcharconv_rotated_45deg_ccw.lo: libcharconv_rotated_45deg_cw.c
+
.c.o:
$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
diff --git a/lib-common.h b/lib-common.h
index eb8cab9..2ab89a0 100644
--- a/lib-common.h
+++ b/lib-common.h
@@ -1,7 +1,97 @@
/* See LICENSE file for copyright and license details. */
#include "libcharconv.h"
+#include <ctype.h>
#include <string.h>
#include <strings.h>
size_t libcharconv_decode_utf8_(const char *s, size_t slen, uint_least32_t *cp);
+
+extern const unsigned char libcharconv_yijing_hexagrams_[];
+
+
+#define CYCLE_2(A, B)\
+ {UINT32_C(A), UINT32_C(B)},\
+ {UINT32_C(B), UINT32_C(A)}
+
+#define CYCLE_4(A, B, C, D)\
+ {UINT32_C(A), UINT32_C(B)},\
+ {UINT32_C(B), UINT32_C(C)},\
+ {UINT32_C(C), UINT32_C(D)},\
+ {UINT32_C(D), UINT32_C(A)}
+
+#define CYCLE_8(A, B, C, D, E, F, G, H)\
+ {UINT32_C(A), UINT32_C(B)},\
+ {UINT32_C(B), UINT32_C(C)},\
+ {UINT32_C(C), UINT32_C(D)},\
+ {UINT32_C(D), UINT32_C(E)},\
+ {UINT32_C(E), UINT32_C(F)},\
+ {UINT32_C(F), UINT32_C(G)},\
+ {UINT32_C(G), UINT32_C(H)},\
+ {UINT32_C(H), UINT32_C(A)}
+
+
+#define PLAIN_RANGE(FIRST, LAST, FIRST_CP)\
+ do {\
+ if ((FIRST) <= *s && *s <= (LAST)) { \
+ c = (uint_least32_t)(UINT32_C(FIRST_CP) + (unsigned)(*s - (FIRST)));\
+ goto conv;\
+ }\
+ } while (0)
+
+#define PLAIN_CASE_RANGE(FIRST, LAST, FIRST_CP)\
+ do {\
+ if (tolower(FIRST) <= tolower(*s) && tolower(*s) <= tolower(LAST)) { \
+ c = (uint_least32_t)(UINT32_C(FIRST_CP) + (unsigned)(tolower(*s) - tolower(FIRST)));\
+ goto conv;\
+ }\
+ } while (0)
+
+#define PLAIN_SINGLE(C, CP)\
+ do {\
+ if (*s == (C)) {\
+ c = (uint_least32_t)UINT32_C(CP);\
+ goto conv;\
+ }\
+ } while (0)
+
+#define PLAIN_CASE_SINGLE(C, CP)\
+ do {\
+ if (*s == tolower(C) || *s == toupper(C)) {\
+ c = (uint_least32_t)UINT32_C(CP);\
+ goto conv;\
+ }\
+ } while (0)
+
+#define PLAIN_SELECT(CS, FIRST_CP)\
+ do {\
+ size_t i__;\
+ for (i__ = 0u; (CS)[i__]; i__++) {\
+ if (*s == (CS)[i__]) {\
+ c = (uint_least32_t)(UINT32_C(FIRST_CP) + i__);\
+ goto conv;\
+ }\
+ }\
+ } while (0)
+
+#define PLAIN_CASE_SELECT(CS, FIRST_CP)\
+ do {\
+ size_t i__;\
+ for (i__ = 0u; (CS)[i__]; i__++) {\
+ if (*s == tolower((CS)[i__]) || *s == toupper((CS)[i__])) {\
+ c = (uint_least32_t)(UINT32_C(FIRST_CP) + i__); \
+ goto conv;\
+ }\
+ }\
+ } while (0)
+
+#define PLAIN_RANGE_SWAP(LOW_FIRST, LOW_LAST, HIGH_FIRST, HIGH_LAST)\
+ do {\
+ if (UINT32_C(LOW_FIRST) <= c && c <= UINT32_C(LOW_LAST)) {\
+ c += UINT32_C(HIGH_FIRST) - UINT32_C(LOW_FIRST);\
+ goto conv;\
+ } else if (UINT32_C(HIGH_FIRST) <= c && c <= UINT32_C(HIGH_LAST)) {\
+ c -= UINT32_C(HIGH_FIRST) - UINT32_C(LOW_FIRST);\
+ goto conv;\
+ }\
+ } while (0)
diff --git a/libcharconv_bold.c b/libcharconv_bold.c
index 9e1bd6e..9da001c 100644
--- a/libcharconv_bold.c
+++ b/libcharconv_bold.c
@@ -7,19 +7,10 @@ libcharconv_bold(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D400) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D41A) + (unsigned)(*s - 'a'));
- goto conv;
- } else if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x1D7CE) + (unsigned)(*s - '0'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D400);
+ PLAIN_RANGE('a', 'z', 0x1D41A);
+ PLAIN_RANGE('0', '9', 0x1D7CE);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_bold_fraktur.c b/libcharconv_bold_fraktur.c
index 50c6004..1245f83 100644
--- a/libcharconv_bold_fraktur.c
+++ b/libcharconv_bold_fraktur.c
@@ -7,16 +7,9 @@ libcharconv_bold_fraktur(const char *s, size_t slen, size_t *n, uint_least32_t *
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D56C) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D586) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D56C);
+ PLAIN_RANGE('a', 'z', 0x1D586);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_bold_italic.c b/libcharconv_bold_italic.c
index 15b309b..1cbd5cb 100644
--- a/libcharconv_bold_italic.c
+++ b/libcharconv_bold_italic.c
@@ -7,16 +7,9 @@ libcharconv_bold_italic(const char *s, size_t slen, size_t *n, uint_least32_t *c
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D468) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D482) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D468);
+ PLAIN_RANGE('a', 'z', 0x1D482);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_bold_script.c b/libcharconv_bold_script.c
index d3a5c7a..f037275 100644
--- a/libcharconv_bold_script.c
+++ b/libcharconv_bold_script.c
@@ -7,16 +7,9 @@ libcharconv_bold_script(const char *s, size_t slen, size_t *n, uint_least32_t *c
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D4D0) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D4EA) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D4D0);
+ PLAIN_RANGE('a', 'z', 0x1D4EA);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_buginese.c b/libcharconv_buginese.c
index 311ab4c..16317c5 100644
--- a/libcharconv_buginese.c
+++ b/libcharconv_buginese.c
@@ -8,30 +8,10 @@ libcharconv_buginese(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
uint_least32_t c, c2;
*n = 0;
for (; slen--; s++) {
+ PLAIN_SELECT("kgGKpbmMtdnRcjYCyrlvs", 0x1A00);
+ PLAIN_SINGLE('h', 0x1A16);
switch (s[0]) {
- case 'k': c = UINT32_C(0x1A00); goto conv;
- case 'g': c = UINT32_C(0x1A01); goto conv;
- case 'G': c = UINT32_C(0x1A02); goto conv;
- case 'K': c = UINT32_C(0x1A03); goto conv;
- case 'p': c = UINT32_C(0x1A04); goto conv;
- case 'b': c = UINT32_C(0x1A05); goto conv;
- case 'm': c = UINT32_C(0x1A06); goto conv;
- case 'M': c = UINT32_C(0x1A07); goto conv;
- case 't': c = UINT32_C(0x1A08); goto conv;
- case 'd': c = UINT32_C(0x1A09); goto conv;
- case 'n': c = UINT32_C(0x1A0A); goto conv;
- case 'R': c = UINT32_C(0x1A0B); goto conv;
- case 'c': c = UINT32_C(0x1A0C); goto conv;
- case 'j': c = UINT32_C(0x1A0D); goto conv;
- case 'Y': c = UINT32_C(0x1A0E); goto conv;
- case 'C': c = UINT32_C(0x1A0F); goto conv;
- case 'y': c = UINT32_C(0x1A10); goto conv;
- case 'r': c = UINT32_C(0x1A11); goto conv;
- case 'l': c = UINT32_C(0x1A12); goto conv;
- case 'v': c = UINT32_C(0x1A13); goto conv;
- case 's': c = UINT32_C(0x1A14); goto conv;
case 'a': c = UINT32_C(0x1A15); goto conv1;
- case 'h': c = UINT32_C(0x1A16); goto conv;
case 'i': c = UINT32_C(0x1A17); goto conv_vowel;
case 'u': c = UINT32_C(0x1A18); goto conv_vowel;
case 'e': c = UINT32_C(0x1A19); goto conv_vowel;
diff --git a/libcharconv_buhid.c b/libcharconv_buhid.c
index 8abad6a..881ca08 100644
--- a/libcharconv_buhid.c
+++ b/libcharconv_buhid.c
@@ -8,6 +8,9 @@ libcharconv_buhid(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
uint_least32_t c;
*n = 0;
for (; slen--; s++) {
+ PLAIN_CASE_SINGLE('k', 0x1743);
+ PLAIN_CASE_SINGLE('g', 0x1744);
+ PLAIN_CASE_SELECT("tdnpbmyrlwsh", 0x1746);
switch (s[0]) {
case 'A': case 'a': c = UINT32_C(0x1740); goto conv1;
case 'I': case 'i': c = UINT32_C(0x1741); goto conv1;
@@ -22,20 +25,6 @@ libcharconv_buhid(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
goto no_match;
}
goto no_match;
- case 'B': case 'b': c = UINT32_C(0x174A); goto conv;
- case 'D': case 'd': c = UINT32_C(0x1747); goto conv;
- case 'G': case 'g': c = UINT32_C(0x1744); goto conv;
- case 'H': case 'h': c = UINT32_C(0x1751); goto conv;
- case 'K': case 'k': c = UINT32_C(0x1743); goto conv;
- case 'L': case 'l': c = UINT32_C(0x174E); goto conv;
- case 'M': case 'm': c = UINT32_C(0x174B); goto conv;
- case 'N': case 'n': c = UINT32_C(0x1748); goto conv;
- case 'P': case 'p': c = UINT32_C(0x1749); goto conv;
- case 'R': case 'r': c = UINT32_C(0x174D); goto conv;
- case 'S': case 's': c = UINT32_C(0x1750); goto conv;
- case 'T': case 't': c = UINT32_C(0x1746); goto conv;
- case 'Y': case 'y': c = UINT32_C(0x174C); goto conv;
- case 'W': case 'w': c = UINT32_C(0x174F); goto conv;
default:
no_match:
*n += 1u;
diff --git a/libcharconv_chess_black.c b/libcharconv_chess_black.c
index 906c2f7..480c872 100644
--- a/libcharconv_chess_black.c
+++ b/libcharconv_chess_black.c
@@ -7,26 +7,11 @@ libcharconv_chess_black(const char *s, size_t slen, size_t *n, uint_least32_t *c
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case 'K': c = UINT32_C(0x2654); goto conv;
- case 'Q': c = UINT32_C(0x2655); goto conv;
- case 'R': c = UINT32_C(0x2656); goto conv;
- case 'B': c = UINT32_C(0x2657); goto conv;
- case 'N': c = UINT32_C(0x2658); goto conv;
- case 'P': c = UINT32_C(0x2659); goto conv;
- case 'E': c = UINT32_C(0x1FA48); goto conv;
- case 'k': c = UINT32_C(0x265A); goto conv;
- case 'q': c = UINT32_C(0x265B); goto conv;
- case 'r': c = UINT32_C(0x265C); goto conv;
- case 'b': c = UINT32_C(0x265D); goto conv;
- case 'n': c = UINT32_C(0x265E); goto conv;
- case 'p': c = UINT32_C(0x265F); goto conv;
- case 'e': c = UINT32_C(0x1FA49); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("KQRBNP", 0x2654);
+ PLAIN_SELECT("kqrbnp", 0x265A);
+ PLAIN_SINGLE('E', 0x1FA48);
+ PLAIN_SINGLE('e', 0x1FA49);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_chess_neutral.c b/libcharconv_chess_neutral.c
index 04f548d..2a11eda 100644
--- a/libcharconv_chess_neutral.c
+++ b/libcharconv_chess_neutral.c
@@ -7,19 +7,9 @@ libcharconv_chess_neutral(const char *s, size_t slen, size_t *n, uint_least32_t
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case 'k': case 'K': c = UINT32_C(0x1FA00); goto conv;
- case 'q': case 'Q': c = UINT32_C(0x1FA01); goto conv;
- case 'r': case 'R': c = UINT32_C(0x1FA02); goto conv;
- case 'b': case 'B': c = UINT32_C(0x1FA03); goto conv;
- case 'n': case 'N': c = UINT32_C(0x1FA04); goto conv;
- case 'p': case 'P': c = UINT32_C(0x1FA05); goto conv;
- case 'e': case 'E': c = UINT32_C(0x1FA4A); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_CASE_SELECT("kqrbnp", 0x1FA00);
+ PLAIN_CASE_SINGLE('e', 0x1FA4A);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_chess_white.c b/libcharconv_chess_white.c
index 1c72e26..f6233a1 100644
--- a/libcharconv_chess_white.c
+++ b/libcharconv_chess_white.c
@@ -7,26 +7,11 @@ libcharconv_chess_white(const char *s, size_t slen, size_t *n, uint_least32_t *c
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case 'k': c = UINT32_C(0x2654); goto conv;
- case 'q': c = UINT32_C(0x2655); goto conv;
- case 'r': c = UINT32_C(0x2656); goto conv;
- case 'b': c = UINT32_C(0x2657); goto conv;
- case 'n': c = UINT32_C(0x2658); goto conv;
- case 'p': c = UINT32_C(0x2659); goto conv;
- case 'e': c = UINT32_C(0x1FA48); goto conv;
- case 'K': c = UINT32_C(0x265A); goto conv;
- case 'Q': c = UINT32_C(0x265B); goto conv;
- case 'R': c = UINT32_C(0x265C); goto conv;
- case 'B': c = UINT32_C(0x265D); goto conv;
- case 'N': c = UINT32_C(0x265E); goto conv;
- case 'P': c = UINT32_C(0x265F); goto conv;
- case 'E': c = UINT32_C(0x1FA49); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("kqrbnp", 0x2654);
+ PLAIN_SELECT("KQRBNP", 0x265A);
+ PLAIN_SINGLE('e', 0x1FA48);
+ PLAIN_SINGLE('E', 0x1FA49);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_dice.c b/libcharconv_dice.c
index dc02bb5..5bcae87 100644
--- a/libcharconv_dice.c
+++ b/libcharconv_dice.c
@@ -7,18 +7,8 @@ libcharconv_dice(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case '1': c = UINT32_C(0x2680); goto conv;
- case '2': c = UINT32_C(0x2681); goto conv;
- case '3': c = UINT32_C(0x2682); goto conv;
- case '4': c = UINT32_C(0x2683); goto conv;
- case '5': c = UINT32_C(0x2684); goto conv;
- case '6': c = UINT32_C(0x2685); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('1', '6', 0x2680);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_double_struck.c b/libcharconv_double_struck.c
index ae64247..2a7fa4f 100644
--- a/libcharconv_double_struck.c
+++ b/libcharconv_double_struck.c
@@ -7,40 +7,17 @@ libcharconv_double_struck(const char *s, size_t slen, size_t *n, uint_least32_t
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if (*s == 'C') {
- c = (uint_least32_t)UINT32_C(0x2102);
- goto conv;
- } else if (*s == 'H') {
- c = (uint_least32_t)UINT32_C(0x210D);
- goto conv;
- } else if (*s == 'N') {
- c = (uint_least32_t)UINT32_C(0x2115);
- goto conv;
- } else if (*s == 'P') {
- c = (uint_least32_t)UINT32_C(0x2119);
- goto conv;
- } else if (*s == 'Q') {
- c = (uint_least32_t)UINT32_C(0x211A);
- goto conv;
- } else if (*s == 'R') {
- c = (uint_least32_t)UINT32_C(0x211D);
- goto conv;
- } else if (*s == 'Z') {
- c = (uint_least32_t)UINT32_C(0x2124);
- goto conv;
- } else if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D538) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D552) + (unsigned)(*s - 'a'));
- goto conv;
- } else if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x1D7D8) + (unsigned)(*s - '0'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('C', 0x2102);
+ PLAIN_SINGLE('H', 0x210D);
+ PLAIN_SINGLE('N', 0x2115);
+ PLAIN_SINGLE('P', 0x2119);
+ PLAIN_SINGLE('Q', 0x211A);
+ PLAIN_SINGLE('R', 0x211D);
+ PLAIN_SINGLE('Z', 0x2124);
+ PLAIN_RANGE('A', 'Z', 0x1D538);
+ PLAIN_RANGE('a', 'z', 0x1D552);
+ PLAIN_RANGE('0', '9', 0x1D7D8);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_double_struck_italic.c b/libcharconv_double_struck_italic.c
index beb80a0..f3f3248 100644
--- a/libcharconv_double_struck_italic.c
+++ b/libcharconv_double_struck_italic.c
@@ -7,17 +7,8 @@ libcharconv_double_struck_italic(const char *s, size_t slen, size_t *n, uint_lea
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case 'D': c = UINT32_C(0x2145); goto conv;
- case 'd': c = UINT32_C(0x2146); goto conv;
- case 'e': c = UINT32_C(0x2147); goto conv;
- case 'i': c = UINT32_C(0x2148); goto conv;
- case 'j': c = UINT32_C(0x2149); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("Ddeij", 0x2145);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_draughts.c b/libcharconv_draughts.c
index b45f4fe..00b97c9 100644
--- a/libcharconv_draughts.c
+++ b/libcharconv_draughts.c
@@ -7,18 +7,9 @@ libcharconv_draughts(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case '1':
- case 'm': c = UINT32_C(0x26C0); goto conv;
- case '2':
- case 'k': c = UINT32_C(0x26C1); goto conv;
- case 'M': c = UINT32_C(0x26C2); goto conv;
- case 'K': c = UINT32_C(0x26C3); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("mkMK", 0x26C0);
+ PLAIN_RANGE('1', '2', 0x26C0);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_flipped.c b/libcharconv_flipped.c
index 49f2c9b..3da791c 100644
--- a/libcharconv_flipped.c
+++ b/libcharconv_flipped.c
@@ -2,18 +2,6 @@
#include "lib-common.h"
-static unsigned char yijing_hexagrams[] = {
- 0xC0, 0xEB, 0xCC, 0xE0, 0xC9, 0xC5, 0xD8, 0xCB,
- 0xC8, 0xF8, 0xE4, 0xF4, 0xFC, 0xFA, 0xE9, 0xD3,
- 0xCD, 0xF1, 0xDD, 0xF7, 0xE5, 0xFF, 0xD4, 0xE2,
- 0xD9, 0xD1, 0xD5, 0xF3, 0xE8, 0xC3, 0xDA, 0xD6,
- 0xEA, 0xDB, 0xF0, 0xDE, 0xF9, 0xEE, 0xD0, 0xEC,
- 0xC4, 0xEF, 0xFE, 0xE6, 0xFB, 0xDC, 0xC2, 0xC7,
- 0xE1, 0xDF, 0xF6, 0xFD, 0xF5, 0xE7, 0xF2, 0xCF,
- 0xCA, 0xED, 0xE3, 0xCE, 0xD2, 0xC6, 0xD7, 0xC1
-};
-
-
static struct {
uint_least32_t a;
uint_least32_t b;
@@ -80,7 +68,7 @@ libcharconv_flipped(const char *s, size_t slen, size_t *n, uint_least32_t *cp, s
goto conv;
} else if (UINT32_C(0x4DC0) <= c && c <= UINT32_C(0x4DFF)) {
for (i = 0u;; i++)
- if ((c & 0xFFu) == yijing_hexagrams[i])
+ if ((c & 0xFFu) == libcharconv_yijing_hexagrams_[i])
break;
c = (i & 32u) ? 1u : 0u;
c |= (i & 16u) ? 2u : 0u;
@@ -88,7 +76,7 @@ libcharconv_flipped(const char *s, size_t slen, size_t *n, uint_least32_t *cp, s
c |= (i & 4u) ? 8u : 0u;
c |= (i & 2u) ? 16u : 0u;
c |= (i & 1u) ? 32u : 0u;
- c = UINT32_C(0x4D00) | yijing_hexagrams[c];
+ c = UINT32_C(0x4D00) | libcharconv_yijing_hexagrams_[c];
goto conv;
} else if (UINT32_C(0x2800) <= c && c <= UINT32_C(0x28FF)) {
c = ((c & 0x01u) << 6) | ((c & 0x40u) >> 6)
diff --git a/libcharconv_fraktur.c b/libcharconv_fraktur.c
index e04d6ab..713e9a6 100644
--- a/libcharconv_fraktur.c
+++ b/libcharconv_fraktur.c
@@ -7,31 +7,14 @@ libcharconv_fraktur(const char *s, size_t slen, size_t *n, uint_least32_t *cp, s
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if (*s == 'C') {
- c = (uint_least32_t)UINT32_C(0x212D);
- goto conv;
- } else if (*s == 'H') {
- c = (uint_least32_t)UINT32_C(0x210C);
- goto conv;
- } else if (*s == 'I') {
- c = (uint_least32_t)UINT32_C(0x2111);
- goto conv;
- } else if (*s == 'R') {
- c = (uint_least32_t)UINT32_C(0x211C);
- goto conv;
- } else if (*s == 'Z') {
- c = (uint_least32_t)UINT32_C(0x2128);
- goto conv;
- } else if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D504) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D51E) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('C', 0x212D);
+ PLAIN_SINGLE('H', 0x210C);
+ PLAIN_SINGLE('I', 0x2111);
+ PLAIN_SINGLE('R', 0x211C);
+ PLAIN_SINGLE('Z', 0x2128);
+ PLAIN_RANGE('A', 'Z', 0x1D504);
+ PLAIN_RANGE('a', 'z', 0X1D51E);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_ideographic_tally_marks.c b/libcharconv_ideographic_tally_marks.c
index 508c3cc..601c637 100644
--- a/libcharconv_ideographic_tally_marks.c
+++ b/libcharconv_ideographic_tally_marks.c
@@ -7,17 +7,8 @@ libcharconv_ideographic_tally_marks(const char *s, size_t slen, size_t *n, uint_
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case '1': c = UINT32_C(0x13D72); goto conv;
- case '2': c = UINT32_C(0x13D73); goto conv;
- case '3': c = UINT32_C(0x13D74); goto conv;
- case '4': c = UINT32_C(0x13D75); goto conv;
- case '5': c = UINT32_C(0x13D76); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('1', '5', 0x13D72);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_invisible.c b/libcharconv_invisible.c
index a3bda95..64d9ad0 100644
--- a/libcharconv_invisible.c
+++ b/libcharconv_invisible.c
@@ -7,16 +7,8 @@ libcharconv_invisible(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case '(': c = UINT32_C(0x2061); goto conv;
- case '*': c = UINT32_C(0x2062); goto conv;
- case '|': c = UINT32_C(0x2063); goto conv;
- case '+': c = UINT32_C(0x2064); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("(*|+", 0x2061);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_italic.c b/libcharconv_italic.c
index 134c2cb..43d6f0c 100644
--- a/libcharconv_italic.c
+++ b/libcharconv_italic.c
@@ -7,19 +7,10 @@ libcharconv_italic(const char *s, size_t slen, size_t *n, uint_least32_t *cp, si
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D434) + (unsigned)(*s - 'A'));
- goto conv;
- } else if (*s == 'h') {
- c = (uint_least32_t)UINT32_C(0x210E);
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D44E) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('h', 0x210E);
+ PLAIN_RANGE('A', 'Z', 0x1D434);
+ PLAIN_RANGE('a', 'z', 0x1D44E);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_latin.c b/libcharconv_latin.c
index 20e3fd9..49de445 100644
--- a/libcharconv_latin.c
+++ b/libcharconv_latin.c
@@ -2,18 +2,6 @@
#include "lib-common.h"
-static unsigned char yijing_hexagrams[] = {
- 0xC0, 0xEB, 0xCC, 0xE0, 0xC9, 0xC5, 0xD8, 0xCB,
- 0xC8, 0xF8, 0xE4, 0xF4, 0xFC, 0xFA, 0xE9, 0xD3,
- 0xCD, 0xF1, 0xDD, 0xF7, 0xE5, 0xFF, 0xD4, 0xE2,
- 0xD9, 0xD1, 0xD5, 0xF3, 0xE8, 0xC3, 0xDA, 0xD6,
- 0xEA, 0xDB, 0xF0, 0xDE, 0xF9, 0xEE, 0xD0, 0xEC,
- 0xC4, 0xEF, 0xFE, 0xE6, 0xFB, 0xDC, 0xC2, 0xC7,
- 0xE1, 0xDF, 0xF6, 0xFD, 0xF5, 0xE7, 0xF2, 0xCF,
- 0xCA, 0xED, 0xE3, 0xCE, 0xD2, 0xC6, 0xD7, 0xC1
-};
-
-
enum libcharconv_result
libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
@@ -457,7 +445,7 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
/* yijing hexagrams */
c &= 0xFFu;
for (i = 0u;; i++)
- if (yijing_hexagrams[i] == (unsigned char)c)
+ if (libcharconv_yijing_hexagrams_[i] == (unsigned char)c)
break;
c6 = (i & 1u) ? '2' : '1';
c5 = (i & 2u) ? '2' : '1';
diff --git a/libcharconv_lycian.c b/libcharconv_lycian.c
index 7998ecb..f34adda 100644
--- a/libcharconv_lycian.c
+++ b/libcharconv_lycian.c
@@ -2,52 +2,13 @@
#include "lib-common.h"
-static struct {
- unsigned char cp_low;
- char latin;
-} lycian[] = {
- {0x80, 'a'},
- {0x82, 'b'},
- {0x85, 'd'},
- {0x81, 'e'},
- {0x84, 'g'},
- {0x9B, 'h'},
- {0x86, 'i'},
- {0x8A, 'j'},
- {0x8B, 'k'},
- {0x8D, 'l'},
- {0x8E, 'm'},
- {0x8F, 'n'},
- {0x93, 'p'},
- {0x8C, 'q'},
- {0x95, 'r'},
- {0x96, 's'},
- {0x97, 't'},
- {0x92, 'u'},
- {0x87, 'w'},
- {0x9C, 'x'},
- {0x88, 'z'},
- {0x99, 'A'},
- {0x83, 'B'},
- {0x89, 'D'},
- {0x9A, 'E'},
- {0x94, 'K'},
- {0x90, 'M'},
- {0x91, 'N'},
- {0x98, 'T'}
-};
-
-
enum libcharconv_result
libcharconv_lycian(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
- size_t i;
+ uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- for (i = 0u; i < sizeof(lycian) / sizeof(*lycian); i++)
- if (*s == lycian[i].latin)
- goto conv;
- *n += 1u;
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("aebBgdiwzDjkqlmnMNupKrstTAEhx", 0x10280);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
@@ -56,7 +17,7 @@ conv:
if (*n)
goto no_conv;
if (*ncp)
- *cp = (uint_least32_t)(UINT32_C(0x10200) | lycian[i].cp_low);
+ *cp = c;
*n += 1u;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
diff --git a/libcharconv_lydian.c b/libcharconv_lydian.c
index a3427fa..2165a59 100644
--- a/libcharconv_lydian.c
+++ b/libcharconv_lydian.c
@@ -2,51 +2,15 @@
#include "lib-common.h"
-static struct {
- unsigned char cp_low;
- char latin;
-} lydian[] = {
- {0x20, 'a'},
- {0x21, 'b'},
- {0x39, 'c'},
- {0x23, 'd'},
- {0x24, 'e'},
- {0x31, 'f'},
- {0x22, 'g'},
- {0x26, 'i'},
- {0x28, 'k'},
- {0x29, 'l'},
- {0x2A, 'm'},
- {0x2B, 'n'},
- {0x2C, 'o'},
- {0x32, 'q'},
- {0x2D, 'r'},
- {0x33, 's'},
- {0x2F, 't'},
- {0x30, 'u'},
- {0x25, 'v'},
- {0x27, 'y'},
- {0x35, 'A'},
- {0x36, 'E'},
- {0x37, 'L'},
- {0x38, 'N'},
- {0x2E, 'S'},
- {0x34, 'T'},
- {0x3F, '\"'},
- {0x3F, '\''}
-};
-
-
enum libcharconv_result
libcharconv_lydian(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
- size_t i;
+ uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- for (i = 0u; i < sizeof(lydian) / sizeof(*lydian); i++)
- if (*s == lydian[i].latin)
- goto conv;
- *n += 1u;
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("abgdeviyklmnorStufqsTAELNc", 0x10920);
+ PLAIN_SINGLE('\"', 0x1093F);
+ PLAIN_SINGLE('\'', 0x1093F);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
@@ -55,7 +19,7 @@ conv:
if (*n)
goto no_conv;
if (*ncp)
- *cp = (uint_least32_t)(UINT32_C(0x10900) | lydian[i].cp_low);
+ *cp = c;
*n += 1u;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
diff --git a/libcharconv_mandaic.c b/libcharconv_mandaic.c
index a29ea66..7845fcb 100644
--- a/libcharconv_mandaic.c
+++ b/libcharconv_mandaic.c
@@ -2,54 +2,15 @@
#include "lib-common.h"
-static struct {
- unsigned char cp_low;
- char latin;
-} mandaic[] = {
- {0x40, 'a'},
- {0x41, 'b'},
- {0x42, 'g'},
- {0x43, 'd'},
- {0x44, 'h'},
- {0x45, 'u'},
- {0x45, 'w'},
- {0x46, 'z'},
- {0x47, 'H'},
- {0x48, 'T'},
- {0x49, 'j'},
- {0x49, 'j'},
- {0x4A, 'k'},
- {0x4B, 'l'},
- {0x4C, 'm'},
- {0x4D, 'n'},
- {0x4E, 's'},
- {0x4F, 'e'},
- {0x50, 'p'},
- {0x51, 'Z'},
- {0x52, 'q'},
- {0x53, 'r'},
- {0x54, 'S'},
- {0x55, 't'},
- {0x56, 'D'},
- {0x57, 'K'},
- {0x58, 'o'},
- {0x59, '\''},
- {0x5A, '*'},
- {0x5B, ':'},
- {0x5E, '.'}
-};
-
-
enum libcharconv_result
libcharconv_mandaic(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
- size_t i;
+ uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- for (i = 0u; i < sizeof(mandaic) / sizeof(*mandaic); i++)
- if (*s == mandaic[i].latin)
- goto conv;
- *n += 1u;
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("abgdhuzHTjklmnsepZqrStDKo'*:", 0x0840);
+ PLAIN_SINGLE('.', 0x085E);
+ PLAIN_SINGLE('w', 0x0845);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
@@ -59,7 +20,7 @@ conv:
goto no_conv;
*n += 1u;
if (*ncp)
- *cp = (uint_least32_t)(UINT32_C(0x0800) | mandaic[i].cp_low);
+ *cp = c;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
}
diff --git a/libcharconv_monospace.c b/libcharconv_monospace.c
index e1a9b01..ac714ee 100644
--- a/libcharconv_monospace.c
+++ b/libcharconv_monospace.c
@@ -7,19 +7,10 @@ libcharconv_monospace(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D670) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D68A) + (unsigned)(*s - 'a'));
- goto conv;
- } else if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x1D7F6) + (unsigned)(*s - '0'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D670);
+ PLAIN_RANGE('a', 'z', 0x1D68A);
+ PLAIN_RANGE('0', '9', 0x1D7F6);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_ocr.c b/libcharconv_ocr.c
index a849952..673ba2a 100644
--- a/libcharconv_ocr.c
+++ b/libcharconv_ocr.c
@@ -7,29 +7,10 @@ libcharconv_ocr(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case 's':
- case 'S': c = UINT32_C(0x2440); goto conv;
- case 'h':
- case 'd': c = UINT32_C(0x2441); goto conv;
- case 'Y': c = UINT32_C(0x2442); goto conv;
- case 'A': c = UINT32_C(0x2443); goto conv;
- case 'I': c = UINT32_C(0x2444); goto conv;
- case 'x':
- case 'X': c = UINT32_C(0x2445); goto conv;
- case '\\': c = UINT32_C(0x244A); goto conv;
- case 'c':
- case 'C': c = UINT32_C(0x2446); goto conv;
- case '/': c = UINT32_C(0x2447); goto conv;
- case 'p':
- case 'P': c = UINT32_C(0x2448); goto conv;
- case '_': c = UINT32_C(0x2449); goto conv;
- case 'E': c = UINT32_C(0x2BFF); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("SdYAIX\\C/P_", 0x2440);
+ PLAIN_SELECT("shYAIx\\c/p_", 0x2440);
+ PLAIN_SINGLE('E', 0x2BFF);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_region_indicators.c b/libcharconv_region_indicators.c
index 0c9ecb9..a3ed1b0 100644
--- a/libcharconv_region_indicators.c
+++ b/libcharconv_region_indicators.c
@@ -7,16 +7,8 @@ libcharconv_region_indicators(const char *s, size_t slen, size_t *n, uint_least3
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1F1E6) + (unsigned)(*s - 'a'));
- goto conv;
- } else if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1F1E6) + (unsigned)(*s - 'A'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_CASE_RANGE('A', 'Z', 0x1F1E6);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_rotated_45deg_ccw.c b/libcharconv_rotated_45deg_ccw.c
index 7144041..13fbfc8 100644
--- a/libcharconv_rotated_45deg_ccw.c
+++ b/libcharconv_rotated_45deg_ccw.c
@@ -1,78 +1,3 @@
/* See LICENSE file for copyright and license details. */
-#include "lib-common.h"
-
-
-static struct {
- uint_least32_t to;
- uint_least32_t from;
-} pairs[] = {
- {UINT32_C(0x1FA04), UINT32_C(0x1FA08)},
- {UINT32_C(0x1FA08), UINT32_C(0x1FA19)},
- {UINT32_C(0x1FA19), UINT32_C(0x1FA1D)},
- {UINT32_C(0x1FA1D), UINT32_C(0x1FA2E)},
- {UINT32_C(0x1FA2E), UINT32_C(0x1FA32)},
- {UINT32_C(0x1FA32), UINT32_C(0x1FA43)},
- {UINT32_C(0x1FA43), UINT32_C(0x1FA47)},
- {UINT32_C(0x1FA47), UINT32_C(0x1FA04)},
- {UINT32_C(0x2658), UINT32_C(0x1FA06)},
- {UINT32_C(0x1FA06), UINT32_C(0x1FA0D)},
- {UINT32_C(0x1FA0D), UINT32_C(0x1FA1B)},
- {UINT32_C(0x1FA1B), UINT32_C(0x1FA22)},
- {UINT32_C(0x1FA22), UINT32_C(0x1FA30)},
- {UINT32_C(0x1FA30), UINT32_C(0x1FA37)},
- {UINT32_C(0x1FA37), UINT32_C(0x1FA45)},
- {UINT32_C(0x1FA45), UINT32_C(0x2658)},
- {UINT32_C(0x265E), UINT32_C(0x1FA07)},
- {UINT32_C(0x1FA07), UINT32_C(0x1FA13)},
- {UINT32_C(0x1FA13), UINT32_C(0x1FA1C)},
- {UINT32_C(0x1FA1C), UINT32_C(0x1FA28)},
- {UINT32_C(0x1FA28), UINT32_C(0x1FA31)},
- {UINT32_C(0x1FA31), UINT32_C(0x1FA3D)},
- {UINT32_C(0x1FA3D), UINT32_C(0x1FA46)},
- {UINT32_C(0x1FA46), UINT32_C(0x265E)}
-};
-
-
-enum libcharconv_result
-libcharconv_rotated_45deg_ccw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
-{
- uint_least32_t c;
- size_t i, clen;
- *n = 0;
- while (slen) {
- clen = libcharconv_decode_utf8_(s, slen, &c);
- if (clen > slen) {
- if (*n)
- goto no_conv;
- return LIBCHARCONV_INDETERMINATE;
- }
- if (!clen) {
- *n += 1u;
- slen -= 1u;
- s = &s[1];
- continue;
- }
-
- for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
- if (c == pairs[i].from) {
- c = pairs[i].to;
- goto conv;
- }
- }
-
- *n += clen;
- s = &s[clen];
- slen -= clen;
- }
-no_conv:
- return LIBCHARCONV_NO_CONVERT;
-
-conv:
- if (*n)
- goto no_conv;
- if (*ncp)
- *cp = c;
- *n += clen;
- *ncp = 1u;
- return LIBCHARCONV_CONVERTED;
-}
+#define REVERSED
+#include "libcharconv_rotated_45deg_cw.c"
diff --git a/libcharconv_rotated_45deg_cw.c b/libcharconv_rotated_45deg_cw.c
index 06a4b51..2780781 100644
--- a/libcharconv_rotated_45deg_cw.c
+++ b/libcharconv_rotated_45deg_cw.c
@@ -3,38 +3,24 @@
static struct {
+#ifndef REVERSED
+# define FUNC_NAME libcharconv_rotated_45deg_cw
uint_least32_t from;
uint_least32_t to;
+#else
+# define FUNC_NAME libcharconv_rotated_45deg_ccw
+ uint_least32_t to;
+ uint_least32_t from;
+#endif
} pairs[] = {
- {UINT32_C(0x1FA04), UINT32_C(0x1FA08)},
- {UINT32_C(0x1FA08), UINT32_C(0x1FA19)},
- {UINT32_C(0x1FA19), UINT32_C(0x1FA1D)},
- {UINT32_C(0x1FA1D), UINT32_C(0x1FA2E)},
- {UINT32_C(0x1FA2E), UINT32_C(0x1FA32)},
- {UINT32_C(0x1FA32), UINT32_C(0x1FA43)},
- {UINT32_C(0x1FA43), UINT32_C(0x1FA47)},
- {UINT32_C(0x1FA47), UINT32_C(0x1FA04)},
- {UINT32_C(0x2658), UINT32_C(0x1FA06)},
- {UINT32_C(0x1FA06), UINT32_C(0x1FA0D)},
- {UINT32_C(0x1FA0D), UINT32_C(0x1FA1B)},
- {UINT32_C(0x1FA1B), UINT32_C(0x1FA22)},
- {UINT32_C(0x1FA22), UINT32_C(0x1FA30)},
- {UINT32_C(0x1FA30), UINT32_C(0x1FA37)},
- {UINT32_C(0x1FA37), UINT32_C(0x1FA45)},
- {UINT32_C(0x1FA45), UINT32_C(0x2658)},
- {UINT32_C(0x265E), UINT32_C(0x1FA07)},
- {UINT32_C(0x1FA07), UINT32_C(0x1FA13)},
- {UINT32_C(0x1FA13), UINT32_C(0x1FA1C)},
- {UINT32_C(0x1FA1C), UINT32_C(0x1FA28)},
- {UINT32_C(0x1FA28), UINT32_C(0x1FA31)},
- {UINT32_C(0x1FA31), UINT32_C(0x1FA3D)},
- {UINT32_C(0x1FA3D), UINT32_C(0x1FA46)},
- {UINT32_C(0x1FA46), UINT32_C(0x265E)}
+ CYCLE_8(0x1FA04, 0x1FA08, 0x1FA19, 0x1FA1D, 0x1FA2E, 0x1FA32, 0x1FA43, 0x1FA47),
+ CYCLE_8(0x02658, 0x1FA06, 0x1FA0D, 0x1FA1B, 0x1FA22, 0x1FA30, 0x1FA37, 0x1FA45),
+ CYCLE_8(0x0265E, 0x1FA07, 0x1FA13, 0x1FA1C, 0x1FA28, 0x1FA31, 0x1FA3D, 0x1FA46)
};
enum libcharconv_result
-libcharconv_rotated_45deg_cw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+FUNC_NAME(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
uint_least32_t c;
size_t i, clen;
diff --git a/libcharconv_rotated_90deg_ccw.c b/libcharconv_rotated_90deg_ccw.c
index 3d245bf..bd3baeb 100644
--- a/libcharconv_rotated_90deg_ccw.c
+++ b/libcharconv_rotated_90deg_ccw.c
@@ -1,149 +1,3 @@
/* See LICENSE file for copyright and license details. */
-#include "lib-common.h"
-
-
-static struct {
- uint_least32_t to;
- uint_least32_t from;
-} pairs[] = {
- {UINT32_C(0x230E), UINT32_C(0x230C)},
- {UINT32_C(0x230C), UINT32_C(0x230D)},
- {UINT32_C(0x230D), UINT32_C(0x230F)},
- {UINT32_C(0x230F), UINT32_C(0x230E)},
- {UINT32_C(0x1FA04), UINT32_C(0x1FA19)},
- {UINT32_C(0x1FA19), UINT32_C(0x1FA2E)},
- {UINT32_C(0x1FA2E), UINT32_C(0x1FA43)},
- {UINT32_C(0x1FA43), UINT32_C(0x1FA04)},
- {UINT32_C(0x02658), UINT32_C(0x1FA0D)},
- {UINT32_C(0x1FA0D), UINT32_C(0x1FA22)},
- {UINT32_C(0x1FA22), UINT32_C(0x1FA37)},
- {UINT32_C(0x1FA37), UINT32_C(0x02658)},
- {UINT32_C(0x0265E), UINT32_C(0x1FA13)},
- {UINT32_C(0x1FA13), UINT32_C(0x1FA28)},
- {UINT32_C(0x1FA28), UINT32_C(0x1FA3D)},
- {UINT32_C(0x1FA3D), UINT32_C(0x0265E)},
- {UINT32_C(0x1FA08), UINT32_C(0x1FA1D)},
- {UINT32_C(0x1FA1D), UINT32_C(0x1FA32)},
- {UINT32_C(0x1FA32), UINT32_C(0x1FA47)},
- {UINT32_C(0x1FA47), UINT32_C(0x1FA08)},
- {UINT32_C(0x1FA06), UINT32_C(0x1FA1B)},
- {UINT32_C(0x1FA1B), UINT32_C(0x1FA30)},
- {UINT32_C(0x1FA30), UINT32_C(0x1FA45)},
- {UINT32_C(0x1FA45), UINT32_C(0x1FA06)},
- {UINT32_C(0x1FA07), UINT32_C(0x1FA1C)},
- {UINT32_C(0x1FA1C), UINT32_C(0x1FA31)},
- {UINT32_C(0x1FA31), UINT32_C(0x1FA46)},
- {UINT32_C(0x1FA46), UINT32_C(0x1FA07)},
- {UINT32_C(0x1FA48), UINT32_C(0x1FA4B)},
- {UINT32_C(0x1FA49), UINT32_C(0x1FA4C)},
- {UINT32_C(0x1FA4A), UINT32_C(0x1FA4D)},
- {UINT32_C(0x1FA4B), UINT32_C(0x1FA48)},
- {UINT32_C(0x1FA4C), UINT32_C(0x1FA49)},
- {UINT32_C(0x1FA4D), UINT32_C(0x1FA4A)},
- {UINT32_C(0x1FA00), UINT32_C(0x1FA15)},
- {UINT32_C(0x1FA15), UINT32_C(0x1FA2A)},
- {UINT32_C(0x1FA2A), UINT32_C(0x1FA3F)},
- {UINT32_C(0x1FA3F), UINT32_C(0x1FA00)},
- {UINT32_C(0x1FA01), UINT32_C(0x1FA16)},
- {UINT32_C(0x1FA16), UINT32_C(0x1FA2B)},
- {UINT32_C(0x1FA2B), UINT32_C(0x1FA40)},
- {UINT32_C(0x1FA40), UINT32_C(0x1FA01)},
- {UINT32_C(0x1FA02), UINT32_C(0x1FA17)},
- {UINT32_C(0x1FA17), UINT32_C(0x1FA2C)},
- {UINT32_C(0x1FA2C), UINT32_C(0x1FA41)},
- {UINT32_C(0x1FA41), UINT32_C(0x1FA02)},
- {UINT32_C(0x1FA03), UINT32_C(0x1FA18)},
- {UINT32_C(0x1FA18), UINT32_C(0x1FA2D)},
- {UINT32_C(0x1FA2D), UINT32_C(0x1FA42)},
- {UINT32_C(0x1FA42), UINT32_C(0x1FA03)},
- {UINT32_C(0x1FA05), UINT32_C(0x1FA1A)},
- {UINT32_C(0x1FA1A), UINT32_C(0x1FA2F)},
- {UINT32_C(0x1FA2F), UINT32_C(0x1FA44)},
- {UINT32_C(0x1FA44), UINT32_C(0x1FA05)},
- {UINT32_C(0x2654), UINT32_C(0x1FA09)},
- {UINT32_C(0x1FA09), UINT32_C(0x1FA1E)},
- {UINT32_C(0x1FA1E), UINT32_C(0x1FA33)},
- {UINT32_C(0x1FA33), UINT32_C(0x2654)},
- {UINT32_C(0x2655), UINT32_C(0x1FA0A)},
- {UINT32_C(0x1FA0A), UINT32_C(0x1FA1F)},
- {UINT32_C(0x1FA1F), UINT32_C(0x1FA34)},
- {UINT32_C(0x1FA34), UINT32_C(0x2655)},
- {UINT32_C(0x2656), UINT32_C(0x1FA0B)},
- {UINT32_C(0x1FA0B), UINT32_C(0x1FA20)},
- {UINT32_C(0x1FA20), UINT32_C(0x1FA35)},
- {UINT32_C(0x1FA35), UINT32_C(0x2656)},
- {UINT32_C(0x2657), UINT32_C(0x1FA0C)},
- {UINT32_C(0x1FA0C), UINT32_C(0x1FA21)},
- {UINT32_C(0x1FA21), UINT32_C(0x1FA36)},
- {UINT32_C(0x1FA36), UINT32_C(0x2657)},
- {UINT32_C(0x2659), UINT32_C(0x1FA0E)},
- {UINT32_C(0x1FA0E), UINT32_C(0x1FA23)},
- {UINT32_C(0x1FA23), UINT32_C(0x1FA38)},
- {UINT32_C(0x1FA38), UINT32_C(0x2659)},
- {UINT32_C(0x265A), UINT32_C(0x1FA0F)},
- {UINT32_C(0x1FA0F), UINT32_C(0x1FA24)},
- {UINT32_C(0x1FA24), UINT32_C(0x1FA39)},
- {UINT32_C(0x1FA39), UINT32_C(0x265A)},
- {UINT32_C(0x265B), UINT32_C(0x1FA10)},
- {UINT32_C(0x1FA10), UINT32_C(0x1FA25)},
- {UINT32_C(0x1FA25), UINT32_C(0x1FA3A)},
- {UINT32_C(0x1FA3A), UINT32_C(0x265B)},
- {UINT32_C(0x265C), UINT32_C(0x1FA11)},
- {UINT32_C(0x1FA11), UINT32_C(0x1FA26)},
- {UINT32_C(0x1FA26), UINT32_C(0x1FA3B)},
- {UINT32_C(0x1FA3B), UINT32_C(0x265C)},
- {UINT32_C(0x265D), UINT32_C(0x1FA12)},
- {UINT32_C(0x1FA12), UINT32_C(0x1FA27)},
- {UINT32_C(0x1FA27), UINT32_C(0x1FA3C)},
- {UINT32_C(0x1FA3C), UINT32_C(0x265D)},
- {UINT32_C(0x265F), UINT32_C(0x1FA14)},
- {UINT32_C(0x1FA14), UINT32_C(0x1FA29)},
- {UINT32_C(0x1FA29), UINT32_C(0x1FA3E)},
- {UINT32_C(0x1FA3E), UINT32_C(0x265F)},
- {UINT32_C(0x213A), (uint_least32_t)'Q'}
-};
-
-
-enum libcharconv_result
-libcharconv_rotated_90deg_ccw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
-{
- uint_least32_t c;
- size_t i, clen;
- *n = 0;
- while (slen) {
- clen = libcharconv_decode_utf8_(s, slen, &c);
- if (clen > slen) {
- if (*n)
- goto no_conv;
- return LIBCHARCONV_INDETERMINATE;
- }
- if (!clen) {
- *n += 1u;
- slen -= 1u;
- s = &s[1];
- continue;
- }
-
- for (i = 0u; i < sizeof(pairs) / sizeof(*pairs); i++) {
- if (c == pairs[i].from) {
- c = pairs[i].to;
- goto conv;
- }
- }
-
- *n += clen;
- s = &s[clen];
- slen -= clen;
- }
-no_conv:
- return LIBCHARCONV_NO_CONVERT;
-
-conv:
- if (*n)
- goto no_conv;
- if (*ncp)
- *cp = c;
- *n += clen;
- *ncp = 1u;
- return LIBCHARCONV_CONVERTED;
-}
+#define REVERSED
+#include "libcharconv_rotated_90deg_cw.c"
diff --git a/libcharconv_rotated_90deg_cw.c b/libcharconv_rotated_90deg_cw.c
index c22b44f..7b23dba 100644
--- a/libcharconv_rotated_90deg_cw.c
+++ b/libcharconv_rotated_90deg_cw.c
@@ -3,109 +3,47 @@
static struct {
+#ifndef REVERSED
+# define FUNC_NAME libcharconv_rotated_90deg_cw
uint_least32_t from;
uint_least32_t to;
+#else
+# define FUNC_NAME libcharconv_rotated_90deg_ccw
+ uint_least32_t to;
+ uint_least32_t from;
+#endif
} pairs[] = {
- {UINT32_C(0x230E), UINT32_C(0x230C)},
- {UINT32_C(0x230C), UINT32_C(0x230D)},
- {UINT32_C(0x230D), UINT32_C(0x230F)},
- {UINT32_C(0x230F), UINT32_C(0x230E)},
- {UINT32_C(0x1FA04), UINT32_C(0x1FA19)},
- {UINT32_C(0x1FA19), UINT32_C(0x1FA2E)},
- {UINT32_C(0x1FA2E), UINT32_C(0x1FA43)},
- {UINT32_C(0x1FA43), UINT32_C(0x1FA04)},
- {UINT32_C(0x02658), UINT32_C(0x1FA0D)},
- {UINT32_C(0x1FA0D), UINT32_C(0x1FA22)},
- {UINT32_C(0x1FA22), UINT32_C(0x1FA37)},
- {UINT32_C(0x1FA37), UINT32_C(0x02658)},
- {UINT32_C(0x0265E), UINT32_C(0x1FA13)},
- {UINT32_C(0x1FA13), UINT32_C(0x1FA28)},
- {UINT32_C(0x1FA28), UINT32_C(0x1FA3D)},
- {UINT32_C(0x1FA3D), UINT32_C(0x0265E)},
- {UINT32_C(0x1FA08), UINT32_C(0x1FA1D)},
- {UINT32_C(0x1FA1D), UINT32_C(0x1FA32)},
- {UINT32_C(0x1FA32), UINT32_C(0x1FA47)},
- {UINT32_C(0x1FA47), UINT32_C(0x1FA08)},
- {UINT32_C(0x1FA06), UINT32_C(0x1FA1B)},
- {UINT32_C(0x1FA1B), UINT32_C(0x1FA30)},
- {UINT32_C(0x1FA30), UINT32_C(0x1FA45)},
- {UINT32_C(0x1FA45), UINT32_C(0x1FA06)},
- {UINT32_C(0x1FA07), UINT32_C(0x1FA1C)},
- {UINT32_C(0x1FA1C), UINT32_C(0x1FA31)},
- {UINT32_C(0x1FA31), UINT32_C(0x1FA46)},
- {UINT32_C(0x1FA46), UINT32_C(0x1FA07)},
- {UINT32_C(0x1FA48), UINT32_C(0x1FA4B)},
- {UINT32_C(0x1FA49), UINT32_C(0x1FA4C)},
- {UINT32_C(0x1FA4A), UINT32_C(0x1FA4D)},
- {UINT32_C(0x1FA4B), UINT32_C(0x1FA48)},
- {UINT32_C(0x1FA4C), UINT32_C(0x1FA49)},
- {UINT32_C(0x1FA4D), UINT32_C(0x1FA4A)},
- {UINT32_C(0x1FA00), UINT32_C(0x1FA15)},
- {UINT32_C(0x1FA15), UINT32_C(0x1FA2A)},
- {UINT32_C(0x1FA2A), UINT32_C(0x1FA3F)},
- {UINT32_C(0x1FA3F), UINT32_C(0x1FA00)},
- {UINT32_C(0x1FA01), UINT32_C(0x1FA16)},
- {UINT32_C(0x1FA16), UINT32_C(0x1FA2B)},
- {UINT32_C(0x1FA2B), UINT32_C(0x1FA40)},
- {UINT32_C(0x1FA40), UINT32_C(0x1FA01)},
- {UINT32_C(0x1FA02), UINT32_C(0x1FA17)},
- {UINT32_C(0x1FA17), UINT32_C(0x1FA2C)},
- {UINT32_C(0x1FA2C), UINT32_C(0x1FA41)},
- {UINT32_C(0x1FA41), UINT32_C(0x1FA02)},
- {UINT32_C(0x1FA03), UINT32_C(0x1FA18)},
- {UINT32_C(0x1FA18), UINT32_C(0x1FA2D)},
- {UINT32_C(0x1FA2D), UINT32_C(0x1FA42)},
- {UINT32_C(0x1FA42), UINT32_C(0x1FA03)},
- {UINT32_C(0x1FA05), UINT32_C(0x1FA1A)},
- {UINT32_C(0x1FA1A), UINT32_C(0x1FA2F)},
- {UINT32_C(0x1FA2F), UINT32_C(0x1FA44)},
- {UINT32_C(0x1FA44), UINT32_C(0x1FA05)},
- {UINT32_C(0x2654), UINT32_C(0x1FA09)},
- {UINT32_C(0x1FA09), UINT32_C(0x1FA1E)},
- {UINT32_C(0x1FA1E), UINT32_C(0x1FA33)},
- {UINT32_C(0x1FA33), UINT32_C(0x2654)},
- {UINT32_C(0x2655), UINT32_C(0x1FA0A)},
- {UINT32_C(0x1FA0A), UINT32_C(0x1FA1F)},
- {UINT32_C(0x1FA1F), UINT32_C(0x1FA34)},
- {UINT32_C(0x1FA34), UINT32_C(0x2655)},
- {UINT32_C(0x2656), UINT32_C(0x1FA0B)},
- {UINT32_C(0x1FA0B), UINT32_C(0x1FA20)},
- {UINT32_C(0x1FA20), UINT32_C(0x1FA35)},
- {UINT32_C(0x1FA35), UINT32_C(0x2656)},
- {UINT32_C(0x2657), UINT32_C(0x1FA0C)},
- {UINT32_C(0x1FA0C), UINT32_C(0x1FA21)},
- {UINT32_C(0x1FA21), UINT32_C(0x1FA36)},
- {UINT32_C(0x1FA36), UINT32_C(0x2657)},
- {UINT32_C(0x2659), UINT32_C(0x1FA0E)},
- {UINT32_C(0x1FA0E), UINT32_C(0x1FA23)},
- {UINT32_C(0x1FA23), UINT32_C(0x1FA38)},
- {UINT32_C(0x1FA38), UINT32_C(0x2659)},
- {UINT32_C(0x265A), UINT32_C(0x1FA0F)},
- {UINT32_C(0x1FA0F), UINT32_C(0x1FA24)},
- {UINT32_C(0x1FA24), UINT32_C(0x1FA39)},
- {UINT32_C(0x1FA39), UINT32_C(0x265A)},
- {UINT32_C(0x265B), UINT32_C(0x1FA10)},
- {UINT32_C(0x1FA10), UINT32_C(0x1FA25)},
- {UINT32_C(0x1FA25), UINT32_C(0x1FA3A)},
- {UINT32_C(0x1FA3A), UINT32_C(0x265B)},
- {UINT32_C(0x265C), UINT32_C(0x1FA11)},
- {UINT32_C(0x1FA11), UINT32_C(0x1FA26)},
- {UINT32_C(0x1FA26), UINT32_C(0x1FA3B)},
- {UINT32_C(0x1FA3B), UINT32_C(0x265C)},
- {UINT32_C(0x265D), UINT32_C(0x1FA12)},
- {UINT32_C(0x1FA12), UINT32_C(0x1FA27)},
- {UINT32_C(0x1FA27), UINT32_C(0x1FA3C)},
- {UINT32_C(0x1FA3C), UINT32_C(0x265D)},
- {UINT32_C(0x265F), UINT32_C(0x1FA14)},
- {UINT32_C(0x1FA14), UINT32_C(0x1FA29)},
- {UINT32_C(0x1FA29), UINT32_C(0x1FA3E)},
- {UINT32_C(0x1FA3E), UINT32_C(0x265F)},
+ CYCLE_4(0x230E, 0x230C, 0x230D, 0x230F),
+ CYCLE_4(0x1FA04, 0x1FA19, 0x1FA2E, 0x1FA43),
+ CYCLE_4(0x02658, 0x1FA0D, 0x1FA22, 0x1FA37),
+ CYCLE_4(0x0265E, 0x1FA13, 0x1FA28, 0x1FA3D),
+ CYCLE_4(0x1FA08, 0x1FA1D, 0x1FA32, 0x1FA47),
+ CYCLE_4(0x1FA06, 0x1FA1B, 0x1FA30, 0x1FA45),
+ CYCLE_4(0x1FA07, 0x1FA1C, 0x1FA31, 0x1FA46),
+ CYCLE_2(0x1FA48, 0x1FA4B),
+ CYCLE_2(0x1FA49, 0x1FA4C),
+ CYCLE_2(0x1FA4A, 0x1FA4D),
+ CYCLE_4(0x1FA00, 0x1FA15, 0x1FA2A, 0x1FA3F),
+ CYCLE_4(0x1FA01, 0x1FA16, 0x1FA2B, 0x1FA40),
+ CYCLE_4(0x1FA02, 0x1FA17, 0x1FA2C, 0x1FA41),
+ CYCLE_4(0x1FA03, 0x1FA18, 0x1FA2D, 0x1FA42),
+ CYCLE_4(0x1FA05, 0x1FA1A, 0x1FA2F, 0x1FA44),
+ CYCLE_4(0x2654, 0x1FA09, 0x1FA1E, 0x1FA33),
+ CYCLE_4(0x2655, 0x1FA0A, 0x1FA1F, 0x1FA34),
+ CYCLE_4(0x2656, 0x1FA0B, 0x1FA20, 0x1FA35),
+ CYCLE_4(0x2657, 0x1FA0C, 0x1FA21, 0x1FA36),
+ CYCLE_4(0x2659, 0x1FA0E, 0x1FA23, 0x1FA38),
+ CYCLE_4(0x265A, 0x1FA0F, 0x1FA24, 0x1FA39),
+ CYCLE_4(0x265B, 0x1FA10, 0x1FA25, 0x1FA3A),
+ CYCLE_4(0x265C, 0x1FA11, 0x1FA26, 0x1FA3B),
+ CYCLE_4(0x265D, 0x1FA12, 0x1FA27, 0x1FA3C),
+ CYCLE_4(0x265F, 0x1FA14, 0x1FA29, 0x1FA3E),
{UINT32_C(0x213A), (uint_least32_t)'Q'}
};
enum libcharconv_result
-libcharconv_rotated_90deg_cw(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+FUNC_NAME(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
uint_least32_t c;
size_t i, clen;
diff --git a/libcharconv_sans_serif.c b/libcharconv_sans_serif.c
index 787d14b..4edf373 100644
--- a/libcharconv_sans_serif.c
+++ b/libcharconv_sans_serif.c
@@ -10,16 +10,10 @@ libcharconv_sans_serif(const char *s, size_t slen, size_t *n, uint_least32_t *cp
*n = 0;
for (; slen--; s++) {
old_slen = slen;
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D5A0) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D5BA) + (unsigned)(*s - 'a'));
- goto conv;
- } else if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x1D7E2) + (unsigned)(*s - '0'));
- goto conv;
- } else if ((unsigned char)s[0] == 0xE2u) {
+ PLAIN_RANGE('A', 'Z', 0x1D5A0);
+ PLAIN_RANGE('a', 'z', 0x1D5BA);
+ PLAIN_RANGE('0', '9', 0x1D7E2);
+ if ((unsigned char)s[0] == 0xE2u) {
if (!slen--)
goto indeterminate;
if ((unsigned char)s[1] == 0x93u) {
diff --git a/libcharconv_sans_serif_bold.c b/libcharconv_sans_serif_bold.c
index 4d0df44..826af75 100644
--- a/libcharconv_sans_serif_bold.c
+++ b/libcharconv_sans_serif_bold.c
@@ -7,19 +7,10 @@ libcharconv_sans_serif_bold(const char *s, size_t slen, size_t *n, uint_least32_
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D5D4) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D5EE) + (unsigned)(*s - 'a'));
- goto conv;
- } else if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x1D7EC) + (unsigned)(*s - '0'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D5D4);
+ PLAIN_RANGE('a', 'z', 0x1D5EE);
+ PLAIN_RANGE('0', '9', 0x1D7EC);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_sans_serif_bold_italic.c b/libcharconv_sans_serif_bold_italic.c
index f9b77f1..0dbb41a 100644
--- a/libcharconv_sans_serif_bold_italic.c
+++ b/libcharconv_sans_serif_bold_italic.c
@@ -7,16 +7,9 @@ libcharconv_sans_serif_bold_italic(const char *s, size_t slen, size_t *n, uint_l
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D63C) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D656) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D63C);
+ PLAIN_RANGE('a', 'z', 0x1D656);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_sans_serif_italic.c b/libcharconv_sans_serif_italic.c
index c0d8ff9..2da6206 100644
--- a/libcharconv_sans_serif_italic.c
+++ b/libcharconv_sans_serif_italic.c
@@ -7,16 +7,9 @@ libcharconv_sans_serif_italic(const char *s, size_t slen, size_t *n, uint_least3
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D608) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D622) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('A', 'Z', 0x1D608);
+ PLAIN_RANGE('a', 'z', 0x1D622);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_script.c b/libcharconv_script.c
index 2617c58..5149aad 100644
--- a/libcharconv_script.c
+++ b/libcharconv_script.c
@@ -7,49 +7,20 @@ libcharconv_script(const char *s, size_t slen, size_t *n, uint_least32_t *cp, si
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if (*s == 'B') {
- c = (uint_least32_t)UINT32_C(0x212C);
- goto conv;
- } else if (*s == 'E') {
- c = (uint_least32_t)UINT32_C(0x2130);
- goto conv;
- } else if (*s == 'F') {
- c = (uint_least32_t)UINT32_C(0x2131);
- goto conv;
- } else if (*s == 'H') {
- c = (uint_least32_t)UINT32_C(0x210B);
- goto conv;
- } else if (*s == 'I') {
- c = (uint_least32_t)UINT32_C(0x2110);
- goto conv;
- } else if (*s == 'L') {
- c = (uint_least32_t)UINT32_C(0x2112);
- goto conv;
- } else if (*s == 'M') {
- c = (uint_least32_t)UINT32_C(0x2133);
- goto conv;
- } else if (*s == 'R') {
- c = (uint_least32_t)UINT32_C(0x211B);
- goto conv;
- } else if (*s == 'e') {
- c = (uint_least32_t)UINT32_C(0x212F);
- goto conv;
- } else if (*s == 'g') {
- c = (uint_least32_t)UINT32_C(0x210A);
- goto conv;
- } else if (*s == 'o') {
- c = (uint_least32_t)UINT32_C(0x2134);
- goto conv;
- } else if ('A' <= *s && *s <= 'Z') {
- c = (uint_least32_t)(UINT32_C(0x1D49C) + (unsigned)(*s - 'A'));
- goto conv;
- } else if ('a' <= *s && *s <= 'z') {
- c = (uint_least32_t)(UINT32_C(0x1D4B6) + (unsigned)(*s - 'a'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('B', 0x212C);
+ PLAIN_SINGLE('E', 0x2130);
+ PLAIN_SINGLE('F', 0x2131);
+ PLAIN_SINGLE('H', 0x210B);
+ PLAIN_SINGLE('I', 0x2110);
+ PLAIN_SINGLE('L', 0x2112);
+ PLAIN_SINGLE('M', 0x2133);
+ PLAIN_SINGLE('R', 0x211B);
+ PLAIN_SINGLE('e', 0x212F);
+ PLAIN_SINGLE('g', 0x210A);
+ PLAIN_SINGLE('o', 0x2134);
+ PLAIN_RANGE('A', 'Z', 0x1D49C);
+ PLAIN_RANGE('a', 'z', 0x1D4B6);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_segmented.c b/libcharconv_segmented.c
index 87bf1c1..4508585 100644
--- a/libcharconv_segmented.c
+++ b/libcharconv_segmented.c
@@ -7,13 +7,8 @@ libcharconv_segmented(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x1FBF0) + (unsigned)(*s - '0'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('0', '9', 0x1FBF0);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_shogi.c b/libcharconv_shogi.c
index d12f158..66604c5 100644
--- a/libcharconv_shogi.c
+++ b/libcharconv_shogi.c
@@ -7,16 +7,11 @@ libcharconv_shogi(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case 'w': c = UINT32_C(0x2616); goto conv;
- case 'b': c = UINT32_C(0x2617); goto conv;
- case 'W': c = UINT32_C(0x26C9); goto conv;
- case 'B': c = UINT32_C(0x26CA); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('w', 0x2616);
+ PLAIN_SINGLE('b', 0x2617);
+ PLAIN_SINGLE('W', 0x2619);
+ PLAIN_SINGLE('B', 0x261A);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_sora_sompeng.c b/libcharconv_sora_sompeng.c
index 6ced61d..984d303 100644
--- a/libcharconv_sora_sompeng.c
+++ b/libcharconv_sora_sompeng.c
@@ -2,58 +2,14 @@
#include "lib-common.h"
-static struct {
- unsigned char cp_low;
- char latin;
-} sora_sompeng[] = {
- {0xE2, 'a'},
- {0xD2, 'b'},
- {0xD3, 'c'},
- {0xD4, 'd'},
- {0xE7, 'e'},
- {0xE3, 'E'},
- {0xD5, 'g'},
- {0xD7, 'G'},
- {0xDE, 'h'},
- {0xE4, 'i'},
- {0xE0, 'j'},
- {0xDF, 'k'},
- {0xD8, 'l'},
- {0xD9, 'n'},
- {0xD6, 'm'},
- {0xE8, 'M'},
- {0xE6, 'o'},
- {0xDB, 'p'},
- {0xDD, 'r'},
- {0xD0, 's'},
- {0xD1, 't'},
- {0xE5, 'u'},
- {0xDA, 'v'},
- {0xDC, 'y'},
- {0xE1, 'Y'},
- {0xF0, '0'},
- {0xF1, '1'},
- {0xF2, '2'},
- {0xF3, '3'},
- {0xF4, '4'},
- {0xF5, '5'},
- {0xF6, '6'},
- {0xF7, '7'},
- {0xF8, '8'},
- {0xF9, '9'}
-};
-
-
enum libcharconv_result
libcharconv_sora_sompeng(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
- size_t i;
+ uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- for (i = 0u; i < sizeof(sora_sompeng) / sizeof(*sora_sompeng); i++)
- if (*s == sora_sompeng[i].latin)
- goto conv;
- *n += 1u;
+ for (; slen--; s++, ++*n) {
+ PLAIN_SELECT("stbcdgmGlnvpyrhkjYaEiuoeM", 0x110D0);
+ PLAIN_RANGE('0', '9', 0x110F0);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
@@ -62,7 +18,7 @@ conv:
if (*n)
goto no_conv;
if (*ncp)
- *cp = (uint_least32_t)(UINT32_C(0x11000) | sora_sompeng[i].cp_low);
+ *cp = c;
*n += 1u;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
diff --git a/libcharconv_subscript.c b/libcharconv_subscript.c
index 35a3a72..4b94a7a 100644
--- a/libcharconv_subscript.c
+++ b/libcharconv_subscript.c
@@ -7,13 +7,8 @@ libcharconv_subscript(const char *s, size_t slen, size_t *n, uint_least32_t *cp,
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x2080) + (unsigned)(*s - '0'));
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('0', '9', 0x2080);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_superscript.c b/libcharconv_superscript.c
index d15f490..9f83164 100644
--- a/libcharconv_superscript.c
+++ b/libcharconv_superscript.c
@@ -7,18 +7,10 @@ libcharconv_superscript(const char *s, size_t slen, size_t *n, uint_least32_t *c
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if (*s == '1') {
- c = (uint_least32_t)UINT32_C(0x00B9);
- } else if ('2' <= *s && *s <= '3') {
- c = (uint_least32_t)(UINT32_C(0x00B2) + (unsigned)(*s - '2'));
- } else if ('0' <= *s && *s <= '9') {
- c = (uint_least32_t)(UINT32_C(0x2070) + (unsigned)(*s - '0'));
- } else {
- *n += 1u;
- continue;
- }
- goto conv;
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('1', 0x00B9);
+ PLAIN_RANGE('2', '3', 0x00B2);
+ PLAIN_RANGE('0', '9', 0x2070);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_tags.c b/libcharconv_tags.c
index 326a83e..d069c76 100644
--- a/libcharconv_tags.c
+++ b/libcharconv_tags.c
@@ -7,13 +7,8 @@ libcharconv_tags(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- if ('\x20' <= *s && *s <= '\x7E') {
- c = (uint_least32_t)(UINT32_C(0xE0000) + (unsigned)*s);
- goto conv;
- } else {
- *n += 1u;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_RANGE('\x20', '\x7E', 0xE0020);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_tally_marks.c b/libcharconv_tally_marks.c
index e94f48d..c8156e9 100644
--- a/libcharconv_tally_marks.c
+++ b/libcharconv_tally_marks.c
@@ -7,14 +7,9 @@ libcharconv_tally_marks(const char *s, size_t slen, size_t *n, uint_least32_t *c
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case '1': c = UINT32_C(0x13D77); goto conv;
- case '5': c = UINT32_C(0x13D78); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('1', 0x13D77);
+ PLAIN_SINGLE('5', 0x13D78);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
diff --git a/libcharconv_transposed.c b/libcharconv_transposed.c
index af2a835..e73dcbc 100644
--- a/libcharconv_transposed.c
+++ b/libcharconv_transposed.c
@@ -22,13 +22,7 @@ libcharconv_transposed(const char *s, size_t slen, size_t *n, uint_least32_t *cp
continue;
}
- if (UINT32_C(0x1F030) <= c && c <= UINT32_C(0x1F061)) {
- c += 0x32u;
- goto conv;
- } else if (UINT32_C(0x1F062) <= c && c <= UINT32_C(0x1F093)) {
- c -= 0x32u;
- goto conv;
- }
+ PLAIN_RANGE_SWAP(0x1F030, 0x1F061, 0x1F062, 0x1F093);
*n += clen;
s = &s[clen];
diff --git a/libcharconv_turned.c b/libcharconv_turned.c
index ff51618..2ad33f0 100644
--- a/libcharconv_turned.c
+++ b/libcharconv_turned.c
@@ -2,18 +2,6 @@
#include "lib-common.h"
-static unsigned char yijing_hexagrams[] = {
- 0xC0, 0xEB, 0xCC, 0xE0, 0xC9, 0xC5, 0xD8, 0xCB,
- 0xC8, 0xF8, 0xE4, 0xF4, 0xFC, 0xFA, 0xE9, 0xD3,
- 0xCD, 0xF1, 0xDD, 0xF7, 0xE5, 0xFF, 0xD4, 0xE2,
- 0xD9, 0xD1, 0xD5, 0xF3, 0xE8, 0xC3, 0xDA, 0xD6,
- 0xEA, 0xDB, 0xF0, 0xDE, 0xF9, 0xEE, 0xD0, 0xEC,
- 0xC4, 0xEF, 0xFE, 0xE6, 0xFB, 0xDC, 0xC2, 0xC7,
- 0xE1, 0xDF, 0xF6, 0xFD, 0xF5, 0xE7, 0xF2, 0xCF,
- 0xCA, 0xED, 0xE3, 0xCE, 0xD2, 0xC6, 0xD7, 0xC1
-};
-
-
static struct {
uint_least32_t a;
uint_least32_t b;
@@ -81,19 +69,9 @@ libcharconv_turned(const char *s, size_t slen, size_t *n, uint_least32_t *cp, si
continue;
}
- if (UINT32_C(0x1FA00) <= c && c <= UINT32_C(0x1FA1D)) {
- c += 0x2Au;
- goto conv;
- } else if (UINT32_C(0x1FA2A) <= c && c <= UINT32_C(0x1FA47)) {
- c -= 0x2Au;
- goto conv;
- } else if (UINT32_C(0x1FA1E) <= c && c <= UINT32_C(0x1FA29)) {
- c -= UINT32_C(0x1FA1E) - UINT32_C(0x2654);
- goto conv;
- } else if (UINT32_C(0x2654) <= c && c <= UINT32_C(0x265F)) {
- c += UINT32_C(0x1FA1E) - UINT32_C(0x2654);
- goto conv;
- } else if (UINT32_C(0x1F031) <= c && c <= UINT32_C(0x1F061)) {
+ PLAIN_RANGE_SWAP(0x1FA00, 0x1FA1D, 0x1FA2A, 0x1FA47);
+ PLAIN_RANGE_SWAP(0x1FA1E, 0x1FA29, 0x2654, 0x265F);
+ if (UINT32_C(0x1F031) <= c && c <= UINT32_C(0x1F061)) {
c -= UINT32_C(0x1F031);
c = c % 7u * 7u + c / 7u;
c += UINT32_C(0x1F031);
@@ -120,7 +98,7 @@ libcharconv_turned(const char *s, size_t slen, size_t *n, uint_least32_t *cp, si
goto conv;
} else if (UINT32_C(0x4DC0) <= c && c <= UINT32_C(0x4DFF)) {
for (i = 0u;; i++)
- if ((c & 0xFFu) == yijing_hexagrams[i])
+ if ((c & 0xFFu) == libcharconv_yijing_hexagrams_[i])
break;
c = (i & 32u) ? 1u : 0u;
c |= (i & 16u) ? 2u : 0u;
@@ -128,7 +106,7 @@ libcharconv_turned(const char *s, size_t slen, size_t *n, uint_least32_t *cp, si
c |= (i & 4u) ? 8u : 0u;
c |= (i & 2u) ? 16u : 0u;
c |= (i & 1u) ? 32u : 0u;
- c = UINT32_C(0x4D00) | yijing_hexagrams[c];
+ c = UINT32_C(0x4D00) | libcharconv_yijing_hexagrams_[c];
goto conv;
} else if (UINT32_C(0x2800) <= c && c <= UINT32_C(0x28FF)) {
c = ((c & 0x01u) << 7) | ((c & 0x80u) >> 7)
diff --git a/libcharconv_vulgar_fractions.c b/libcharconv_vulgar_fractions.c
index a89a02f..285c10d 100644
--- a/libcharconv_vulgar_fractions.c
+++ b/libcharconv_vulgar_fractions.c
@@ -33,42 +33,24 @@ libcharconv_vulgar_fractions(const char *s, size_t slen, size_t *n, uint_least32
return LIBCHARCONV_INDETERMINATE;
}
}
- if (s[0] == '0' && s[2] == '3') {
- c = UINT32_C(0x2189);
- } else if (s[0] == '2' && s[2] == '3') {
- c = UINT32_C(0x2154);
- } else if (s[0] == '2' && s[2] == '5') {
- c = UINT32_C(0x2156);
- } else if (s[0] == '3' && s[2] == '4') {
- c = UINT32_C(0x00BE);
- } else if (s[0] == '3' && s[2] == '5') {
- c = UINT32_C(0x2157);
- } else if (s[0] == '3' && s[2] == '8') {
- c = UINT32_C(0x215C);
- } else if (s[0] == '4' && s[2] == '5') {
- c = UINT32_C(0x2158);
- } else if (s[0] == '5' && s[2] == '6') {
- c = UINT32_C(0x215A);
- } else if (s[0] == '5' && s[2] == '8') {
- c = UINT32_C(0x215D);
- } else if (s[0] == '7' && s[2] == '8') {
- c = UINT32_C(0x215E);
- } else if (s[0] == '1' && s[2] == '2') {
- c = UINT32_C(0x00BD);
- } else if (s[0] == '1' && s[2] == '3') {
- c = UINT32_C(0x2153);
- } else if (s[0] == '1' && s[2] == '4') {
- c = UINT32_C(0x00BC);
- } else if (s[0] == '1' && s[2] == '5') {
- c = UINT32_C(0x2155);
- } else if (s[0] == '1' && s[2] == '6') {
- c = UINT32_C(0x2159);
- } else if (s[0] == '1' && s[2] == '7') {
- c = UINT32_C(0x2150);
- } else if (s[0] == '1' && s[2] == '8') {
- c = UINT32_C(0x215B);
- } else if (s[0] == '1' && s[2] == '9') {
- c = UINT32_C(0x2151);
+ if (s[0] == '0' && s[2] == '3') { c = UINT32_C(0x2189);
+ } else if (s[0] == '2' && s[2] == '3') { c = UINT32_C(0x2154);
+ } else if (s[0] == '2' && s[2] == '5') { c = UINT32_C(0x2156);
+ } else if (s[0] == '3' && s[2] == '4') { c = UINT32_C(0x00BE);
+ } else if (s[0] == '3' && s[2] == '5') { c = UINT32_C(0x2157);
+ } else if (s[0] == '3' && s[2] == '8') { c = UINT32_C(0x215C);
+ } else if (s[0] == '4' && s[2] == '5') { c = UINT32_C(0x2158);
+ } else if (s[0] == '5' && s[2] == '6') { c = UINT32_C(0x215A);
+ } else if (s[0] == '5' && s[2] == '8') { c = UINT32_C(0x215D);
+ } else if (s[0] == '7' && s[2] == '8') { c = UINT32_C(0x215E);
+ } else if (s[0] == '1' && s[2] == '2') { c = UINT32_C(0x00BD);
+ } else if (s[0] == '1' && s[2] == '3') { c = UINT32_C(0x2153);
+ } else if (s[0] == '1' && s[2] == '4') { c = UINT32_C(0x00BC);
+ } else if (s[0] == '1' && s[2] == '5') { c = UINT32_C(0x2155);
+ } else if (s[0] == '1' && s[2] == '6') { c = UINT32_C(0x2159);
+ } else if (s[0] == '1' && s[2] == '7') { c = UINT32_C(0x2150);
+ } else if (s[0] == '1' && s[2] == '8') { c = UINT32_C(0x215B);
+ } else if (s[0] == '1' && s[2] == '9') { c = UINT32_C(0x2151);
} else if (s[0] == '1' && s[2] == '1') {
if (slen == 2u)
return LIBCHARCONV_INDETERMINATE;
diff --git a/libcharconv_yijing_digrams.c b/libcharconv_yijing_digrams.c
index 91bc36f..ff0b4c4 100644
--- a/libcharconv_yijing_digrams.c
+++ b/libcharconv_yijing_digrams.c
@@ -11,24 +11,15 @@ libcharconv_yijing_digrams(const char *s, size_t slen, size_t *n, uint_least32_t
if ('1' <= s[0] && s[0] <= '3') {
if (!slen)
return LIBCHARCONV_INDETERMINATE;
- if (s[0] == '1' && s[1] == '1')
- c = UINT32_C(0x268C);
- else if (s[0] == '1' && s[1] == '2')
- c = UINT32_C(0x268E);
- else if (s[0] == '1' && s[1] == '3')
- c = UINT32_C(0x1D301);
- else if (s[0] == '2' && s[1] == '1')
- c = UINT32_C(0x268D);
- else if (s[0] == '2' && s[1] == '2')
- c = UINT32_C(0x268F);
- else if (s[0] == '2' && s[1] == '3')
- c = UINT32_C(0x1D302);
- else if (s[0] == '3' && s[1] == '1')
- c = UINT32_C(0x1D303);
- else if (s[0] == '3' && s[1] == '2')
- c = UINT32_C(0x1D304);
- else if (s[0] == '3' && s[1] == '3')
- c = UINT32_C(0x1D305);
+ if (s[0] == '1' && s[1] == '1') c = UINT32_C(0x268C);
+ else if (s[0] == '1' && s[1] == '2') c = UINT32_C(0x268E);
+ else if (s[0] == '1' && s[1] == '3') c = UINT32_C(0x1D301);
+ else if (s[0] == '2' && s[1] == '1') c = UINT32_C(0x268D);
+ else if (s[0] == '2' && s[1] == '2') c = UINT32_C(0x268F);
+ else if (s[0] == '2' && s[1] == '3') c = UINT32_C(0x1D302);
+ else if (s[0] == '3' && s[1] == '1') c = UINT32_C(0x1D303);
+ else if (s[0] == '3' && s[1] == '2') c = UINT32_C(0x1D304);
+ else if (s[0] == '3' && s[1] == '3') c = UINT32_C(0x1D305);
else
goto no_match;
goto conv;
diff --git a/libcharconv_yijing_hexagrams.c b/libcharconv_yijing_hexagrams.c
index b271e1f..0b3fe41 100644
--- a/libcharconv_yijing_hexagrams.c
+++ b/libcharconv_yijing_hexagrams.c
@@ -2,18 +2,6 @@
#include "lib-common.h"
-static unsigned char yijing_hexagrams[] = {
- 0xC0, 0xEB, 0xCC, 0xE0, 0xC9, 0xC5, 0xD8, 0xCB,
- 0xC8, 0xF8, 0xE4, 0xF4, 0xFC, 0xFA, 0xE9, 0xD3,
- 0xCD, 0xF1, 0xDD, 0xF7, 0xE5, 0xFF, 0xD4, 0xE2,
- 0xD9, 0xD1, 0xD5, 0xF3, 0xE8, 0xC3, 0xDA, 0xD6,
- 0xEA, 0xDB, 0xF0, 0xDE, 0xF9, 0xEE, 0xD0, 0xEC,
- 0xC4, 0xEF, 0xFE, 0xE6, 0xFB, 0xDC, 0xC2, 0xC7,
- 0xE1, 0xDF, 0xF6, 0xFD, 0xF5, 0xE7, 0xF2, 0xCF,
- 0xCA, 0xED, 0xE3, 0xCE, 0xD2, 0xC6, 0xD7, 0xC1
-};
-
-
enum libcharconv_result
libcharconv_yijing_hexagrams(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
@@ -48,7 +36,7 @@ libcharconv_yijing_hexagrams(const char *s, size_t slen, size_t *n, uint_least32
i |= s[2] == '2' ? 8u : 0u;
i |= s[1] == '2' ? 16u : 0u;
i |= s[0] == '2' ? 32u : 0u;
- c = UINT32_C(0x4D00) | yijing_hexagrams[i];
+ c = UINT32_C(0x4D00) | libcharconv_yijing_hexagrams_[i];
goto conv;
} else {
no_match:
diff --git a/libcharconv_yijing_hexagrams_.c b/libcharconv_yijing_hexagrams_.c
new file mode 100644
index 0000000..2004561
--- /dev/null
+++ b/libcharconv_yijing_hexagrams_.c
@@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+const unsigned char libcharconv_yijing_hexagrams_[] = {
+ 0xC0, 0xEB, 0xCC, 0xE0, 0xC9, 0xC5, 0xD8, 0xCB,
+ 0xC8, 0xF8, 0xE4, 0xF4, 0xFC, 0xFA, 0xE9, 0xD3,
+ 0xCD, 0xF1, 0xDD, 0xF7, 0xE5, 0xFF, 0xD4, 0xE2,
+ 0xD9, 0xD1, 0xD5, 0xF3, 0xE8, 0xC3, 0xDA, 0xD6,
+ 0xEA, 0xDB, 0xF0, 0xDE, 0xF9, 0xEE, 0xD0, 0xEC,
+ 0xC4, 0xEF, 0xFE, 0xE6, 0xFB, 0xDC, 0xC2, 0xC7,
+ 0xE1, 0xDF, 0xF6, 0xFD, 0xF5, 0xE7, 0xF2, 0xCF,
+ 0xCA, 0xED, 0xE3, 0xCE, 0xD2, 0xC6, 0xD7, 0xC1
+};
diff --git a/libcharconv_yijing_monograms.c b/libcharconv_yijing_monograms.c
index 12177ec..c8cc0d5 100644
--- a/libcharconv_yijing_monograms.c
+++ b/libcharconv_yijing_monograms.c
@@ -7,15 +7,10 @@ libcharconv_yijing_monograms(const char *s, size_t slen, size_t *n, uint_least32
{
uint_least32_t c;
*n = 0;
- for (; slen--; s++) {
- switch (*s) {
- case '1': c = UINT32_C(0x268A); goto conv;
- case '2': c = UINT32_C(0x268B); goto conv;
- case '3': c = UINT32_C(0x1D300); goto conv;
- default:
- *n += 1u;
- break;
- }
+ for (; slen--; s++, ++*n) {
+ PLAIN_SINGLE('1', 0x268A);
+ PLAIN_SINGLE('2', 0x268B);
+ PLAIN_SINGLE('3', 0x1D300);
}
no_conv:
return LIBCHARCONV_NO_CONVERT;