/* See LICENSE file for copyright and license details. */ #include "libcharconv.h" enum libcharconv_result libcharconv_cypriot(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[0]) { case 'A': case 'a': c = UINT32_C(0x10800); goto conv1; case 'E': case 'e': c = UINT32_C(0x10801); goto conv1; case 'I': case 'i': c = UINT32_C(0x10802); goto conv1; case 'O': case 'o': c = UINT32_C(0x10803); goto conv1; case 'U': case 'u': c = UINT32_C(0x10804); goto conv1; case 'J': case 'j': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10805); goto conv2; case 'O': case 'o': c = UINT32_C(0x10808); goto conv2; default: goto no_match; } case 'K': case 'k': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x1080A); goto conv2; case 'E': case 'e': c = UINT32_C(0x1080B); goto conv2; case 'I': case 'i': c = UINT32_C(0x1080C); goto conv2; case 'O': case 'o': c = UINT32_C(0x1080D); goto conv2; case 'U': case 'u': c = UINT32_C(0x1080E); goto conv2; default: goto no_match; } case 'L': case 'l': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x1080F); goto conv2; case 'E': case 'e': c = UINT32_C(0x10810); goto conv2; case 'I': case 'i': c = UINT32_C(0x10811); goto conv2; case 'O': case 'o': c = UINT32_C(0x10812); goto conv2; case 'U': case 'u': c = UINT32_C(0x10813); goto conv2; default: goto no_match; } case 'M': case 'm': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10814); goto conv2; case 'E': case 'e': c = UINT32_C(0x10815); goto conv2; case 'I': case 'i': c = UINT32_C(0x10816); goto conv2; case 'O': case 'o': c = UINT32_C(0x10817); goto conv2; case 'U': case 'u': c = UINT32_C(0x10818); goto conv2; default: goto no_match; } case 'N': case 'n': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10819); goto conv2; case 'E': case 'e': c = UINT32_C(0x1081A); goto conv2; case 'I': case 'i': c = UINT32_C(0x1081B); goto conv2; case 'O': case 'o': c = UINT32_C(0x1081C); goto conv2; case 'U': case 'u': c = UINT32_C(0x1081D); goto conv2; default: goto no_match; } case 'P': case 'p': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x1081E); goto conv2; case 'E': case 'e': c = UINT32_C(0x1081F); goto conv2; case 'I': case 'i': c = UINT32_C(0x10820); goto conv2; case 'O': case 'o': c = UINT32_C(0x10821); goto conv2; case 'U': case 'u': c = UINT32_C(0x10822); goto conv2; default: goto no_match; } case 'R': case 'r': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10823); goto conv2; case 'E': case 'e': c = UINT32_C(0x10824); goto conv2; case 'I': case 'i': c = UINT32_C(0x10825); goto conv2; case 'O': case 'o': c = UINT32_C(0x10826); goto conv2; case 'U': case 'u': c = UINT32_C(0x10827); goto conv2; default: goto no_match; } case 'S': case 's': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10828); goto conv2; case 'E': case 'e': c = UINT32_C(0x10829); goto conv2; case 'I': case 'i': c = UINT32_C(0x1082A); goto conv2; case 'O': case 'o': c = UINT32_C(0x1082B); goto conv2; case 'U': case 'u': c = UINT32_C(0x1082C); goto conv2; default: goto no_match; } case 'T': case 't': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x1082D); goto conv2; case 'E': case 'e': c = UINT32_C(0x1082E); goto conv2; case 'I': case 'i': c = UINT32_C(0x1082F); goto conv2; case 'O': case 'o': c = UINT32_C(0x10831); goto conv2; case 'U': case 'u': c = UINT32_C(0x10830); goto conv2; default: goto no_match; } case 'W': case 'w': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10832); goto conv2; case 'E': case 'e': c = UINT32_C(0x10833); goto conv2; case 'I': case 'i': c = UINT32_C(0x10834); goto conv2; case 'O': case 'o': c = UINT32_C(0x10835); goto conv2; default: goto no_match; } case 'X': case 'x': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x10837); goto conv2; case 'E': case 'e': c = UINT32_C(0x10838); goto conv2; default: goto no_match; } case 'Z': case 'z': if (!slen) return LIBCHARCONV_INDETERMINATE; switch (s[1]) { case 'A': case 'a': c = UINT32_C(0x1083C); goto conv2; case 'O': case 'o': c = UINT32_C(0x1083F); goto conv2; default: goto no_match; } default: no_match: *n += 1u; break; } } no_conv: return LIBCHARCONV_NO_CONVERT; conv1: 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; }