diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-12-05 15:17:44 -0800 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-12-05 15:17:44 -0800 |
commit | b48327d357e0818d1a6ae2a064cfa7d1567e1242 (patch) | |
tree | 4677f228a9846937a7ec71c72a1ab63ab69d68ab /src/base/utf/vendor/common.c | |
parent | c200dd832789afa298ba45e0b9efdec96c0e92cc (diff) |
feat(huge): huge refactor (in progress).
Commented out libc includes to uncover all explicit dependencies.
A large fraction has now been ported over (no testing).
I did not port over the command line tools, such as the rc shell.
These will be done independently - as of now I just want the library to
stand independent.
Compilation currently fails due to the lack of math functions.
Diffstat (limited to 'src/base/utf/vendor/common.c')
-rw-r--r-- | src/base/utf/vendor/common.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/base/utf/vendor/common.c b/src/base/utf/vendor/common.c index c35d022..37ccca3 100644 --- a/src/base/utf/vendor/common.c +++ b/src/base/utf/vendor/common.c @@ -1,5 +1,19 @@ #include "common.h" +int +fatal(char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + + fprintf(stderr,"panic: "); + vfprintf(stderr, fmt, args); + fprintf(stderr,"\n"); + + va_end(args); + rt·exit(1); +} + // ----------------------------------------------------------------------- // input functions @@ -29,7 +43,7 @@ parse(io·Buffer *io, int nfield, char field[][FieldLen]) strcpy(field[n++], b); if(n != nfield) - panicf("expected %d number of fields, got %d: %s", nfield, n, b); + fatal("expected %d number of fields, got %d: %s", nfield, n, b); return ParseOK; } @@ -47,7 +61,7 @@ codepoint(char *s) else if(b >= 'A' && b <= 'F') c += b - 'A' + 10; else - panicf("bad codepoint char '%c'", b); + fatal("bad codepoint char '%c'", b); } return c; @@ -64,23 +78,23 @@ codepointrange(io·Buffer *utf8, char field[NumFields][FieldLen], int *start, i c = codepoint(field[Fcode]); if(c >= NumRunes) - panicf("unexpected large codepoint %x", c); + fatal("unexpected large codepoint %x", c); if(c <= e) - panicf("bad code sequence: %x then %x", e, c); + fatal("bad code sequence: %x then %x", e, c); e = c; if(strstr(field[Fname], ", First>") != nil){ if(!parse(utf8, arrlen(other), other)) - panicf("range start at end of file"); + fatal("range start at end of file"); if(strstr(other[Fname], ", Last>") == nil) - panicf("range start not followed by range end"); + fatal("range start not followed by range end"); e = codepoint(other[Fcode]); if(e <= c) - panicf("bad code sequence: %x then %x", c, e); + fatal("bad code sequence: %x then %x", c, e); if(strcmp(field[Fcategory], other[Fcategory]) != 0) - panicf("range with mismatched category"); + fatal("range with mismatched category"); } *start = c; |