aboutsummaryrefslogtreecommitdiffstats
path: root/libcharconv_superscript.c
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 /libcharconv_superscript.c
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>
Diffstat (limited to 'libcharconv_superscript.c')
-rw-r--r--libcharconv_superscript.c16
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;