aboutsummaryrefslogtreecommitdiff
path: root/src/base/utf/vendor/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/utf/vendor/common.c')
-rw-r--r--src/base/utf/vendor/common.c30
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;