about summary refs log tree commit diff stats
path: root/src/chrtrans
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1999-09-14 02:17:54 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1999-09-14 02:17:54 -0400
commit2b52e9e64b2fc32242c207a0784521b2cf6d1976 (patch)
tree380b158ac389fc05813d55672b0b77bb0817f1dd /src/chrtrans
parentab1d1ae525ff4bed44e3ca2030fa655ad7c5bc7d (diff)
downloadlynx-snapshots-2b52e9e64b2fc32242c207a0784521b2cf6d1976.tar.gz
snapshot of project "lynx", label v2-8-3dev_9
Diffstat (limited to 'src/chrtrans')
-rw-r--r--src/chrtrans/build-chrtrans.com91
-rw-r--r--src/chrtrans/build-header.com1
-rw-r--r--src/chrtrans/make-msc.bat83
-rw-r--r--src/chrtrans/makefile.dos2
-rw-r--r--src/chrtrans/makefile.in2
-rw-r--r--src/chrtrans/makeuctb.c183
-rw-r--r--src/chrtrans/makew32.bat83
7 files changed, 250 insertions, 195 deletions
diff --git a/src/chrtrans/build-chrtrans.com b/src/chrtrans/build-chrtrans.com
index 42aebf86..0ba35058 100644
--- a/src/chrtrans/build-chrtrans.com
+++ b/src/chrtrans/build-chrtrans.com
@@ -76,86 +76,47 @@ $!
 $!	Create the Lynx [.SRC.CHRTRANS] header files.
 $!
 $ makeuctb := $'CHRwhere'makeuctb
-$ define/user sys$output 'CHRwhere'iso01_uni.h	!ISO Latin 1
-$ makeuctb iso01_uni.tbl
-$ define/user sys$output 'CHRwhere'cp850_uni.h	!DosLatin1 (cp850)
-$ makeuctb cp850_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1252_uni.h	!WinLatin1 (cp1252)
+$ makeuctb cp1250_uni.tbl
+$ makeuctb cp1251_uni.tbl
 $ makeuctb cp1252_uni.tbl
-$ define/user sys$output 'CHRwhere'cp437_uni.h	!DosLatinUS (cp437)
+$ makeuctb cp1253_uni.tbl
+$ makeuctb cp1255_uni.tbl
+$ makeuctb cp1256_uni.tbl
+$ makeuctb cp1257_uni.tbl
 $ makeuctb cp437_uni.tbl
-$ define/user sys$output 'CHRwhere'hp_uni.h	!HP Roman8
-$ makeuctb hp_uni.tbl
-$ define/user sys$output 'CHRwhere'dmcs_uni.h	!DEC Multinational
-$ makeuctb dmcs_uni.tbl
-$ define/user sys$output 'CHRwhere'mac_uni.h	!Macintosh (8 bit)
-$ makeuctb mac_uni.tbl
-$ define/user sys$output 'CHRwhere'next_uni.h	!NeXT character set
-$ makeuctb next_uni.tbl
-$ define/user sys$output 'CHRwhere'viscii_uni.h	!Vietnamese (VISCII)
-$ makeuctb viscii_uni.tbl
-$ define/user sys$output 'CHRwhere'def7_uni.h	!7 bit approximations
+$ makeuctb cp737_uni.tbl
+$ makeuctb cp775_uni.tbl
+$ makeuctb cp850_uni.tbl
+$ makeuctb cp852_uni.tbl
+$ makeuctb cp862_uni.tbl
+$ makeuctb cp864_uni.tbl
+$ makeuctb cp866_uni.tbl
+$ makeuctb cp866u_uni.tbl
+$ makeuctb cp869_uni.tbl
 $ makeuctb def7_uni.tbl
-$ define/user sys$output 'CHRwhere'iso02_uni.h	!ISO Latin 2
+$ makeuctb dmcs_uni.tbl
+$ makeuctb hp_uni.tbl
+$ makeuctb iso01_uni.tbl
 $ makeuctb iso02_uni.tbl
-$ define/user sys$output 'CHRwhere'cp852_uni.h	!DosLatin2 (cp852)
-$ makeuctb cp852_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1250_uni.h	!WinLatin2 (cp1250)
-$ makeuctb cp1250_uni.tbl
-$ define/user sys$output 'CHRwhere'iso03_uni.h	!ISO Latin 3
 $ makeuctb iso03_uni.tbl
-$ define/user sys$output 'CHRwhere'iso04_uni.h	!ISO Latin 4
 $ makeuctb iso04_uni.tbl
-$ define/user sys$output 'CHRwhere'cp775_uni.h	!DosBlatRim (cp775)
-$ makeuctb cp775_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1257_uni.h	!WinBlatRim (cp1257)
-$ makeuctb cp1257_uni.tbl
-$ define/user sys$output 'CHRwhere'iso05_uni.h	!ISO 8859-5 Cyrillic
 $ makeuctb iso05_uni.tbl
-$ define/user sys$output 'CHRwhere'cp866_uni.h	!DosCyrillic (cp866)
-$ makeuctb cp866_uni.tbl
-$ define/user sys$output 'CHRwhere'cp866u_uni.h	!Ukrainian Cyrillic
-$ makeuctb cp866u_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1251_uni.h	!WinCyrillic (cp1251)
-$ makeuctb cp1251_uni.tbl
-$ define/user sys$output 'CHRwhere'koi8r_uni.h	!KOI8-R Cyrillic
-$ makeuctb koi8r_uni.tbl
-$ define/user sys$output 'CHRwhere'koi8u_uni.h	!KOI8-U Ukranian Cyrillic
-$ makeuctb koi8u_uni.tbl
-$ define/user sys$output 'CHRwhere'iso06_uni.h	!ISO 8859-6 Arabic
 $ makeuctb iso06_uni.tbl
-$ define/user sys$output 'CHRwhere'cp864_uni.h	!DosArabic (cp864)
-$ makeuctb cp864_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1256_uni.h	!WinArabic (cp1256)
-$ makeuctb cp1256_uni.tbl
-$ define/user sys$output 'CHRwhere'iso07_uni.h	!ISO 8859-7 Greek
 $ makeuctb iso07_uni.tbl
-$ define/user sys$output 'CHRwhere'cp737_uni.h	!DosGreek (cp737)
-$ makeuctb cp737_uni.tbl
-$ define/user sys$output 'CHRwhere'cp869_uni.h	!DosGreek2 (cp869)
-$ makeuctb cp869_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1253_uni.h	!WinGreek (cp1253)
-$ makeuctb cp1253_uni.tbl
-$ define/user sys$output 'CHRwhere'iso08_uni.h	!ISO 8859-8 Hebrew
 $ makeuctb iso08_uni.tbl
-$ define/user sys$output 'CHRwhere'cp862_uni.h	!DosHebrew (cp862)
-$ makeuctb cp862_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1255_uni.h	!WinHebrew (cp1255)
-$ makeuctb cp1255_uni.tbl
-$ define/user sys$output 'CHRwhere'iso09_uni.h	!ISO 8859-9 (Latin 5)
 $ makeuctb iso09_uni.tbl
-$ define/user sys$output 'CHRwhere'iso10_uni.h	!ISO 8859-10
 $ makeuctb iso10_uni.tbl
-$ define/user sys$output 'CHRwhere'iso15_uni.h	!ISO 8859-15
 $ makeuctb iso15_uni.tbl
-$ define/user sys$output 'CHRwhere'utf8_uni.h	!UNICODE UTF-8
-$ makeuctb utf8_uni.tbl
-$ define/user sys$output 'CHRwhere'rfc_suni.h	!RFC 1345 w/o Intro
-$ makeuctb rfc_suni.tbl
-$ define/user sys$output 'CHRwhere'mnem2_suni.h !RFC 1345 Mnemonic
+$ makeuctb koi8r_uni.tbl
+$ makeuctb koi8u_uni.tbl
+$ makeuctb mac_uni.tbl
+$ makeuctb mnem_suni.tbl
 $ makeuctb mnem2_suni.tbl
-$ define/user sys$output 'CHRwhere'mnem_suni.h	!(not used)
 $ makeuctb mnem_suni.tbl
+$ makeuctb next_uni.tbl
+$ makeuctb rfc_suni.tbl
+$ makeuctb utf8_uni.tbl
+$ makeuctb viscii_uni.tbl
 $ v1 = 'f$verify(0)'
 $ exit
 $!
diff --git a/src/chrtrans/build-header.com b/src/chrtrans/build-header.com
index 963825dd..c1e9d087 100644
--- a/src/chrtrans/build-header.com
+++ b/src/chrtrans/build-header.com
@@ -24,7 +24,6 @@ $!
 $!	Create a Lynx [.SRC.CHRTRANS] header file.
 $!
 $ makeuctb := $'CHRwhere'makeuctb
-$ define/user sys$output 'CHRwhere''P1'.h
 $ makeuctb 'P1'.tbl
 $ v1 = 'f$verify(0)'
 $ exit
diff --git a/src/chrtrans/make-msc.bat b/src/chrtrans/make-msc.bat
index 7e69d642..e17389cb 100644
--- a/src/chrtrans/make-msc.bat
+++ b/src/chrtrans/make-msc.bat
@@ -2,48 +2,47 @@
 @echo this batch file.

 @echo .

 @echo off

-REM make -f makefile.w32

 

 nmake -f makefile.msc

 

-makeuctb cp1250_uni.tbl > cp1250_uni.h

-makeuctb cp1251_uni.tbl > cp1251_uni.h

-makeuctb cp1252_uni.tbl > cp1252_uni.h

-makeuctb cp1253_uni.tbl > cp1253_uni.h

-makeuctb cp1255_uni.tbl > cp1255_uni.h

-makeuctb cp1256_uni.tbl > cp1256_uni.h

-makeuctb cp1257_uni.tbl > cp1257_uni.h

-makeuctb cp437_uni.tbl > cp437_uni.h

-makeuctb cp737_uni.tbl > cp737_uni.h

-makeuctb cp775_uni.tbl > cp775_uni.h

-makeuctb cp850_uni.tbl > cp850_uni.h

-makeuctb cp852_uni.tbl > cp852_uni.h

-makeuctb cp862_uni.tbl > cp862_uni.h

-makeuctb cp864_uni.tbl > cp864_uni.h

-makeuctb cp866_uni.tbl > cp866_uni.h

-makeuctb cp866u_uni.tbl > cp866u_uni.h

-makeuctb cp869_uni.tbl > cp869_uni.h

-makeuctb def7_uni.tbl  > def7_uni.h

-makeuctb dmcs_uni.tbl > dmcs_uni.h

-makeuctb hp_uni.tbl > hp_uni.h

-makeuctb iso01_uni.tbl > iso01_uni.h

-makeuctb iso02_uni.tbl > iso02_uni.h

-makeuctb iso03_uni.tbl > iso03_uni.h

-makeuctb iso04_uni.tbl > iso04_uni.h

-makeuctb iso05_uni.tbl > iso05_uni.h

-makeuctb iso06_uni.tbl > iso06_uni.h

-makeuctb iso07_uni.tbl > iso07_uni.h

-makeuctb iso08_uni.tbl > iso08_uni.h

-makeuctb iso09_uni.tbl > iso09_uni.h

-makeuctb iso10_uni.tbl > iso10_uni.h

-makeuctb iso15_uni.tbl > iso15_uni.h

-makeuctb koi8r_uni.tbl > koi8r_uni.h

-makeuctb koi8u_uni.tbl > koi8u_uni.h

-makeuctb mac_uni.tbl > mac_uni.h

-makeuctb mnem_suni.tbl > mnem_suni.h

-makeuctb mnem2_suni.tbl > mnem2_suni.h

-makeuctb mnem_suni.tbl > mnem_suni.h

-makeuctb next_uni.tbl > next_uni.h

-makeuctb rfc_suni.tbl > rfc_suni.h

-makeuctb utf8_uni.tbl > utf8_uni.h

-makeuctb viscii_uni.tbl > viscii_uni.h

+makeuctb cp1250_uni.tbl

+makeuctb cp1251_uni.tbl

+makeuctb cp1252_uni.tbl

+makeuctb cp1253_uni.tbl

+makeuctb cp1255_uni.tbl

+makeuctb cp1256_uni.tbl

+makeuctb cp1257_uni.tbl

+makeuctb cp437_uni.tbl

+makeuctb cp737_uni.tbl

+makeuctb cp775_uni.tbl

+makeuctb cp850_uni.tbl

+makeuctb cp852_uni.tbl

+makeuctb cp862_uni.tbl

+makeuctb cp864_uni.tbl

+makeuctb cp866_uni.tbl

+makeuctb cp866u_uni.tbl

+makeuctb cp869_uni.tbl

+makeuctb def7_uni.tbl

+makeuctb dmcs_uni.tbl

+makeuctb hp_uni.tbl

+makeuctb iso01_uni.tbl

+makeuctb iso02_uni.tbl

+makeuctb iso03_uni.tbl

+makeuctb iso04_uni.tbl

+makeuctb iso05_uni.tbl

+makeuctb iso06_uni.tbl

+makeuctb iso07_uni.tbl

+makeuctb iso08_uni.tbl

+makeuctb iso09_uni.tbl

+makeuctb iso10_uni.tbl

+makeuctb iso15_uni.tbl

+makeuctb koi8r_uni.tbl

+makeuctb koi8u_uni.tbl

+makeuctb mac_uni.tbl

+makeuctb mnem_suni.tbl

+makeuctb mnem2_suni.tbl

+makeuctb mnem_suni.tbl

+makeuctb next_uni.tbl

+makeuctb rfc_suni.tbl

+makeuctb utf8_uni.tbl

+makeuctb viscii_uni.tbl

diff --git a/src/chrtrans/makefile.dos b/src/chrtrans/makefile.dos
index cc9884cf..369246ac 100644
--- a/src/chrtrans/makefile.dos
+++ b/src/chrtrans/makefile.dos
@@ -77,7 +77,7 @@ makeuctb.exe: makeuctb.c UCkd.h
 	strip makeuctb.exe
 
 .tbl.h:
-	./makeuctb $*.tbl > $@
+	./makeuctb $*.tbl
 
 cp1250_uni.h:		cp1250_uni.tbl		makeuctb.exe
 cp1251_uni.h:		cp1251_uni.tbl		makeuctb.exe
diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in
index 87a39825..52cf5524 100644
--- a/src/chrtrans/makefile.in
+++ b/src/chrtrans/makefile.in
@@ -109,7 +109,7 @@ makeuctb.o: $(srcdir)/UCkd.h $(srcdir)/makeuctb.c
 	@ECHO_CC@$(CPP) -C $(CPP_OPTS) $(srcdir)/$*.c >$@
 
 .tbl.h:
-	./makeuctb$x $(srcdir)/$*.tbl > $@
+	./makeuctb$x $(srcdir)/$*.tbl $*.h
 
 # table files listed here once again to get the make dependencies
 # right, in case makeuctb was recompiled.
diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c
index 4a940b7e..305a9abf 100644
--- a/src/chrtrans/makeuctb.c
+++ b/src/chrtrans/makeuctb.c
@@ -25,6 +25,10 @@
 #undef exit
 #endif /* exit */
 
+#ifndef TOUPPER
+#define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : (c))
+#endif /* !TOLOWER */
+
 #ifndef TOLOWER
 #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : (c))
 #endif /* !TOLOWER */
@@ -39,25 +43,39 @@
  */
 typedef u16 unicode;
 
+static FILE *chdr = 0;
+
 /*
- * Since we're writing the formatted file to stdout, ensure that we flush
+ * Since we may be 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 done PARAMS((int code)) GCC_NORETURN;
+PRIVATE void done ARGS1(int, code)
+{
+    fflush(chdr);
+    fclose(chdr);
+    fflush(stderr);
+    exit(code);
+}
 
-PRIVATE void usage ARGS1(
-	char *,		argv0)
+PRIVATE void usage NOARGS
 {
-    fprintf(stderr, "Usage: \n");
-    fprintf(stderr,
-	    "        %s chartable [charsetmimename] [charsetdisplayname]\n",
-	    argv0);
-    fprintf(stderr,
-	    "Utility to convert .tbl into .h files for Lynx compilation.\n");
+    static CONST char *tbl[] = {
+	"Usage: makeuctb [parameters]"
+	"",
+	"Utility to convert .tbl into .h files for Lynx compilation.",
+	""
+	"Parameters (all are optional):",
+	"  1: the input file (normally {filename}.tbl, but \"-\" for stdin",
+	"  2: the output file (normally {filename}.tbl but \"-\" for stdout",
+	"  3: charset mime name",
+	"  4: charset display name"
+    };
+    unsigned n;
+    for (n = 0; n < TABLESIZE(tbl); n++) {
+	fprintf(stderr, "%s\n", tbl[n]);
+    };
     done(EX_USAGE);
 }
 
@@ -110,7 +128,8 @@ int unicount[MAX_FONTLEN];
 
 struct unimapdesc_str themap_str = {0, NULL, 0, 0};
 
-char *tblname;
+PRIVATE char *tblname;
+PRIVATE char *hdrname;
 
 PRIVATE int RawOrEnc = 0;
 PRIVATE int Raw_found = 0;		/* whether explicit R directive found */
@@ -218,16 +237,55 @@ PUBLIC int main ARGS2(
 	int,		argc,
 	char **,	argv)
 {
+    static char *first_ifdefs[] = {
+	"/*",
+	" * Compile-in this chunk of code unless we've turned it off specifically",
+	" * or in general (id=%s).",
+	" */",
+	"",
+	"#ifndef INCL_CHARSET%s",
+	"#define INCL_CHARSET%s 1",
+	"",
+	"/*ifdef NO_CHARSET*/",
+	"#ifdef  NO_CHARSET",
+	"#undef  NO_CHARSET",
+	"#endif",
+	"#define NO_CHARSET 0 /* force default to always be active */",
+	"",
+	"/*ifndef NO_CHARSET%s*/",
+	"#ifndef NO_CHARSET%s",
+	"",
+	"#if    ALL_CHARSETS",
+	"#define NO_CHARSET%s 0",
+	"#else",
+	"#define NO_CHARSET%s 1",
+	"#endif",
+	"",
+	"#endif /* ndef(NO_CHARSET%s) */",
+	"",
+	"#if NO_CHARSET%s",
+	"#define UC_CHARSET_SETUP%s /*nothing*/",
+	"#else"
+    };
+    static char *last_ifdefs[] = {
+	"",
+	"#endif /* NO_CHARSET%s */"
+	"",
+	"#endif /* INCL_CHARSET%s */"
+    };
+
     FILE *ctbl;
     char buffer[65536];
+    char outname[256];
+    unsigned n;
     int fontlen;
     int i, nuni, nent;
-    int fp0, fp1, un0, un1;
+    int fp0 = 0, fp1 = 0, un0, un1;
     char *p, *p1;
     char *tbuf, ch;
 
-    if (argc < 2 || argc > 4) {
-	usage(argv[0]);
+    if (argc < 2 || argc > 5) {
+	usage();
     }
 
     if (!strcmp(argv[1], "-")) {
@@ -241,6 +299,31 @@ PUBLIC int main ARGS2(
 	}
     }
 
+    if (argc > 2) {
+	if (!strcmp(argv[2], "-")) {
+	    chdr = stdout;
+	    hdrname = "stdout";
+	} else {
+	    hdrname = argv[2];
+	}
+    } else if (ctbl == stdin) {
+	chdr = stdout;
+	hdrname = "stdout";
+    } else {
+	strcpy(hdrname = outname, tblname);
+	if ((p = strrchr(outname, '.')) == 0)
+	    p = outname + strlen(outname);
+	strcpy(p, ".h");
+    }
+
+    if (chdr == 0) {
+	chdr = fopen(hdrname, "w");
+	if (!chdr) {
+	    perror(hdrname);
+	    done(EX_NOINPUT);
+	}
+    }
+
     /*
      *  For now we assume the default font is always 256 characters.
      */
@@ -488,7 +571,7 @@ PUBLIC int main ARGS2(
 	    *p1 = '\0';
 	    for (i = un0; i <= un1; i++) {
 #ifdef NOTDEFINED
-		printf("U+0x%x:%s\n", i, tbuf); */
+		fprintf(chdr, "U+0x%x:%s\n", i, tbuf); */
 #endif /* NOTDEFINED */
 		addpair_str(tbuf,i);
 	    }
@@ -637,8 +720,8 @@ PUBLIC int main ARGS2(
 	nuni += unicount[i];
     }
 
-    if (argc >= 3) {
-	strncpy(this_MIMEcharset,argv[2],UC_MAXLEN_MIMECSNAME);
+    if (argc > 3) {
+	strncpy(this_MIMEcharset,argv[3],UC_MAXLEN_MIMECSNAME);
     } else if (this_MIMEcharset[0] == '\0') {
 	strncpy(this_MIMEcharset,tblname,UC_MAXLEN_MIMECSNAME);
 	if ((p = strchr(this_MIMEcharset,'.')) != 0) {
@@ -648,8 +731,8 @@ PUBLIC int main ARGS2(
     for (p = this_MIMEcharset; *p; p++) {
 	*p = TOLOWER(*p);
     }
-    if (argc >= 4) {
-	strncpy(this_LYNXcharset,argv[3],UC_MAXLEN_LYNXCSNAME);
+    if (argc > 4) {
+	strncpy(this_LYNXcharset,argv[4],UC_MAXLEN_LYNXCSNAME);
     } else if (this_LYNXcharset[0] == '\0') {
 	strncpy(this_LYNXcharset,this_MIMEcharset,UC_MAXLEN_LYNXCSNAME);
     }
@@ -683,7 +766,12 @@ PUBLIC int main ARGS2(
     }
     fprintf(stderr, " (%s).\n", id_append);
 
-    printf("\
+    for (n = 0; n < TABLESIZE(first_ifdefs); n++) {
+	fprintf(chdr, first_ifdefs[n], id_append);
+	fprintf(chdr, "\n");
+    }
+
+    fprintf(chdr, "\n\
 /*\n\
  *  uni_hash.tbl\n\
  *\n\
@@ -700,13 +788,13 @@ static CONST u8 dfont_unicount%s[%d] = \n\
 	if (i >= 128 && unicount[i] > 0 && i < lowest_eight) {
 	    lowest_eight = i;
 	}
-	printf("%3d", unicount[i]);
+	fprintf(chdr, "%3d", unicount[i]);
 	if (i == (fontlen - 1)) {
-	    printf("\n};\n");
+	    fprintf(chdr, "\n};\n");
 	} else if ((i % 8) == 7) {
-	    printf(",\n\t");
+	    fprintf(chdr, ",\n\t");
 	} else {
-	    printf(", ");
+	    fprintf(chdr, ", ");
 	}
     }
 
@@ -719,10 +807,10 @@ static CONST u8 dfont_unicount%s[%d] = \n\
     }
 
     if (nuni) {
-	printf("\nstatic CONST u16 dfont_unitable%s[%d] = \n{\n\t",
+	fprintf(chdr, "\nstatic CONST u16 dfont_unitable%s[%d] = \n{\n\t",
 	       id_append, nuni);
     } else {
-	printf("\nstatic CONST u16 dfont_unitable%s[1]; /* dummy */\n", id_append);
+	fprintf(chdr, "\nstatic CONST u16 dfont_unitable%s[1]; /* dummy */\n", id_append);
     }
 
     fp0 = 0;
@@ -732,57 +820,62 @@ static CONST u8 dfont_unicount%s[%d] = \n\
 	    fp0++;
 	    nent = 0;
 	}
-	printf("0x%04x", unitable[fp0][nent++]);
+	fprintf(chdr, "0x%04x", unitable[fp0][nent++]);
 	if (i == (nuni - 1)) {
-	    printf("\n};\n");
+	    fprintf(chdr, "\n};\n");
 	} else if ((i % 8) == 7) {
-	    printf(",\n\t");
+	    fprintf(chdr, ",\n\t");
 	} else {
-	    printf(", ");
+	    fprintf(chdr, ", ");
 	}
     }
 
     if (themap_str.entry_ct) {
-	printf("\n\
+	fprintf(chdr, "\n\
 static struct unipair_str repl_map%s[%d] = \n\
 {\n\t", id_append, themap_str.entry_ct);
     } else {
-	printf("\n\
+	fprintf(chdr, "\n\
 /* static struct unipair_str repl_map%s[]; */\n", id_append);
     }
 
     for (i = 0; i < themap_str.entry_ct; i++) {
-	printf("{0x%x,\"%s\"}",
+	fprintf(chdr, "{0x%x,\"%s\"}",
 	       themap_str.entries[i].unicode,
 	       themap_str.entries[i].replace_str);
 	if (i == (themap_str.entry_ct - 1)) {
-	    printf("\n};\n");
+	    fprintf(chdr, "\n};\n");
 	} else if ((i % 4) == 3) {
-	    printf(",\n\t");
+	    fprintf(chdr, ",\n\t");
 	} else {
-	    printf(", ");
+	    fprintf(chdr, ", ");
 	}
     }
     if (themap_str.entry_ct) {
-	printf("\n\
+	fprintf(chdr, "\n\
 static CONST struct unimapdesc_str dfont_replacedesc%s = {%d,repl_map%s,",
 id_append, themap_str.entry_ct, id_append);
     } else {
-	printf("\n\
+	fprintf(chdr, "\n\
 static CONST struct unimapdesc_str dfont_replacedesc%s = {0,NULL,",id_append);
     }
-    printf("%d,%d};\n",
-    this_isDefaultMap ? 1 : 0,
-    (useDefaultMap && !this_isDefaultMap) ? 1 : 0
+    fprintf(chdr, "%d,%d};\n",
+	    this_isDefaultMap ? 1 : 0,
+	    (useDefaultMap && !this_isDefaultMap) ? 1 : 0
     );
 
 
-    printf("#define UC_CHARSET_SETUP%s UC_Charset_Setup(\
+    fprintf(chdr, "#define UC_CHARSET_SETUP%s UC_Charset_Setup(\
 \"%s\",\\\n\"%s\",\\\n\
 dfont_unicount%s,dfont_unitable%s,%d,\\\n\
 dfont_replacedesc%s,%d,%d,%d)\n",
 id_append, this_MIMEcharset, this_LYNXcharset,
 id_append, id_append, nuni, id_append, lowest_eight, RawOrEnc, CodePage);
 
+    for (n = 0; n < TABLESIZE(last_ifdefs); n++) {
+	fprintf(chdr, last_ifdefs[n], id_append);
+	fprintf(chdr, "\n");
+    }
+
     done(EX_OK);
 }
diff --git a/src/chrtrans/makew32.bat b/src/chrtrans/makew32.bat
index e0e28bc4..6339101d 100644
--- a/src/chrtrans/makew32.bat
+++ b/src/chrtrans/makew32.bat
@@ -1,44 +1,47 @@
 @echo If .tbl files are added or removed you will need to hand edit

 @echo this batch file.

+@echo .

 @echo off

+

 make -l -f makefile.bcb

-makeuctb cp1250_uni.tbl > cp1250_uni.h

-makeuctb cp1251_uni.tbl > cp1251_uni.h

-makeuctb cp1252_uni.tbl > cp1252_uni.h

-makeuctb cp1253_uni.tbl > cp1253_uni.h

-makeuctb cp1255_uni.tbl > cp1255_uni.h

-makeuctb cp1256_uni.tbl > cp1256_uni.h

-makeuctb cp1257_uni.tbl > cp1257_uni.h

-makeuctb cp437_uni.tbl > cp437_uni.h

-makeuctb cp737_uni.tbl > cp737_uni.h

-makeuctb cp775_uni.tbl > cp775_uni.h

-makeuctb cp850_uni.tbl > cp850_uni.h

-makeuctb cp852_uni.tbl > cp852_uni.h

-makeuctb cp862_uni.tbl > cp862_uni.h

-makeuctb cp864_uni.tbl > cp864_uni.h

-makeuctb cp866_uni.tbl > cp866_uni.h

-makeuctb cp866u_uni.tbl > cp866u_uni.h

-makeuctb cp869_uni.tbl > cp869_uni.h

-makeuctb def7_uni.tbl  > def7_uni.h

-makeuctb dmcs_uni.tbl > dmcs_uni.h

-makeuctb hp_uni.tbl > hp_uni.h

-makeuctb iso01_uni.tbl > iso01_uni.h

-makeuctb iso02_uni.tbl > iso02_uni.h

-makeuctb iso03_uni.tbl > iso03_uni.h

-makeuctb iso04_uni.tbl > iso04_uni.h

-makeuctb iso05_uni.tbl > iso05_uni.h

-makeuctb iso06_uni.tbl > iso06_uni.h

-makeuctb iso07_uni.tbl > iso07_uni.h

-makeuctb iso08_uni.tbl > iso08_uni.h

-makeuctb iso09_uni.tbl > iso09_uni.h

-makeuctb iso10_uni.tbl > iso10_uni.h

-makeuctb iso15_uni.tbl > iso15_uni.h

-makeuctb koi8r_uni.tbl > koi8r_uni.h

-makeuctb koi8u_uni.tbl > koi8u_uni.h

-makeuctb mac_uni.tbl > mac_uni.h

-makeuctb mnem2_suni.tbl > mnem2_suni.h

-makeuctb mnem_suni.tbl > mnem_suni.h

-makeuctb next_uni.tbl > next_uni.h

-makeuctb rfc_suni.tbl > rfc_suni.h

-makeuctb utf8_uni.tbl > utf8_uni.h

-makeuctb viscii_uni.tbl > viscii_uni.h

+

+makeuctb cp1250_uni.tbl

+makeuctb cp1251_uni.tbl

+makeuctb cp1252_uni.tbl

+makeuctb cp1253_uni.tbl

+makeuctb cp1255_uni.tbl

+makeuctb cp1256_uni.tbl

+makeuctb cp1257_uni.tbl

+makeuctb cp437_uni.tbl

+makeuctb cp737_uni.tbl

+makeuctb cp775_uni.tbl

+makeuctb cp850_uni.tbl

+makeuctb cp852_uni.tbl

+makeuctb cp862_uni.tbl

+makeuctb cp864_uni.tbl

+makeuctb cp866_uni.tbl

+makeuctb cp866u_uni.tbl

+makeuctb cp869_uni.tbl

+makeuctb def7_uni.tbl

+makeuctb dmcs_uni.tbl

+makeuctb hp_uni.tbl

+makeuctb iso01_uni.tbl

+makeuctb iso02_uni.tbl

+makeuctb iso03_uni.tbl

+makeuctb iso04_uni.tbl

+makeuctb iso05_uni.tbl

+makeuctb iso06_uni.tbl

+makeuctb iso07_uni.tbl

+makeuctb iso08_uni.tbl

+makeuctb iso09_uni.tbl

+makeuctb iso10_uni.tbl

+makeuctb iso15_uni.tbl

+makeuctb koi8r_uni.tbl

+makeuctb koi8u_uni.tbl

+makeuctb mac_uni.tbl

+makeuctb mnem2_suni.tbl

+makeuctb mnem_suni.tbl

+makeuctb next_uni.tbl

+makeuctb rfc_suni.tbl

+makeuctb utf8_uni.tbl

+makeuctb viscii_uni.tbl