diff options
Diffstat (limited to 'libcharconv_superscript.c')
| -rw-r--r-- | libcharconv_superscript.c | 16 |
1 files changed, 4 insertions, 12 deletions
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; |
