/* See LICENSE file for copyright and license details. */ #include "lib-common.h" enum libcharconv_result libcharconv_sans_serif(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp) { uint_least32_t c; size_t old_slen; *n = 0; for (; slen--; s++) { old_slen = slen; 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) { if (!slen--) goto indeterminate; if ((unsigned char)s[2] == 0xAAu) c = (uint_least32_t)UINT32_C(0x1F10B); else if ((unsigned char)s[2] == 0xBFu) c = (uint_least32_t)UINT32_C(0x1F10C); else goto no_match; goto conv3; } else if ((unsigned char)s[1] == 0x91u) { if (!slen--) goto indeterminate; if (0xA0u <= (unsigned char)s[2] && (unsigned char)s[2] <= 0xA9u) c = (uint_least32_t)UINT32_C(0x2780); else goto no_match; c += (unsigned char)s[2] - 0xA0u; goto conv3; } else if ((unsigned char)s[1] == 0x9Du) { if (!slen--) goto indeterminate; if (!slen--) goto indeterminate; if (0xB6u <= (unsigned char)s[2] && (unsigned char)s[2] <= 0xBFu) c = (uint_least32_t)UINT32_C(0x278A); else goto no_match; c += (unsigned char)s[2] - 0xB6u; goto conv3; } else { goto no_match; } } else { no_match: slen = old_slen; *n += 1u; } } no_conv: return LIBCHARCONV_NO_CONVERT; indeterminate: return LIBCHARCONV_INDETERMINATE; conv: if (*n) goto no_conv; if (*ncp) *cp = c; *n += 1u; *ncp = 1u; return LIBCHARCONV_CONVERTED; conv3: if (*n) goto no_conv; if (*ncp) *cp = c; *n += 3u; *ncp = 1u; return LIBCHARCONV_CONVERTED; }