diff options
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | convert-to-dentistry.c | 4 | ||||
| -rw-r--r-- | libcharconv.h | 5 | ||||
| -rw-r--r-- | libcharconv_dentistry.c | 61 | ||||
| -rw-r--r-- | libcharconv_flipped.c | 6 | ||||
| -rw-r--r-- | libcharconv_joined.c | 10 | ||||
| -rw-r--r-- | libcharconv_latin.c | 17 | ||||
| -rw-r--r-- | libcharconv_mirrored.c | 4 | ||||
| -rw-r--r-- | libcharconv_overlaid.c | 10 | ||||
| -rw-r--r-- | libcharconv_turned.c | 7 |
10 files changed, 120 insertions, 10 deletions
@@ -82,7 +82,8 @@ BIN =\ convert-to-rotated-90deg-ccw\ convert-to-invisible\ convert-to-enclosed\ - convert-to-metrical + convert-to-metrical\ + convert-to-dentistry LIBOBJ =\ libcharconv_decode_utf8_.o\ @@ -157,7 +158,8 @@ LIBOBJ =\ libcharconv_invisible.o\ libcharconv_enclosed_positive.o\ libcharconv_enclosed_negative.o\ - libcharconv_metrical.o + libcharconv_metrical.o\ + libcharconv_dentistry.o LOBJ = $(LIBOBJ:.o=.lo) diff --git a/convert-to-dentistry.c b/convert-to-dentistry.c new file mode 100644 index 0000000..abbaece --- /dev/null +++ b/convert-to-dentistry.c @@ -0,0 +1,4 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + +SIMPLE(libcharconv_dentistry) diff --git a/libcharconv.h b/libcharconv.h index 6693376..3763577 100644 --- a/libcharconv.h +++ b/libcharconv.h @@ -486,6 +486,11 @@ LIBCHARCONV_FUNC_(libcharconv_enclosed_negative); */ LIBCHARCONV_FUNC_(libcharconv_metrical); +/** + * Convert to DENTISTRY SYMBOLs + */ +LIBCHARCONV_FUNC_(libcharconv_dentistry); + #undef LIBCHARCONV_FUNC_ #endif diff --git a/libcharconv_dentistry.c b/libcharconv_dentistry.c new file mode 100644 index 0000000..e3f463e --- /dev/null +++ b/libcharconv_dentistry.c @@ -0,0 +1,61 @@ +/* See LICENSE file for copyright and license details. */ +#include "lib-common.h" + + +enum libcharconv_result +libcharconv_dentistry(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp) +{ + uint_least32_t c; + *n = 0; + for (; slen--; s++) { + switch (*s) { + case 'o': + case 'O': c = UINT32_C(0x23C0); goto conv; + case 'a': + case 'A': c = UINT32_C(0x23C3); goto conv; + case '~': c = UINT32_C(0x23C6); goto conv; + case 'l': c = UINT32_C(0x23BF); goto conv; + case 'j': c = UINT32_C(0x23CC); goto conv; + case 't': c = UINT32_C(0x23CA); goto conv; + case 'L': c = UINT32_C(0x23BE); goto conv; + case 'J': c = UINT32_C(0x23CB); goto conv; + case 'T': c = UINT32_C(0x23C9); goto conv; + case '-': + case '_': + if (!slen) + return LIBCHARCONV_INDETERMINATE; + if (s[1] != 'A' && s[1] != 'O' && s[1] != '~') + if (s[1] != 'a' && s[1] != 'o') + goto no_match; + c = (s[1] == 'A' || s[1] == 'a') ? UINT32_C(0x23C1) : + (s[1] == 'O' || s[1] == 'o') ? UINT32_C(0x23C4) : UINT32_C(0x23C7); + if (s[0] == '_') + c += 1u; + goto conv2; + default: + no_match: + *n += 1u; + break; + } + } +no_conv: + return LIBCHARCONV_NO_CONVERT; + +conv: + if (*n) + goto no_conv; + if (*ncp) + *cp = c; + *n += 1u; + *ncp = 1u; + return LIBCHARCONV_CONVERTED; + +conv2: + if (*n) + goto no_conv; + if (*ncp) + *cp = c; + *n += 2u; + *ncp = 1u; + return LIBCHARCONV_CONVERTED; +} diff --git a/libcharconv_flipped.c b/libcharconv_flipped.c index f015c99..9423bdd 100644 --- a/libcharconv_flipped.c +++ b/libcharconv_flipped.c @@ -28,7 +28,11 @@ static struct { {UINT32_C(0x230C), UINT32_C(0x230E)}, {UINT32_C(0x268E), UINT32_C(0x268D)}, {UINT32_C(0x1D301), UINT32_C(0x1D303)}, - {UINT32_C(0x1D302), UINT32_C(0x1D304)} + {UINT32_C(0x1D302), UINT32_C(0x1D304)}, + {UINT32_C(0x23BE), UINT32_C(0x23BF)}, + {UINT32_C(0x23CB), UINT32_C(0x23CC)}, + {UINT32_C(0x23C9), UINT32_C(0x23CA)}, + {UINT32_C(0x23C1), UINT32_C(0x23C2)} }; diff --git a/libcharconv_joined.c b/libcharconv_joined.c index 72377a2..e8e0a59 100644 --- a/libcharconv_joined.c +++ b/libcharconv_joined.c @@ -7,10 +7,12 @@ static struct { uint_least32_t b; uint_least32_t to; } pairs[] = { - {(uint_least32_t)'?', (uint_least32_t)'!', 0x2048}, - {(uint_least32_t)'?', (uint_least32_t)'?', 0x2047}, - {(uint_least32_t)'!', (uint_least32_t)'!', 0x203C}, - {(uint_least32_t)'!', (uint_least32_t)'?', 0x2049} + {(uint_least32_t)'?', (uint_least32_t)'!', UINT32_C(0x2048)}, + {(uint_least32_t)'?', (uint_least32_t)'?', UINT32_C(0x2047)}, + {(uint_least32_t)'!', (uint_least32_t)'!', UINT32_C(0x203C)}, + {(uint_least32_t)'!', (uint_least32_t)'?', UINT32_C(0x2049)}, + {UINT32_C(0x23CB), UINT32_C(0x23BE), UINT32_C(0x23C9)}, + {UINT32_C(0x23CC), UINT32_C(0x23BF), UINT32_C(0x23CA)} }; diff --git a/libcharconv_latin.c b/libcharconv_latin.c index 2693ea4..a3bc55f 100644 --- a/libcharconv_latin.c +++ b/libcharconv_latin.c @@ -994,6 +994,23 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz /* metrical */ case UINT32_C(0x23D1): c1 = '1'; goto conv1; + /* dentistry */ + case UINT32_C(0x23C0): c1 = 'O'; goto conv1; + case UINT32_C(0x23C3): c1 = 'A'; goto conv1; + case UINT32_C(0x23C6): c1 = '~'; goto conv1; + case UINT32_C(0x23BF): c1 = 'l'; goto conv1; + case UINT32_C(0x23CC): c1 = 'j'; goto conv1; + case UINT32_C(0x23CA): c1 = 't'; goto conv1; + case UINT32_C(0x23BE): c1 = 'L'; goto conv1; + case UINT32_C(0x23CB): c1 = 'J'; goto conv1; + case UINT32_C(0x23C9): c1 = 'T'; goto conv1; + case UINT32_C(0x23C1): c1 = '-'; c2 = 'O'; goto conv2; + case UINT32_C(0x23C4): c1 = '-'; c2 = 'A'; goto conv2; + case UINT32_C(0x23C7): c1 = '-'; c2 = '~'; goto conv2; + case UINT32_C(0x23C2): c1 = '_'; c2 = 'O'; goto conv2; + case UINT32_C(0x23C5): c1 = '_'; c2 = 'A'; goto conv2; + case UINT32_C(0x23C8): c1 = '_'; c2 = '~'; goto conv2; + default: no_match: *n += clen; diff --git a/libcharconv_mirrored.c b/libcharconv_mirrored.c index 78bc924..a71e480 100644 --- a/libcharconv_mirrored.c +++ b/libcharconv_mirrored.c @@ -19,7 +19,9 @@ static struct { {UINT32_C(0xA4D8), (uint_least32_t)'K'}, {UINT32_C(0x1F12F), UINT32_C(0x00A9)}, {UINT32_C(0x230C), UINT32_C(0x230D)}, - {UINT32_C(0x230E), UINT32_C(0x230F)} + {UINT32_C(0x230E), UINT32_C(0x230F)}, + {UINT32_C(0x23BE), UINT32_C(0x23CB)}, + {UINT32_C(0x23BF), UINT32_C(0x23CC)} }; diff --git a/libcharconv_overlaid.c b/libcharconv_overlaid.c index 4e8e0f7..0c6d525 100644 --- a/libcharconv_overlaid.c +++ b/libcharconv_overlaid.c @@ -44,7 +44,15 @@ static struct { {UINT32_C(0x2658), UINT32_C(0x2657), UINT32_C(0x1FA50)}, {UINT32_C(0x265E), UINT32_C(0x265B), UINT32_C(0x1FA51)}, {UINT32_C(0x265E), UINT32_C(0x265C), UINT32_C(0x1FA52)}, - {UINT32_C(0x265E), UINT32_C(0x265D), UINT32_C(0x1FA53)} + {UINT32_C(0x265E), UINT32_C(0x265D), UINT32_C(0x1FA53)}, + {UINT32_C(0x23CB), UINT32_C(0x23BE), UINT32_C(0x23C9)}, + {UINT32_C(0x23CC), UINT32_C(0x23BF), UINT32_C(0x23CA)}, + {UINT32_C(0x23C9), UINT32_C(0x23C0), UINT32_C(0x23C1)}, + {UINT32_C(0x23C9), UINT32_C(0x23C3), UINT32_C(0x23C4)}, + {UINT32_C(0x23C9), UINT32_C(0x23C6), UINT32_C(0x23C7)}, + {UINT32_C(0x23CA), UINT32_C(0x23C0), UINT32_C(0x23C2)}, + {UINT32_C(0x23CA), UINT32_C(0x23C3), UINT32_C(0x23C5)}, + {UINT32_C(0x23CA), UINT32_C(0x23C6), UINT32_C(0x23C8)} }; diff --git a/libcharconv_turned.c b/libcharconv_turned.c index 4dd587f..081bd9b 100644 --- a/libcharconv_turned.c +++ b/libcharconv_turned.c @@ -50,7 +50,12 @@ static struct { {UINT32_C(0x230E), UINT32_C(0x230D)}, {UINT32_C(0x268E), UINT32_C(0x268D)}, {UINT32_C(0x1D301), UINT32_C(0x1D303)}, - {UINT32_C(0x1D302), UINT32_C(0x1D304)} + {UINT32_C(0x1D302), UINT32_C(0x1D304)}, + {UINT32_C(0x23BE), UINT32_C(0x23CC)}, + {UINT32_C(0x23CB), UINT32_C(0x23BF)}, + {UINT32_C(0x23C9), UINT32_C(0x23CA)}, + {UINT32_C(0x23C1), UINT32_C(0x23C2)}, + {UINT32_C(0x23C7), UINT32_C(0x23C8)} }; |
