about summary refs log tree commit diff stats
path: root/src/chrtrans
diff options
context:
space:
mode:
Diffstat (limited to 'src/chrtrans')
-rw-r--r--src/chrtrans/makeuctb.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c
index 4c191d77..ff66ad6c 100644
--- a/src/chrtrans/makeuctb.c
+++ b/src/chrtrans/makeuctb.c
@@ -40,6 +40,16 @@
  */
 typedef u16 unicode;
 
+/*
+ * Since we're writing the formatted file to stdout, ensure that we flush
+ * everything before leaving, since some old (and a few not-so-old) platforms
+ * that do not implement POSIX 'exit()'.
+ */
+#define done(code)  \
+    fflush(stdout); \
+    fflush(stderr); \
+    exit(code)
+
 PRIVATE void usage ARGS1(
 	char *,		argv0)
 {
@@ -49,7 +59,7 @@ PRIVATE void usage ARGS1(
 	    argv0);
     fprintf(stderr,
 	    "Utility to convert .tbl into .h files for Lynx compilation.\n");
-    exit(EX_USAGE);
+    done(EX_USAGE);
 }
 
 /* copied from HTString.c, not everybody has strncasecmp */
@@ -122,7 +132,7 @@ PRIVATE void addpair_str ARGS2(
 	    if (!themap_str.entries) {
 		fprintf(stderr,
 			"%s: Out of memory\n", tblname);
-		exit(EX_DATAERR);
+		done(EX_DATAERR);
 	    }
 	} else {
 	    /*
@@ -142,7 +152,7 @@ PRIVATE void addpair_str ARGS2(
 	if (themap_str.entry_ct > 1999) {
 	    fprintf(stderr,
 		"ERROR: Only 2000 unicode replacement strings permitted!\n");
-	    exit(EX_DATAERR);
+	    done(EX_DATAERR);
 	}
 	themap_str.entries[themap_str.entry_ct].unicode = un;
 	themap_str.entries[themap_str.entry_ct].replace_str = str;
@@ -188,7 +198,7 @@ PRIVATE void addpair ARGS2(
 	 */
 	if (unicount[fp] > 254) {
 	    fprintf(stderr, "ERROR: Only 255 unicodes/glyph permitted!\n");
-	    exit(EX_DATAERR);
+	    done(EX_DATAERR);
 	}
 	unitable[fp][unicount[fp]] = un;
 	unicount[fp]++;
@@ -226,7 +236,7 @@ PUBLIC int main ARGS2(
 	ctbl = fopen(tblname = argv[1], "r");
 	if (!ctbl) {
 	    perror(tblname);
-	    exit(EX_NOINPUT);
+	    done(EX_NOINPUT);
 	}
     }
 
@@ -376,11 +386,11 @@ PUBLIC int main ARGS2(
 	    un0 = getunicode(&p);
 	    if (un0 < 0) {
 		fprintf(stderr, "Bad input line: %s\n", buffer);
-		exit(EX_DATAERR);
+		done(EX_DATAERR);
 		fprintf(stderr,
     "%s: Bad Unicode range corresponding to font position range 0x%x-0x%x\n",
 			tblname, fp0, fp1);
-		exit(EX_DATAERR);
+		done(EX_DATAERR);
 	    }
 	    un1 = un0;
 	    while (*p == ' ' || *p == '\t') {
@@ -397,7 +407,7 @@ PUBLIC int main ARGS2(
 			    "%s: Bad Unicode range U+%x-U+%x\n",
 			    tblname, un0, un1);
 		    fprintf(stderr, "Bad input line: %s\n", buffer);
-		    exit(EX_DATAERR);
+		    done(EX_DATAERR);
 		}
 		while (*p == ' ' || *p == '\t') {
 		    p++;
@@ -414,7 +424,7 @@ PUBLIC int main ARGS2(
 
 	    if (!(p1 = tbuf)) {
 		fprintf(stderr, "%s: Out of memory\n", tblname);
-		exit(EX_DATAERR);
+		done(EX_DATAERR);
 	    }
 	    if (*p == '"') {
 		/*
@@ -474,7 +484,7 @@ PUBLIC int main ARGS2(
 	fp0 = strtol(p, &p1, 0);
 	if (p1 == p) {
 	    fprintf(stderr, "Bad input line: %s\n", buffer);
-	    exit(EX_DATAERR);
+	    done(EX_DATAERR);
         }
 	p = p1;
 
@@ -486,7 +496,7 @@ PUBLIC int main ARGS2(
 	    fp1 = strtol(p, &p1, 0);
 	    if (p1 == p) {
 		fprintf(stderr, "Bad input line: %s\n", buffer);
-		exit(EX_DATAERR);
+		done(EX_DATAERR);
 	    }
 	    p = p1;
         } else {
@@ -497,13 +507,13 @@ PUBLIC int main ARGS2(
 	    fprintf(stderr,
 		    "%s: Glyph number (0x%x) larger than font length\n",
 		    tblname, fp0);
-	    exit(EX_DATAERR);
+	    done(EX_DATAERR);
 	}
 	if (fp1 && (fp1 < fp0 || fp1 >= fontlen)) {
 	    fprintf(stderr,


def init():
	sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..')))

class Fake(object):
	def __getattr__(self, attrname):
		val = Fake()
		self.__dict__[attrname] = val
		return val

	def __call__(self, *_, **__):
		return Fake()

	def __clear__(self):
		self.__dict__.clear()

	def __iter__(self):
		return iter(())

class OK(Exception):
	pass

def raise_ok(*_, **__):
	raise OK()