diff options
Diffstat (limited to 'test/_brk-test.h')
-rw-r--r-- | test/_brk-test.h | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/test/_brk-test.h b/test/_brk-test.h index e468f23..3a66f23 100644 --- a/test/_brk-test.h +++ b/test/_brk-test.h @@ -19,7 +19,6 @@ #define CNTFUNC CONCAT(CONCAT(u8, BRKTYPE), cnt) static bool test(struct u8view, int); -static int hexdigits(rune); int main(int, char **argv) @@ -59,25 +58,21 @@ test(struct u8view sv, int id) typedef dynarr(char8_t) item; dynarr(item) items = {}; - struct u8view sv_cpy = sv; - - do { - rune op, ch; - u8next(&op, &sv_cpy); + rune op; + struct u8view sv_cpy = sv; + while ((op = u8cut(nullptr, &sv_cpy, U"×÷", 2)) != MBEND) { + rune ch; sscanf(sv_cpy.p, "%" SCNxRUNE, &ch); - int off = hexdigits(ch); - off = MAX(4, off); - VSHFT(&sv_cpy, off); - char8_t buf[U8_LEN_MAX] = {}; + char8_t buf[U8_LEN_MAX]; int w = rtou8(buf, sizeof(buf), ch); total += w; if (op == U'÷') DAPUSH(&items, (item){}); DAEXTEND(&items.buf[items.len - 1], buf, w); - } while (sv_cpy.len > 0); + } size_t off = 0; char8_t *p = bufalloc(nullptr, 1, total); @@ -114,14 +109,3 @@ test(struct u8view sv, int id) return true; } - -int -hexdigits(rune ch) -{ - int n = 0; - do { - ch /= 16; - n++; - } while (ch != 0); - return n; -} |