diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/charconv |
Initial commit
Diffstat (limited to 'support/charconv')
-rw-r--r-- | support/charconv/Makefile | 52 | ||||
-rw-r--r-- | support/charconv/Makefile.bcc | 57 | ||||
-rw-r--r-- | support/charconv/README | 35 | ||||
-rw-r--r-- | support/charconv/char_arr.c | 430 | ||||
-rw-r--r-- | support/charconv/charconv.c | 1052 | ||||
-rw-r--r-- | support/charconv/charconv.man | 75 | ||||
-rw-r--r-- | support/charconv/charstab.h | 665 | ||||
-rw-r--r-- | support/charconv/getopt.c | 88 | ||||
-rw-r--r-- | support/charconv/sys_def.h | 55 |
9 files changed, 2509 insertions, 0 deletions
diff --git a/support/charconv/Makefile b/support/charconv/Makefile new file mode 100644 index 0000000000..bf318599ca --- /dev/null +++ b/support/charconv/Makefile @@ -0,0 +1,52 @@ +# Makefile for charconv +BIN_DIR = /usr/local/bin +#MAN_DIR = /usr/local/man +MAN_DIR = /usr/man +MANEXT = 1 +# +SHELL=/bin/sh +CC= cc +#CC= gcc +CFLAGS= -O + +LFLAGS= + +CFILES= charconv.c getopt.c +OFILES= charconv.o getopt.o + +CFILES2= char_arr.c getopt.c +OFILES2= char_arr.o getopt.o + +.c.o: + $(CC) $(CFLAGS) -c $< + +charconv: $(OFILES) + $(CC) $(CFLAGS) -o charconv $(OFILES) $(LFLAGS) + +char_arr: $(OFILES2) + $(CC) $(CFLAGS) -o char_arr $(OFILES2) $(LFLAGS) + +charconv.o: charconv.c charstab.h sys_def.h + +char_arr.o: char_arr.c charstab.h sys_def.h + +getopt.o: sys_def.h + +install: charconv + -if [ ! -d $(BIN_DIR) ] ; then mkdir -p $(BIN_DIR); fi + strip charconv + cp charconv $(BIN_DIR) + +install.man: charconv.man + -if [ ! -d $(MAN_DIR) ] ; then mkdir -p $(MAN_DIR); fi + -if [ ! -d $(MAN_DIR)/man$(MANEXT) ]; \ + then mkdir -p $(MAN_DIR)/man$(MANEXT); fi + cp charconv.man $(MAN_DIR)/man$(MANEXT)/charconv.$(MANEXT) + +clean: + rm -f *.o charconv char_arr + +dist: + rm -f *.o charconv char_arr + cd .. ; tar cvf charconv.tar ./charconv ; compress charconv.tar ; \ + cd charconv diff --git a/support/charconv/Makefile.bcc b/support/charconv/Makefile.bcc new file mode 100644 index 0000000000..b5de11997f --- /dev/null +++ b/support/charconv/Makefile.bcc @@ -0,0 +1,57 @@ +.AUTODEPEND + +# *Translator Definitions* +CC = bcc +CHARCONV.CFG +TASM = TASM +TLIB = tlib +TLINK = tlink +LIBPATH = D:\BC\LIB +INCLUDEPATH = D:\BC\INCLUDE + + +# *Implicit Rules* +.c.obj: + $(CC) -c {$< } + +.cpp.obj: + $(CC) -c {$< } + +# *List Macros* + + +EXE_dependencies = \ + charconv.obj \ + getopt.obj + +# *Explicit Rules* +charconv.exe: charconv.cfg $(EXE_dependencies) + $(TLINK) /v/x/c/P-/L$(LIBPATH) @&&| +c0s.obj+ +charconv.obj+ +getopt.obj +charconv + # no map file +cs.lib +| + + +# *Individual File Dependencies* +charconv.obj: charconv.cfg charconv.c + +getopt.obj: charconv.cfg getopt.c + +# *Compiler Configuration File* +charconv.cfg: makefile.bcc + copy &&| +-2 +-f- +-v +-vi- +-wpro +-weas +-wpre +-I$(INCLUDEPATH) +-L$(LIBPATH) +| charconv.cfg + + diff --git a/support/charconv/README b/support/charconv/README new file mode 100644 index 0000000000..8b9abd0106 --- /dev/null +++ b/support/charconv/README @@ -0,0 +1,35 @@ +CHARCONV is a program or filter that allows the transformation of +one encoding of an extended character set (e.g., ISO Latin-1) to +another (e.g., MS DOS, Macintosh). Note that the encoding of umlauts, +diphthongs, or diacritics is quite different in ISO Latin-1 +(Unix, MS Windows), MS DOS (code page 437) or Apple Macintosh. + +Moreover, this program takes care of transcriptions used in TeX or HTML +(hypertext markup language). Internally, a font description similar to the +TeX code (but without math mode) is used. Tags and macros are removed +from HTML and TeX input. (With respect to TeX, the resulting plain +text file is similar to that produced by utilities such as "detex" or +"unretex", but umlauts are taken into account.) + +Furthermore, the program allows conversion between different +end-of-line markers (Unix: LF, DOS: CRLF, Mac: CR). + +However, the text is not formatted. + +Installation: + +The file "sys_def.h" tries to define the system (and includes stdio.h); +it may have to be edited. +To install, look at the Makefile, edit the paths etc., type "make". +(Followed by "make install" and "make install.man".) + +The program has been compiled successfully on the following systems: + +Sun Sparc running SunOS 4.1.1 with cc or gcc +SGI Iris Indigo running IRIX 4.0.5F +IBM RS/6000 running AIX 3.2 +CDC 4680 running EP/IX 2.1.1 +IBM PC running DOS with Borland C++ 3.1 +Atari ST with Turbo C 2.0 + +Burkhard Kirste (kirste@chemie.fu-berlin.de) diff --git a/support/charconv/char_arr.c b/support/charconv/char_arr.c new file mode 100644 index 0000000000..49559a9369 --- /dev/null +++ b/support/charconv/char_arr.c @@ -0,0 +1,430 @@ +/* char_arr + * Create C header files for the conversion of character tables + * Dr. Burkhard Kirste 1993/07/13 + * kirste@chemie.fu-berlin.de + * usage: char_arr [-h] -f from_table -t to_table [[-o] output_file]] + * requires: sys_def.h, getopt.c, charstab.h + * cc char_arr.c getopt.c -o char_arr + */ +#define VERSION "1.00" +#include "sys_def.h" +#ifdef __ANSI +#include <string.h> +#include <stdlib.h> +#else +#ifdef sun +#include <stdlib.h> +#endif +#endif /* stdlib */ +#include "charstab.h" /* character tables */ + +#ifndef EOF +#define EOF -1 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef MAXPATHLEN +#define MAXPATHLEN 128 /* max. length of path names */ +#endif + +#define NPERLINE 8 /* array: numbers per line */ + + +/* prototypes */ +#ifdef __ANSI +#define PROTO(x) x +#else +#define PROTO(x) () +#endif + +int getopt PROTO((int argc, char **argv, char *opts)); +int write_table +PROTO((FILE *fp, char **from_table, char **to_table, + int nperline)); + int write_str PROTO((FILE *fp, char **from_table, int to_type, + int nperline)); + int make_table PROTO((char ***tablep, int table_type)); + +#undef PROTO + +/* globals */ + static char sccsid[] = "@(#)char_arr create headers. 93/07/13 BKi"; + extern char *optarg; /* option arg. (getopt) */ + extern int optind, optopt; /* option index (getopt) */ + + int + write_table(fp, from_table, to_table, nperline) + FILE *fp; + char **from_table, **to_table; + int nperline; + +/* + * write header for character conversion table + * 1993/07/10 BKi + * FILE *fp: output file + * char **from_table: source character table + * char **to_table: aim character table + * int nperline: entries per line + */ +{ + int i, j; + char *ptr; + + fprintf(fp, "char ctable[] = {\n "); + for (i = 0; i < 256; i++) + { + ptr = from_table[i]; + for (j = 0; j < 256; j++) + if (strcmp(ptr, to_table[j]) == 0) + break; + if (j >= 256) + j = i; + if (i > 0) + { + if (i % nperline == 0) + fprintf(fp, ",\n "); + else + fprintf(fp, ","); + } + fprintf(fp, "0x%02x", j); + } /* for i */ + fprintf(fp, "};\n"); + fprintf(fp, "\n/* %d entries */\n", i); + return 0; +} /* write_table */ + +int +write_str(fp, from_table, to_type, nperline) + FILE *fp; + char **from_table; + int to_type; + int nperline; + +/* + * write header for string-coded character table + * 1993/07/10 BKi + * FILE *fp: output file + * char **from_table: source character table + * int to_type: aim (0 ... 3) + * int nperline: entries per line + * global: trans_string + */ +{ + int i, j; + char *ptr; + + fprintf(fp, "char *stable[] = {\n "); + for (i = 0; i < 256; i++) + { + ptr = from_table[i]; + if (to_type > 0) + { + for (j = 0; j < TRANS_ROW; j++) + if (strcmp(ptr, trans_string[j][0]) == 0) + { + ptr = trans_string[j][to_type]; + break; + } + if (j >= 256) + ptr = NULL; + } + if (i % nperline == 0) + fprintf(fp, ",\n "); + else + fprintf(fp, ","); + if (ptr != NULL) + { + fputc('"', fp); + for (j = 0; j < strlen(ptr); j++) + { + if (ptr[j] == '"' || ptr[j] == '\\') + fputc('\\', fp); + fputc(ptr[j], fp); + } + fputc('"', fp); + } else + fprintf(fp, "\"\\\\%03o\"", i); + } /* for i */ + fprintf(fp, "};\n"); + fprintf(fp, "\n/* %d entries */\n", i); + return 0; +} /* write_str */ + +int +make_table(tablep, table_type) + char ***tablep; + int table_type; + +/* + * make ASCII or EBCDIC table + * 1993/07/10 BKi + * char ***tablep: pointer to table of strings (output) + * int table_type: 0 (ASCII) or 1 (EBCDIC) + * global: char *iso_table[], char ebc2asc[] + */ +{ + int i, j; + char **table; + + table = (char **) calloc(256, sizeof(char *)); + if (table == NULL) + { + fprintf(stderr, "make_table: memory allocation error.\n"); + return 1; + } + for (i = 0; i < 256; i++) + { + if (table_type == 1) + j = (int) ebc2asc[i] & 0xff; + else + j = i; + if (j < 128) + { + table[i] = (char *) malloc(sizeof(iso_table[j])); + if (table[i] == NULL) + { + fprintf(stderr, "make_table (2): memory allocation error.\n"); + return 1; + } + strcpy(table[i], iso_table[j]); + } else + { + table[i] = (char *) malloc(5); + if (table[i] == NULL) + { + fprintf(stderr, "make_table (3): memory allocation error.\n"); + return 1; + } + sprintf(table[i], "\\%03o", j); + } + } /* for i */ + *tablep = table; + return 0; +} /* make_table */ + +int +main(argc, argv) + int argc; + char **argv; +{ + static char opts[] = "hvf:t:o:"; /* options (getopt) */ + static char allowed[] = "acdehlmrst"; /* known table types */ + int optcheck = 0; /* check validity of options */ + int c; /* character */ + int i; + int from_type, to_type; /* source and aim type of conversion */ + char fname[MAXPATHLEN]; /* output file name */ + char **from_table, **to_table; /* character conversion + * tables */ + char **asc_table = NULL; /* optional ASCII table */ + char **ebc_table = NULL; /* optional EBCDIC table */ + FILE *fp = NULL; /* output file */ + + /* get options */ + fname[0] = '\0'; + do + { + if ((c = getopt(argc, argv, opts)) == EOF) + break; + switch (c) + { + case 'v': + fprintf(stderr, "%s %s\n", VERSION, sccsid); + case 'h': + case '?': + c = '?'; + optcheck = 0; + break; + case 'f': + from_type = (int) optarg[0] & 0xff; + optcheck |= 1; + break; + case 't': + to_type = (int) optarg[0] & 0xff; + optcheck |= 2; + break; + case 'o': + strncpy(fname, optarg, MAXPATHLEN); + fname[MAXPATHLEN - 1] = '\0'; + /* break; */ + } /* options switch */ + if (c == '?') + break; + } while (TRUE); + if (optcheck == 3) + { + /* check validity of arguments */ + if (strchr(allowed, from_type) == NULL) + { + fprintf(stderr, "Unknown character table '%c' (-f)\n", + (char) from_type); + optcheck = 0; + } + if (strchr(allowed, to_type) == NULL) + { + fprintf(stderr, "Unknown character table '%c' (-t)\n", + (char) to_type); + optcheck = 0; + } + } + if (optcheck != 3) + { + fprintf(stderr, + "usage: char_arr -f from_table -t to_table [[-o] output_file]\n"); + fprintf(stderr, " where from_table/to_table is one of:\n"); + fprintf(stderr, " a - ASCII (7 bit)\n"); + fprintf(stderr, " c - transcript (*)\n"); + fprintf(stderr, " d - DOS code page 437\n"); + fprintf(stderr, " e - EBCDIC\n"); + fprintf(stderr, " h - HTML (hypertext) (*)\n"); + fprintf(stderr, " l - ISO Latin 1 (Unix, ANSI, MS Windows)\n"); + fprintf(stderr, " m - Apple Macintosh\n"); + fprintf(stderr, " r - Atari ST\n"); + fprintf(stderr, " s - Symbol font\n"); + fprintf(stderr, " t - TeX (*)\n"); + fprintf(stderr, " (*) string code, output (-t) only!\n"); + return 1; + } + if (optind < argc) + { + strncpy(fname, argv[optind++], MAXPATHLEN); + fname[MAXPATHLEN - 1] = '\0'; + } + /* find conversion tables */ + switch (from_type) + { + case 'a': + if (asc_table == NULL) + { + if (make_table(&asc_table, 0) == 0) + from_table = asc_table; + else + from_table = NULL; + } else + from_table = asc_table; + break; + case 'd': + from_table = pc_table; + break; + case 'e': + if (ebc_table == NULL) + { + if (make_table(&ebc_table, 1) == 0) + from_table = ebc_table; + else + from_table = NULL; + } else + from_table = ebc_table; + break; + case 'l': + from_table = iso_table; + break; + case 'm': + from_table = mac_table; + break; + case 'r': + from_table = st_table; + break; + case 's': + from_table = sym_table; + break; + default: + from_table = NULL; + } /* switch */ + switch (to_type) + { + case 'a': + if (asc_table == NULL) + { + if (make_table(&asc_table, 0) == 0) + to_table = asc_table; + else + to_table = NULL; + } else + to_table = asc_table; + break; + case 'd': + to_table = pc_table; + break; + case 'e': + if (ebc_table == NULL) + { + if (make_table(&ebc_table, 1) == 0) + to_table = ebc_table; + else + to_table = NULL; + } else + to_table = ebc_table; + break; + case 'l': + to_table = iso_table; + break; + case 'm': + to_table = mac_table; + break; + case 'r': + to_table = st_table; + break; + case 's': + to_table = sym_table; + break; + default: + to_table = NULL; + } /* switch */ + if (from_table == NULL) + exit(1); + if (strlen(fname)) + { + fp = fopen(fname, "w"); + if (fp == NULL) + { + fprintf(stderr, "Error opening output file %s\n", fname); + exit(1); + } + } else + fp = stdout; + if (to_table != NULL) + write_table(fp, from_table, to_table, (int) NPERLINE); + else + { + switch (to_type) + { + case 'c': + to_type = 0; + break; + case 't': + to_type = 1; + break; + case 'h': + to_type = 2; + break; + default: + to_type = -1; + } + if (to_type >= 0) + write_str(fp, from_table, to_type, (int) NPERLINE); + } + if (fp != stdout && fp != NULL) + fclose(fp); + if (ebc_table != NULL) + { + for (i = 255; i >= 0; i--) + if (ebc_table[i] != NULL) + free(ebc_table[i]); + if (ebc_table != NULL) + free(ebc_table); + } + if (asc_table != NULL) + { + for (i = 255; i >= 0; i--) + if (asc_table[i] != NULL) + free(asc_table[i]); + if (asc_table != NULL) + free(asc_table); + } + return 0; +} /* main */ diff --git a/support/charconv/charconv.c b/support/charconv/charconv.c new file mode 100644 index 0000000000..11f0feda0a --- /dev/null +++ b/support/charconv/charconv.c @@ -0,0 +1,1052 @@ +/* charconv + * Filter for conversion of character tables + * Dr. Burkhard Kirste 1993/07/17 + * kirste@chemie.fu-berlin.de + * usage: charconv [-h|-v] [-d|-m|-u] [-f from_table] [-t to_table] + * [[-i] input_file [[-o] output_file]] + * requires: sys_def.h, getopt.c, charstab.h + * cc charconv.c getopt.c -o char_arr + */ +#define VERSION "1.00" +#define TEXQUOTE /* if defined, allow for ``F"u"se'' etc. */ +#include "sys_def.h" +#include <string.h> +#include <ctype.h> +#ifdef __ANSI +#include <stdlib.h> +#else +#ifdef sun +#include <stdlib.h> +#endif +#endif /* stdlib */ +#include "charstab.h" /* character tables */ + +#ifndef EOF +#define EOF -1 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef MAXPATHLEN +#define MAXPATHLEN 128 /* max. length of path names */ +#endif + +#define TABLELEN 256 /* size of conversion table */ +#define BUFLEN 1024 /* size of input buffer */ +#define MAXTOK 40 /* maximum size of token */ +#define OFFSET 1024 /* used in fgetit */ + + +/* prototypes */ +#ifdef __ANSI +#define PROTO(x) x +#else +#define PROTO(x) () +#endif + +int getopt PROTO((int argc, char **argv, char *opts)); +int do_table PROTO((char **from_table, char **to_table)); +int do_str PROTO((char **from_table, int to_type)); +int fgetit PROTO((int from_type, char **to_table, FILE *fp)); +int find_str PROTO((char *ptr, char **to_table)); + +#undef PROTO + +/* globals */ +static char sccsid[] = "@(#)charconv character conversion. 93/07/17 BKi"; +extern char *optarg; /* option arg. (getopt) */ +extern int optind, optopt; /* option index (getopt) */ +char buffer[BUFLEN]; /* input buffer */ +char conv_table[TABLELEN]; /* character conversion table */ +char *trans_ptr[TABLELEN]; /* string output */ + +int +do_table(from_table, to_table) + char **from_table, **to_table; + +/* + * Fill character conversion table + * 1993/07/11 BKi + * char **from_table: source character table + * char **to_table: aim character table + * global: conv_table[TABLELEN] + */ +{ + int i, j; + char *ptr; + + for (i = 0; i < TABLELEN; i++) + { + ptr = from_table[i]; + for (j = 0; j < TABLELEN; j++) + if (strcmp(ptr, to_table[j]) == 0) + break; + if (j >= TABLELEN) + j = i; + conv_table[i] = j; + } /* for i */ + return 0; +} /* do_table */ + +int +do_str(from_table, to_type) + char **from_table; + int to_type; + +/* + * Find corresponding string + * 1993/07/11 BKi + * char **from_table: source character table + * int to_type: type (column) in trans_string + * global: trans_string[TRANS_ROW][TRANS_COL] + * trans_ptr[TABLELEN] + */ +{ + int i, j; + char *ptr; + + for (i = 0; i < TABLELEN; i++) + { + ptr = from_table[i]; + for (j = 0; j < TRANS_ROW; j++) + if (strcmp(ptr, trans_string[j][0]) == 0) + { + trans_ptr[i] = trans_string[j][to_type]; + break; + } + if (j >= TRANS_ROW) + { + if (i == '\t') + trans_ptr[i] = "\t"; + else if (i == '\n') + trans_ptr[i] = "\n"; + else if (i == '\r') + trans_ptr[i] = "\r"; + else if (i < 32) + trans_ptr[i] = ""; + else + trans_ptr[i] = " "; + } + } /* for i */ + return 0; +} /* do_str */ + +int +find_str(ptr, to_table) + char *ptr; + char **to_table; + +/* + * Find character code corresponding to string + * 1993/07/11 BKi + * char *ptr: string + * char **to_table: character table + * return character code + */ +{ + int i; + + for (i = 0; i < TABLELEN; i++) + { + if (strcmp(ptr, to_table[i]) == 0) + return i; + } /* for i */ + /* if not found, use blank */ + return 0x20; +} /* find_str */ + +int +fgetit(from_type, to_table, fp) + int from_type; + char **to_table; + FILE *fp; + +/* + * Parse file fp, identify tokens, return character + * 1993/07/12 BKi + * int from_type: type of tokens (column) + * char **to_type: aim character table (or NULL) + * FILE *fp: input stream + * global: trans_string[TRANS_ROW][TRANS_COL] + * buffer[BUFLEN] + * return character_code || trans_string_row + OFFSET || EOF + */ +{ + int c; + int i; + static int len = 0; + static int special = 0; + + if (special < 2) + c = fgetc(fp); + if (c == EOF) + return c; + if (from_type == 0) + { + /* special coding */ + do + { + if (special == 0) + { + if (c != '\\') + return c; + else + { + ++special; + buffer[len++] = c; + buffer[len] = '\0'; + } + } else if (special == 1) + { + buffer[len++] = c; + buffer[len] = '\0'; + if (c == '\\' || len >= MAXTOK) + ++special; + } + if (special > 1) + { + c = buffer[0]; + for (i = 0; i < len; i++) + buffer[i] = buffer[i + 1]; + --len; + if (buffer[0] == '\\') + special = 1; + if (len == 0) + special = 0; + return c; + } + if (special == 1) + { + if (len > 2) + { + /* identify token */ + for (i = 0; i < TRANS_ROW; i++) + if (strcmp(buffer, trans_string[i][from_type]) == 0) + { + len = 0; + special = 0; + buffer[0] = '\0'; + if (to_table != NULL) + return find_str(trans_string[i][0], to_table); + else + return i + OFFSET; + } + } + c = fgetc(fp); + if (c == EOF) + return c; + } + } while (TRUE); + } else if (from_type == 1) + { + /* TeX */ + do + { + if (special == 2) + { + c = buffer[0]; + special = 0; + len = 0; + buffer[0] = '\0'; + } + if (special == 0) + { + if (c == '%') + { + do + { + c = fgetc(fp); + if (c == EOF) + return c; + } while (c != '\r' && c != '\n'); + return c; + } else if (c == '{' || c == '}' || c == '$') + { + c = fgetc(fp); + if (c == EOF) + return c; + continue; +#ifdef TEXQUOTE + } else if (c != '\\' && c != '\'' && c != '?' && c != '!' + && c != '`' && c != '"') +#else + } else if (c != '\\' && c != '\'' && c != '?' && c != '!' && c != '`') +#endif + return c; + else + { + special = 1; + buffer[len++] = c; + buffer[len] = '\0'; + } + } else if (special == 1) + { + if (len == 1 && buffer[0] != '\\') + { + /* check for '' ?` !` */ + buffer[len++] = c; + buffer[len] = '\0'; + if (strcmp(buffer, "``") == 0) + strcpy(buffer, "''"); +#ifdef TEXQUOTE + /* allow for ``F"u"se'' etc. */ + if (buffer[0] == '"') + { + switch (c) + { + case 'A': + strcpy(buffer, "\\\"A"); + len = 3; + break; + case 'O': + strcpy(buffer, "\\\"O"); + len = 3; + break; + case 'U': + strcpy(buffer, "\\\"U"); + len = 3; + break; + case 'a': + strcpy(buffer, "\\\"a"); + len = 3; + break; + case 'o': + strcpy(buffer, "\\\"o"); + len = 3; + break; + case 'u': + strcpy(buffer, "\\\"u"); + len = 3; + break; + case 's': + case '3': + case 'B': + strcpy(buffer, "\\ss{}"); + len = 5; + /* break; */ + } /* switch */ + } /* if quote */ +#endif + /* identify token */ + for (i = 0; i < TRANS_ROW; i++) + if (strcmp(buffer, trans_string[i][from_type]) == 0) + { + len = 0; + special = 0; + buffer[0] = '\0'; + if (to_table != NULL) + return find_str(trans_string[i][0], to_table); + else + return i + OFFSET; + } + /* otherwise nothing special */ + c = buffer[0]; + buffer[0] = buffer[1]; + buffer[1] = '\0'; + len = 1; + special = 2; + return c; + } + if (len >= MAXTOK) + { + len = 0; + special = 0; + buffer[0] = '\0'; + continue; + } else if (len == 1 && c == '3' && buffer[0] == '\\') + { + /* short for German sz */ + strcpy(buffer, "\\ss{}"); + len = 5; + } else if (len == 1 && c == '/' && buffer[0] == '\\') + { + /* italic extra space */ + len = 0; + special = 0; + buffer[0] = '\0'; + c = fgetc(fp); + if (c == EOF) + return c; + continue; + } else + { + buffer[len++] = c; + buffer[len] = '\0'; + } + } + if (special == 1) + { + if (len >= 2) + { + /* identify token */ + for (i = 0; i < TRANS_ROW; i++) + if (strncmp(buffer, trans_string[i][from_type], len) == 0 + || strncmp(buffer, &trans_string[i][from_type][1], len) == 0) + break; + if (i >= TRANS_ROW) + { + /* token not found */ + if (!isalpha(c)) + { + len = 0; + special = 0; + buffer[0] = '\0'; + if (c == ' ') + { + c = fgetc(fp); + if (c == EOF) + return c; + } + } else + { + /* get whole token */ + c = fgetc(fp); + if (c == EOF) + return c; + } + continue; + } + if (strcmp(buffer, trans_string[i][from_type]) == 0 + || trans_string[i][from_type][len + 1] == '$' + || trans_string[i][from_type][len] == '}' + || (trans_string[i][from_type][len] == '{' + && trans_string[i][from_type][len + 1] == '}')) + { + if (isalpha(c) && + (trans_string[i][from_type][len + 1] == '$' || + (trans_string[i][from_type][len] == '{' + && trans_string[i][from_type][len + 1] == '}'))) + { + c = fgetc(fp); + if (isalpha(c)) + continue; + else if (c != ' ') + { + special = 2; + buffer[0] = c; + buffer[1] = '\0'; + len = 1; + } + } + if (special != 2) + { + len = 0; + special = 0; + buffer[0] = '\0'; + } + if (to_table != NULL) + return find_str(trans_string[i][0], to_table); + else + return i + OFFSET; + } + } + c = fgetc(fp); + if (c == EOF) + return c; + } + } while (TRUE); + } else if (from_type == 2) + { + /* HTML */ + do + { + if (special == 0) + { + if (c != '&' && c != '<') + return c; + else + { + ++special; + buffer[len++] = c; + buffer[len] = '\0'; + } + } else if (special == 1) + { + buffer[len++] = c; + buffer[len] = '\0'; + if (c == '&' || len >= MAXTOK) + ++special; + } + if (special > 1) + { + c = buffer[0]; + for (i = 0; i < len; i++) + buffer[i] = buffer[i + 1]; + --len; + if (buffer[0] == '&' || buffer[0] == '<') + special = 1; + if (len == 0) + special = 0; + return c; + } + if (special == 1) + { + if (buffer[0] == '<' && (isalpha(buffer[1]) || buffer[1] == '/')) + { + /* skip HTML tag */ + do + { + c = fgetc(fp); + if (c == EOF) + return c; + if (c == '>') + { + special = 0; + len = 0; + buffer[0] = '\0'; + break; + } + } while (TRUE); + c = fgetc(fp); + if (c == EOF) + return c; + continue; + } + if (c == ';') + { + /* identify token */ + for (i = 0; i < TRANS_ROW; i++) + if (strcmp(buffer, trans_string[i][from_type]) == 0) + { + len = 0; + special = 0; + buffer[0] = '\0'; + if (to_table != NULL) + return find_str(trans_string[i][0], to_table); + else + return i + OFFSET; + } + if (strcmp(buffer, """) == 0) + c = '"'; + else + c = ' '; + len = 0; + special = 0; + buffer[0] = '\0'; + return c; + } + c = fgetc(fp); + if (c == EOF) + return c; + } + } while (TRUE); + } + return c; +} /* fgetit */ + +int +main(argc, argv) + int argc; + char **argv; +{ + static char opts[] = "hvdmuf:t:i:o:"; /* options (getopt) */ + static char allowed[] = " acdehlmrstz"; /* known table types */ + int optcheck = 0; /* check validitity of of options */ + int eol = 0; /* end-of-line option */ + int rtf_flag = 0; /* flag for RTF output (if 1) */ + int c; /* character */ + int lastc = ' '; + int i; + int in_type = 0, out_type = 0; /* 0: no conv., 1: char, 2: + * string */ + int from_type, to_type; /* source and aim type of conversion */ + char **from_table, **to_table; /* character conversion + * tables */ + char inname[MAXPATHLEN]; /* input file name */ + char outname[MAXPATHLEN]; /* output file name */ + FILE *fpin = NULL; /* input file */ + FILE *fpout = NULL; /* output file */ + + /* get options */ + inname[0] = outname[0] = '\0'; + from_type = to_type = ' '; + from_table = to_table = NULL; + do + { + if ((c = getopt(argc, argv, opts)) == EOF) + break; + switch (c) + { + case 'v': + fprintf(stderr, "%s %s\n", VERSION, sccsid); + case 'h': + case '?': + c = '?'; + optcheck = 1; + break; + case 'd': + eol = 1; + break; + case 'm': + eol = 2; + break; + case 'u': + eol = 3; + break; + case 'f': + from_type = (int) optarg[0] & 0xff; + break; + case 't': + to_type = (int) optarg[0] & 0xff; + break; + case 'i': + strncpy(inname, optarg, MAXPATHLEN); + inname[MAXPATHLEN - 1] = '\0'; + break; + case 'o': + strncpy(outname, optarg, MAXPATHLEN); + outname[MAXPATHLEN - 1] = '\0'; + /* break; */ + } /* options switch */ + if (c == '?') + break; + } while (TRUE); + if (optcheck == 0) + { + /* check validity of arguments */ + if (strchr(allowed, from_type) == NULL) + { + fprintf(stderr, "Unknown character table '%c' (-f)\n", + (char) from_type); + optcheck = 1; + } + if (strchr(allowed, to_type) == NULL) + { + fprintf(stderr, "Unknown character table '%c' (-t)\n", + (char) to_type); + optcheck = 1; + } + } + if (optcheck == 1) + { + fprintf(stderr, + "usage: charconv [-d|-m|-u] [-f from_table] [-t to_table]\n"); + fprintf(stderr, + " [[-i] input_file [-o] output_file]\n"); + fprintf(stderr, " -d - create MS DOS end-of-line (CRLF)\n"); + fprintf(stderr, " -m - create Macintosh end-of-line (CR)\n"); + fprintf(stderr, " -u - create Unix end-of-line (LF)\n"); + fprintf(stderr, " -f, -t - 'from'/'to' character table\n"); + fprintf(stderr, " where from_table/to_table is one of:\n"); + fprintf(stderr, " a - ASCII (7 bit) (*)\n"); + fprintf(stderr, " c - transcription (*)\n"); + fprintf(stderr, " d - DOS code page 437\n"); + fprintf(stderr, " e - EBCDIC (only for ASCII <-> EBCDIC!)\n"); + fprintf(stderr, " h - HTML (hypertext) (*)\n"); + fprintf(stderr, " l - ISO Latin 1 (Unix, ANSI, MS Windows)\n"); + fprintf(stderr, " m - Apple Macintosh\n"); + fprintf(stderr, " r - RTF (Rich Text Format) (output only!)\n"); + fprintf(stderr, " s - Symbol font\n"); + fprintf(stderr, " t - TeX (*)\n"); + fprintf(stderr, " z - Atari ST\n"); + fprintf(stderr, " (*) string code\n"); + return 1; + } + if (optind < argc) + { + strncpy(inname, argv[optind++], MAXPATHLEN); + inname[MAXPATHLEN - 1] = '\0'; + } + if (optind < argc) + { + strncpy(outname, argv[optind++], MAXPATHLEN); + outname[MAXPATHLEN - 1] = '\0'; + } + /* find conversion tables */ + switch (from_type) + { + case 'a': + in_type = 3; + from_table = NULL; + break; + case 'd': + in_type = 1; + from_table = pc_table; + break; + case 'e': + in_type = 4; + if (out_type == 0) + out_type = 3; + from_table = NULL; + break; + case 'l': + in_type = 1; + from_table = iso_table; + break; + case 'm': + in_type = 1; + from_table = mac_table; + break; + case 'z': + in_type = 1; + from_table = st_table; + break; + case 's': + in_type = 1; + from_table = sym_table; + break; + case 'c': + in_type = 2; + from_type = 0; + from_table = NULL; + break; + case 't': + in_type = 2; + from_type = 1; + from_table = NULL; + break; + case 'h': + in_type = 2; + from_type = 2; + from_table = NULL; + break; + default: + from_table = NULL; + } /* switch */ + switch (to_type) + { + case 'a': + out_type = 2; + to_type = 3; + to_table = NULL; + break; + case 'd': + out_type = 1; + to_table = pc_table; + break; + case 'e': + out_type = 4; + to_table = NULL; + break; + case 'r': + rtf_flag = 1; + case 'l': + out_type = 1; + to_table = iso_table; + break; + case 'm': + out_type = 1; + to_table = mac_table; + break; + case 'z': + out_type = 1; + to_table = st_table; + break; + case 's': + out_type = 1; + to_table = sym_table; + break; + case 'c': + out_type = 2; + to_type = 0; + to_table = NULL; + break; + case 't': + out_type = 2; + to_type = 1; + to_table = NULL; + break; + case 'h': + out_type = 2; + to_type = 2; + to_table = NULL; + break; + default: + to_table = NULL; + } /* switch */ + /* optionally, open files */ + if (strlen(inname)) + { + fpin = fopen(inname, "rb"); + if (fpin == NULL) + { + fprintf(stderr, "Error opening input file %s\n", inname); + exit(1); + } + } else + fpin = stdin; + if (strlen(outname)) + { + if (strlen(inname) && strcmp(inname, outname) == 0) + { + fprintf(stderr, "Error, 'output' must differ from 'input'\n"); + fpout = NULL; + } else + fpout = fopen(outname, "wb"); + if (fpout == NULL) + { + fprintf(stderr, "Error opening output file %s\n", outname); + exit(1); + } + } else + fpout = stdout; + /* prepare conversions */ + if (in_type == 1 && out_type == 0) + { + out_type = 1; +#ifdef __PC + to_type = 'd'; + to_table = pc_table; +#else +#ifdef __ATARI + to_type = 'r'; + to_table = st_table; +#else + to_type = 'l'; + to_table = iso_table; +#endif +#endif + } + if (in_type == 1 && out_type == 1) + { + if (from_table == to_table) + out_type = 0; + else + do_table(from_table, to_table); + } else if (in_type == 4) + { + /* EBCDIC to ASCII */ + in_type = 1; + out_type = 1; + for (i = 0; i < TABLELEN; i++) + conv_table[i] = ebc2asc[i]; + } else if (out_type == 4) + { + /* ASCII to EBCDIC */ + in_type = 1; + out_type = 1; + for (i = 0; i < TABLELEN; i++) + conv_table[i] = asc2ebc[i]; + } + if (out_type == 2 && in_type != 1 && in_type != 2) + { + in_type = 1; +#ifdef __PC + from_type = 'd'; + from_table = pc_table; +#else +#ifdef __ATARI + from_type = 'r'; + from_table = st_table; +#else + from_type = 'l'; + from_table = iso_table; +#endif +#endif + } + if (out_type == 2 && in_type == 1) + do_str(from_table, to_type); + if (in_type == 2) + { + buffer[0] = '\0'; + if (out_type == 0) + { + out_type = 1; +#ifdef __PC + to_type = 'd'; + to_table = pc_table; +#else +#ifdef __ATARI + to_type = 'r'; + to_table = st_table; +#else + to_type = 'l'; + to_table = iso_table; +#endif +#endif + } + } + if (rtf_flag == 1) + { + do + { + if (in_type < 2) + { + if ((c = fgetc(fpin)) == EOF) + break; + if (in_type == 1 && out_type == 1) + c = (int) conv_table[c] & 0xff; + else + c &= 0xff; + } else if (in_type == 2) + { + if ((c = fgetit(from_type, to_table, fpin)) == EOF) + break; + c &= 0xff; + } + if (c <= 0) + c = ' '; + if (c < 128) + { + if (fputc(c, fpout) == EOF) + break; + } else + { + if (fputs(rtf_table[c], fpout) == EOF) + break; + } + } while (TRUE); + } else if (in_type == 1 && out_type == 1) + { + do + { + if ((c = fgetc(fpin)) == EOF) + break; + if (eol == 0) + { + c = (int) conv_table[c] & 0xff; + if (fputc(c, fpout) == EOF) + break; + } else + { + if (from_type == 'e') + c = (int) conv_table[c] & 0xff; + if (c == '\n' && lastc == '\r') + { + /* CRLF */ + lastc = c; + continue; + } + lastc = c; + if (c == '\n' || c == '\r') + { + /* EOL */ + if (eol == 1) + { + /* DOS */ + c = '\r'; + if (to_type == 'e') + c = (int) conv_table[c] & 0xff; + if (fputc(c, fpout) == EOF) + break; + c = '\n'; + } else if (eol == 2) + c = '\r'; + else if (eol == 3) + c = '\n'; + } + if (from_type != 'e') + c = (int) conv_table[c] & 0xff; + if (fputc(c, fpout) == EOF) + break; + } + } while (TRUE); + } else if (in_type == 0 && out_type == 0) + { + do + { + if ((c = fgetc(fpin)) == EOF) + break; + if (eol == 0) + { + if (fputc(c, fpout) == EOF) + break; + } else + { + if (c == '\n' && lastc == '\r') + { + /* CRLF */ + lastc = c; + continue; + } + lastc = c; + if (c == '\n' || c == '\r') + { + /* EOL */ + if (eol == 1) + { + /* DOS */ + c = '\r'; + if (fputc(c, fpout) == EOF) + break; + c = '\n'; + } else if (eol == 2) + c = '\r'; + else if (eol == 3) + c = '\n'; + } + if (fputc(c, fpout) == EOF) + break; + } + } while (TRUE); + } else + do + { + if (in_type == 2) + { + if ((c = fgetit(from_type, to_table, fpin)) == EOF) + break; + } else if ((c = fgetc(fpin)) == EOF) + break; + if (eol == 0) + { + if (out_type == 2) + { + if (c >= OFFSET) + { + if (fputs(trans_string[c - OFFSET][to_type], fpout) == EOF) + break; + } else if (in_type == 2) + { + if (fputc(c, fpout) == EOF) + break; + } else + { + if (fputs(trans_ptr[c], fpout) == EOF) + break; + } + } else if (fputc(c, fpout) == EOF) + break; + } else + { + if (c == '\n' && lastc == '\r') + { + /* CRLF */ + lastc = c; + continue; + } + lastc = c; + if (c == '\n' || c == '\r') + { + /* EOL */ + if (eol == 1) + { + /* DOS */ + c = '\r'; + if (fputc(c, fpout) == EOF) + break; + c = '\n'; + } else if (eol == 2) + c = '\r'; + else if (eol == 3) + c = '\n'; + if (fputc(c, fpout) == EOF) + break; + } else if (out_type == 2) + { + if (c >= OFFSET) + { + if (fputs(trans_string[c - OFFSET][to_type], fpout) == EOF) + break; + } else if (in_type == 2) + { + if (fputc(c, fpout) == EOF) + break; + } else + { + if (fputs(trans_ptr[c], fpout) == EOF) + break; + } + } else if (fputc(c, fpout) == EOF) + break; + } + } while (TRUE); + if (fpout != stdout && fpout != NULL) + fclose(fpout); + if (fpin != stdin && fpin != NULL) + fclose(fpin); + return 0; +} /* main */ diff --git a/support/charconv/charconv.man b/support/charconv/charconv.man new file mode 100644 index 0000000000..717d303141 --- /dev/null +++ b/support/charconv/charconv.man @@ -0,0 +1,75 @@ +.TH CHARCONV 1 "13 July 1993" +.SH NAME +charconv \- Conversion of characters between various systems +.SH SYNOPSIS +\fBcharconv\fP [-d|-m|-u] [-f \fIfrom_table\fP] [-t \fIto_table\fP] +[[-i] \fIinput_file\fP [-o] \fIoutput_file\fP] +.SH "DESCRIPTION" +CHARCONV is a program or filter that allows the transformation of +one encoding of an extended character set (e.g., ISO Latin-1) to +another. Note that the encoding of umlauts, diphthongs, or diacritics +is quite different in ISO Latin-1 (Unix, MS Windows), +MS DOS (code page 437) or Apple Macintosh. Moreover, this program +takes care of transcriptions used in TeX or HTML (hypertext markup +language). Internally, a font description similar to the TeX code +(but without math mode) is used. Tags and macros are removed from +HTML and TeX input. +.LP +Furthermore, the program allows conversion between different +end-of-line markers (Unix: LF, DOS: CRLF, Mac: CR). +.SH OPTIONS +\fBcharconv\fP [-d|-m|-u] [-f \fIfrom_table\fP] [-t \fIto_table\fP] +[[-i] \fIinput_file\fP [-o] \fIoutput_file\fP] +.LP +.IP \fB-d\fP +create MS DOS end-of-line (CRLF) +.IP \fB-m\fP +create Macintosh end-of-line (CR) +.IP \fB-u\fP +create Unix end-of-line (LF) +.IP \fB-f\fP +\fIfrom_table\fP +.IP \fB-t\fP +\fIto_table\fP +.PP +from/to character table, where from_table/to_table is one of: +.LP +.in +4m +.nf + a - ASCII (7 bit) (*) + c - transcription (*) + d - DOS code page 437 + e - EBCDIC (only for ASCII <-> EBCDIC!) + h - HTML (hypertext) (*) + l - ISO Latin 1 (Unix, ANSI, MS Windows) + m - Apple Macintosh + r - RTF (Rich Text Format) (output only!) + s - Symbol font + t - TeX (*) + z - Atari ST + (*) string code +.fi +.in -4m +.LP +.SH EXAMPLES +.nf + charconv -ft myfile.tex + (de-texify file, using umlauts of current system) + charconv -ft -th myfile.tex myfile.html + (convert from TeX to HTML) + charconv -m -fd -tm dos.txt mac_txt + (convert from "DOS" to "Macintosh") + cat myfile.html | charconv -fh | less -r +.fi +.SH FILES +.nf +\fI/usr/local/bin/charconv\fR binary +\fI/usr/local/man/man1/charconv.1\fR man page +.fi +.SH BUGS +(probably) +.SH RESTRICTIONS +Note: the text is not formatted. RTF output assumes ISO Latin-1 coding, +end-of-line markers are not changed. +.SH AUTHOR +Burkhard Kirste (kirste@chemie.fu-berlin.de) diff --git a/support/charconv/charstab.h b/support/charconv/charstab.h new file mode 100644 index 0000000000..aba7a31aa2 --- /dev/null +++ b/support/charconv/charstab.h @@ -0,0 +1,665 @@ +/* charstab + * @(#)Character tables. 1993/07/13 BKi + */ + +/* Character table of Atari ST */ +char *st_table[] = { + "\\000","\\001","\\002","\\003","\\004","\\005","\\006","\\007", + "\\010","\\011","\\012","\\013","\\014","\\015","\\016","\\017", + "\\020","\\021","\\022","\\023","\\024","\\025","\\026","\\027", + "\\030","\\031","\\032","\\033","\\034","\\035","\\036","\\037", + " ","!","\"","#","$","%","&","'", + "(",")","*","+",",","-",".","/", + "0","1","2","3","4","5","6","7", + "8","9",":",";","<","=",">","?", + "@","A","B","C","D","E","F","G", + "H","I","J","K","L","M","N","O", + "P","Q","R","S","T","U","V","W", + "X","Y","Z","[","\\{}","]","^","_", + "`","a","b","c","d","e","f","g", + "h","i","j","k","l","m","n","o", + "p","q","r","s","t","u","v","w", + "x","y","z","{","|","}","~","\\177", + "\\c{C}","\\\"u","\\'e","\\^a","\\\"a","\\`a","\\aa{}","\\c{c}", + "\\^e","\\\"e","\\`e","\\\"i","\\^i","\\`i","\\\"A","\\AA{}", + "\\'E","\\ae{}","\\AE{}","\\^o","\\\"o","\\`o","\\^u","\\`u", + "\\\"y","\\\"O","\\\"U","\\cents{}","\\pound{}","\\yen{}","\\ss{}", + "\\florin{}", + "\\'a","\\'i","\\'o","\\'u","\\~n","\\~N","\\b{a}","\\b{o}", + "\\?`","\\251","\\neg{}","\\onehalf{}","\\onequarter{}","\\!`","\\ll{}", + "\\gg{}", + "\\~a","\\~o","\\O{}","\\o{}","\\oe{}","\\OE{}","\\`A","\\~A", + "\\~O","\\\"_","\\'_","\\dagger{}","\\P{}","\\copyright{}", + "\\registered{}","\\trademark{}", + "\\300","\\301","\\302","\\303","\\304","\\305","\\306","\\307", + "\\310","\\311","\\312","\\313","\\314","\\315","\\316","\\317", + "\\320","\\321","\\322","\\323","\\324","\\325","\\326","\\327", + "\\330","\\331","\\332","\\333","\\334","\\S{}","\\336","\\infty{}", + "\\alpha{}","\\beta{}","\\Gamma{}","\\pi{}","\\Sigma{}","\\sigma{}","\\mu{}", + "\\tau{}", + "\\Phi{}","\\Theta{}","\\Omega{}","\\delta{}","\\354","\\phi{}", + "\\epsilon{}","\\cap{}", + "\\equiv{}","\\pm{}","\\ge{}","\\le{}","\\uint{}","\\lint{}","\\div{}", + "\\approx{}", + "\\degree{}","\\bullet{}","\\cdot{}","\\sqrt{}","\\nsuperior{}", + "\\twosuperior{}","\\threesuperior{}","\\377"}; + +/* 256 entries */ + +/* Character table of IBM PC DOS, international code page 437 */ +char *pc_table[] = { + "\\000","\\001","\\002","\\003","\\004","\\005","\\006","\\007", + "\\010","\\011","\\012","\\013","\\014","\\015","\\016","\\017", + "\\020","\\021","\\022","\\023","\\P{}","\\S{}","\\026","\\027", + "\\030","\\031","\\032","\\033","\\034","\\035","\\036","\\037", + " ","!","\"","#","$","%","&","'", + "(",")","*","+",",","-",".","/", + "0","1","2","3","4","5","6","7", + "8","9",":",";","<","=",">","?", + "@","A","B","C","D","E","F","G", + "H","I","J","K","L","M","N","O", + "P","Q","R","S","T","U","V","W", + "X","Y","Z","[","\\{}","]","^","_", + "`","a","b","c","d","e","f","g", + "h","i","j","k","l","m","n","o", + "p","q","r","s","t","u","v","w", + "x","y","z","{","|","}","~","\\177", + "\\c{C}","\\\"u","\\'e","\\^a","\\\"a","\\`a","\\aa{}","\\c{c}", + "\\^e","\\\"e","\\`e","\\\"i","\\^i","\\`i","\\\"A","\\AA{}", + "\\'E","\\ae{}","\\AE{}","\\^o","\\\"o","\\`o","\\^u","\\`u", + "\\\"y","\\\"O","\\\"U","\\cents{}","\\pound{}","\\yen{}","\\peseta{}", + "\\florin{}", + "\\'a","\\'i","\\'o","\\'u","\\~n","\\~N","\\b{a}","\\b{o}", + "\\?`","\\251","\\neg{}","\\onehalf{}","\\onequarter{}","\\!`","\\ll{}", + "\\gg{}", + "\\260","\\261","\\262","\\263","\\264","\\265","\\266","\\267", + "\\270","\\271","\\272","\\273","\\274","\\275","\\276","\\277", + "\\300","\\301","\\302","\\303","\\304","\\305","\\306","\\307", + "\\310","\\311","\\312","\\313","\\314","\\315","\\316","\\317", + "\\320","\\321","\\322","\\323","\\324","\\325","\\326","\\327", + "\\330","\\331","\\332","\\333","\\334","\\335","\\336","\\337", + "\\alpha{}","\\ss{}","\\Gamma{}","\\pi{}","\\Sigma{}","\\sigma{}","\\mu{}", + "\\tau{}", + "\\Phi{}","\\Theta{}","\\Omega{}","\\delta{}","\\infty{}","\\phi{}", + "\\epsilon{}","\\cap{}", + "\\equiv{}","\\pm{}","\\ge{}","\\le{}","\\uint{}","\\lint{}","\\div{}", + "\\approx{}", + "\\degree{}","\\bullet{}","\\cdot{}","\\sqrt{}","\\nsuperior{}", + "\\twosuperior{}","\\376","\\space{}"}; + +/* 256 entries */ + +/* Character table ANSI ISO latin1 (Unix) */ +char *iso_table[] = { + "\\000","\\001","\\002","\\003","\\004","\\005","\\006","\\007", + "\\010","\\011","\\012","\\013","\\014","\\015","\\016","\\017", + "\\020","\\021","\\022","\\023","\\024","\\025","\\026","\\027", + "\\030","\\031","\\032","\\033","\\034","\\035","\\036","\\037", + " ","!","\"","#","$","%","&","'", + "(",")","*","+",",","-",".","/", + "0","1","2","3","4","5","6","7", + "8","9",":",";","<","=",">","?", + "@","A","B","C","D","E","F","G", + "H","I","J","K","L","M","N","O", + "P","Q","R","S","T","U","V","W", + "X","Y","Z","[","\\{}","]","^","_", + "`","a","b","c","d","e","f","g", + "h","i","j","k","l","m","n","o", + "p","q","r","s","t","u","v","w", + "x","y","z","{","|","}","~","\\177", + "\\200","\\201","\\quotesinglbase{}","\\florin{}","\\quotedblbase{}", + "\\ldots{}","\\dagger{}","\\ddagger{}", + "\\^_","\\perthousand{}","\\v{S}","\\guilsinglleft{}","\\OE{}","\\215", + "\\216","\\217", + "\\220","\\quoteleft{}","\\quoteright{}","\\quotedblleft{}", + "\\quotedblright{}","\\bullet{}","\\endash{}","\\emdash{}", + "\\~_","\\trademark{}","\\v{s}","\\guilsinglright{}","\\oe{}","\\235", + "\\236","\\\"Y", + "\\space{}","\\!`","\\cents{}","\\pound{}","\\currency{}","\\yen{}", + "\\brokenbar{}","\\S{}", + "\\\"_","\\copyright{}","\\b{a}","\\ll{}","\\neg{}","\\hyphen{}", + "\\registered{}","\\=_", + "\\degree{}","\\pm{}","\\twosuperior{}","\\threesuperior{}","\\'_", + "\\mu{}","\\P{}","\\cdot{}", + "\\c{_}","\\onesuperior{}","\\b{o}","\\gg{}","\\onequarter{}","\\onehalf{}", + "\\threequarters{}","\\?`", + "\\`A","\\'A","\\^A","\\~A","\\\"A","\\AA{}","\\AE{}","\\c{C}", + "\\`E","\\'E","\\^E","\\\"E","\\`I","\\'I","\\^I","\\\"I", + "\\Eth{}","\\~N","\\`O","\\'O","\\^O","\\~O","\\\"O","\\times{}", + "\\O{}","\\`U","\\'U","\\^U","\\\"U","\\'Y","\\Thorn{}","\\ss{}", + "\\`a","\\'a","\\^a","\\~a","\\\"a","\\aa{}","\\ae{}","\\c{c}", + "\\`e","\\'e","\\^e","\\\"e","\\`i","\\'i","\\^i","\\\"i", + "\\eth{}","\\~n","\\`o","\\'o","\\^o","\\~o","\\\"o","\\div{}", + "\\o{}","\\`u","\\'u","\\^u","\\\"u","\\'y","\\thorn{}","\\\"y"}; + +/* 256 entries */ + +/* character table of Apple Macintosh */ +char *mac_table[] = { + "\\000","\\001","\\002","\\003","\\004","\\005","\\006","\\007", + "\\010","\\011","\\012","\\013","\\014","\\015","\\016","\\017", + "\\020","\\021","\\022","\\023","\\024","\\025","\\026","\\027", + "\\030","\\031","\\032","\\033","\\034","\\035","\\036","\\037", + " ","!","\"","#","$","%","&","'", + "(",")","*","+",",","-",".","/", + "0","1","2","3","4","5","6","7", + "8","9",":",";","<","=",">","?", + "@","A","B","C","D","E","F","G", + "H","I","J","K","L","M","N","O", + "P","Q","R","S","T","U","V","W", + "X","Y","Z","[","\\{}","]","^","_", + "`","a","b","c","d","e","f","g", + "h","i","j","k","l","m","n","o", + "p","q","r","s","t","u","v","w", + "x","y","z","{","|","}","~","\\177", + "\\\"A","\\AA{}","\\c{C}","\\'E","\\~N","\\\"O","\\\"U","\\'a", + "\\`a","\\^a","\\\"a","\\~a","\\aa{}","\\c{c}","\\'e","\\`e", + "\\^e","\\\"e","\\'i","\\`i","\\^i","\\\"i","\\~n","\\'o", + "\\`o","\\^o","\\\"o","\\~o","\\'u","\\`u","\\^u","\\\"u", + "\\dagger{}","\\degree{}","\\cents{}","\\pound{}","\\S{}","\\bullet{}", + "\\P{}","\\ss{}", + "\\registered{}","\\copyright{}","\\trademark{}","\\'_","\\\"_", + "\\ne{}","\\AE{}","\\O{}", + "\\infty{}","\\pm{}","\\le{}","\\ge{}","\\yen{}","\\mu{}","\\partial{}", + "\\Sigma{}", + "\\Pi{}","\\Pi{}","\\int{}","\\b{a}","\\b{o}","\\Omega{}","\\ae{}","\\o{}", + "\\?`","\\!`","\\neg{}","\\sqrt{}","\\florin{}","\\approx{}","\\Delta{}", + "\\ll{}", + "\\gg{}","\\ldots{}","\\space{}","\\`A","\\~A","\\~O","\\OE{}","\\oe{}", + "\\endash{}","\\emdash{}","\\quotedblleft{}","\\quotedblright{}", + "\\quoteleft{}","\\quoteright{}","\\div{}","\\diamond{}", + "\\\"y","\\\"Y","/","\\333","\\guilsinglleft{}","\\guilsinglright{}", + "\\fi{}","\\fl{}", + "\\ddagger{}","\\cdot{}","\\quotesinglbase{}","\"","\\perthousand{}", + "\\^A","\\^E","\\'A", + "\\\"E","\\`E","\\'I","\\^I","\\\"I","\\`I","\\'O","\\^O", + "\\360","\\`O","\\'U","\\^U","\\`U","\\oldstyleone{}","\\^_","\\~_", + "\\=_","\\u{_}","\\._","\\373","\\c{_}","\\H{_}","\\376","\\v{_}"}; + +/* 256 entries */ + +/* Symbol character table */ +char *sym_table[] = { + "\\000","\\001","\\002","\\003","\\004","\\005","\\006","\\007", + "\\010","\\011","\\012","\\013","\\014","\\015","\\016","\\017", + "\\020","\\021","\\022","\\023","\\024","\\025","\\026","\\027", + "\\030","\\031","\\032","\\033","\\034","\\035","\\036","\\037", + " ","!","\\forall{}","#","\\exists{}","%","&","\\ni{}", + "(",")","\\ast{}","+",",","-",".","/", + "0","1","2","3","4","5","6","7", + "8","9",":",";","<","=",">","?", + "\\cong{}","A","B","X","\\Delta{}","E","\\Phi{}","\\Gamma{}", + "H","I","\\vartheta{}","K","\\Lambda{}","M","N","O", + "\\Pi{}","\\Theta{}","P","\\Sigma{}","T","Y","\\varsigma{}","\\Omega{}", + "\\Xi{}","\\Psi{}","Z","[","\\therefore{}","]","\\perp{}","_", + "\\dashsuperior{}","\\alpha{}","\\beta{}","\\chi{}","\\delta{}", + "\\varepsilon{}","\\phi{}","\\gamma{}", + "\\eta{}","\\iota{}","\\varphi{}","\\kappa{}","\\lambda{}","\\mu{}","\\nu{}", + "o", + "\\pi{}","\\theta{}","\\rho{}","\\sigma{}","\\tau{}","\\upsilon{}", + "\\varpi{}","\\omega{}", + "\\xi{}","\\psi{}","\\zeta{}","{","|","}","\\sim{}","\\177", + "\\200","\\201","\\202","\\203","\\204","\\205","\\206","\\207", + "\\210","\\211","\\212","\\213","\\214","\\215","\\216","\\217", + "\\220","\\221","\\222","\\223","\\224","\\225","\\226","\\227", + "\\230","\\231","\\232","\\233","\\234","\\235","\\236","\\237", + "\\240","\\Upsilon{}","'","\\le{}","/","\\infty{}","\\florin{}", + "\\clubsuit{}", + "\\diamondsuit{}","\\heartsuit{}","\\spadesuit{}","\\leftrightarrow{}", + "\\leftarrow{}","\\uparrow{}","\\rightarrow{}","\\downarrow{}", + "\\degree{}","\\pm{}","\"","\\ge{}","\\times{}","\\propto{}","\\partial{}", + "\\bullet{}", + "\\div{}","\\ne{}","\\equiv{}","\\approx{}","\\dots{}","|","\\endash{}", + "\\hookleftarrow{}", + "\\aleph{}","\\Im{}","\\Re{}","\\wp{}","\\otimes{}","\\oplus{}", + "\\emptyset{}","\\cap{}", + "\\cup{}","\\supset{}","\\supseteq{}","\\notsubset{}","\\subset{}", + "\\subseteq{}","\\in{}","\\notin{}", + "\\angle{}","\\nabla{}","\\registered{}","\\copyright{}","\\trademark{}", + "\\prod{}","\\sqrt{}","\\cdot{}", + "\\neg{}","\\wedge{}","\\vee{}","\\Leftrightarrow{}","\\Leftarrow{}", + "\\Uparrow{}","\\Rightarrow{}","\\Downarrow{}", + "\\diamond{}","\\langle{}","\\registered{}","\\copyright{}","\\trademark{}", + "\\sum{}","\\346","\\347", + "\\350","\\351","\\352","\\353","\\354","\\355","\\356","\\357", + "\\360","\\rangle{}","\\int{}","\\363","\\364","\\365","\\366","\\367", + "\\370","\\371","\\372","\\373","\\374","\\375","\\376","\\cong{}"}; + +/* 256 entries */ + +/* string conversion: + * transcript, TeX, HTML, plain-ASCII *** TODO *** + */ +#define TRANS_ROW 318 /* number of entries (lines) */ +#define TRANS_COL 4 /* number of types (columns) */ +char *trans_string[TRANS_ROW][TRANS_COL] = { + {" "," "," "," "}, + {"!","!","!","!"}, + {"\"","''","\"","\""}, + {"#","\\#","#","#"}, + {"$","\\$","$","$"}, + {"%","\\%","%","%"}, + {"&","\\&","&","&"}, + {"'","'","'","'"}, + {"(","(","(","("}, + {")",")",")",")"}, + {"*","*","*","*"}, + {"+","+","+","+"}, + {",",",",",",","}, + {"-","-","-","-"}, + {".",".",".","."}, + {"/","/","/","/"}, + {"0","0","0","0"}, + {"1","1","1","1"}, + {"2","2","2","2"}, + {"3","3","3","3"}, + {"4","4","4","4"}, + {"5","5","5","5"}, + {"6","6","6","6"}, + {"7","7","7","7"}, + {"8","8","8","8"}, + {"9","9","9","9"}, + {":",":",":",":"}, + {";",";",";",";"}, + {"<","$<$","<","<"}, + {"=","=","=","="}, + {">","$>$",">",">"}, + {"?","?","?","?"}, + {"@","@","@","@"}, + {"A","A","A","A"}, + {"B","B","B","B"}, + {"C","C","C","C"}, + {"D","D","D","D"}, + {"E","E","E","E"}, + {"F","F","F","F"}, + {"G","G","G","G"}, + {"H","H","H","H"}, + {"I","I","I","I"}, + {"J","J","J","J"}, + {"K","K","K","K"}, + {"L","L","L","L"}, + {"M","M","M","M"}, + {"N","N","N","N"}, + {"O","O","O","O"}, + {"P","P","P","P"}, + {"Q","Q","Q","Q"}, + {"R","R","R","R"}, + {"S","S","S","S"}, + {"T","T","T","T"}, + {"U","U","U","U"}, + {"V","V","V","V"}, + {"W","W","W","W"}, + {"X","X","X","X"}, + {"Y","Y","Y","Y"}, + {"Z","Z","Z","Z"}, + {"[","[","[","["}, + {"\\{}","$\\backslash$","\\","\\"}, + {"]","]","]","]"}, + {"^","\\^{ }","^","^"}, + {"_","\\_","_","_"}, + {"`","`","`","`"}, + {"a","a","a","a"}, + {"b","b","b","b"}, + {"c","c","c","c"}, + {"d","d","d","d"}, + {"e","e","e","e"}, + {"f","f","f","f"}, + {"g","g","g","g"}, + {"h","h","h","h"}, + {"i","i","i","i"}, + {"j","j","j","j"}, + {"k","k","k","k"}, + {"l","l","l","l"}, + {"m","m","m","m"}, + {"n","n","n","n"}, + {"o","o","o","o"}, + {"p","p","p","p"}, + {"q","q","q","q"}, + {"r","r","r","r"}, + {"s","s","s","s"}, + {"t","t","t","t"}, + {"u","u","u","u"}, + {"v","v","v","v"}, + {"w","w","w","w"}, + {"x","x","x","x"}, + {"y","y","y","y"}, + {"z","z","z","z"}, + {"{","$\\{$","{","{"}, + {"|","$|$","|","|"}, + {"}","$\\}$","}","}"}, + {"~","\\~{ }","~","~"}, + {"\\quotesinglbase{}",",",",",","}, + {"\\quotedblbase{}",",,","\"","\""}, + {"\\quoteleft{}","`","`","`"}, + {"\\quoteright{}","'","'","'"}, + {"\\quotedblleft{}","``","\"","\""}, + {"\\quotedblright{}","''","\"","\""}, + {"\\guilsinglleft{}","$<$","<","<"}, + {"\\guilsinglright{}","$>$",">",">"}, + {"\\bullet{}","$\\bullet$","*","*"}, + {"\\endash{}","{}--{}","-","-"}, + {"\\emdash{}","{}---{}","-","-"}, + {"\\ldots{}","$\\ldots$","...","..."}, + {"\\dagger{}","$\\dagger$","+","+"}, + {"\\ddagger{}","$\\ddagger$","#","#"}, + {"\\perthousand{}","$^o/_{oo}$","o/oo","o/oo"}, + {"\\florin{}","$f$","f","f"}, + {"\\trademark{}","$^{TM}$","(TM)","(TM)"}, + {"\\copyright{}","\\copyright{}","(C)","(C)"}, + {"\\registered{}","(R)","(R)","(R)"}, + {"\\cents{}"," cents ","cents","cents"}, + {"\\pound{}","{\\it\\$}","pound","pound"}, + {"\\currency{}"," currency ","(currency)","<currency>"}, + {"\\yen{}"," yen ","yen","yen"}, + {"\\brokenbar{}","$|$","|","|"}, + {"\\b{a}","\\b{a}","na.","na."}, + {"\\b{o}","\\b{o}","no.","no."}, + {"\\ll{}","$\\ll$","<<","<<"}, + {"\\gg{}","$\\gg$",">>",">>"}, + {"\\neg{}","$\\neg$","(neg)","<neg>"}, + {"\\hyphen{}","{}---{}","-","-"}, + {"\\degree{}","$^\\circ$","^o","^o"}, + {"\\pm{}","$\\pm$","+-","+-"}, + {"\\times{}","$\\times$","x","x"}, + {"\\div{}","$\\div$","/","/"}, + {"\\cdot{}","$\\cdot$","*","*"}, + {"\\P{}","\\P{}","(par)","<par>"}, + {"\\S{}","\\S{}","(sect)","<sect>"}, + {"\\Eth{}","Eth","Ð","Eth"}, + {"\\Thorn{}","Thorn","Þ","Thorn"}, + {"\\eth{}","eth","ð","eth"}, + {"\\thorn{}","thorn","þ","thorn"}, + {"\\onequarter{}","$^1/_4$","1/4","1/4"}, + {"\\onehalf{}","$^1/_2$","1/2","1/2"}, + {"\\threequarters{}","$^3/_4$","3/4","3/4"}, + {"\\onesuperior{}","$^1$","^1","^1"}, + {"\\twosuperior{}","$^2$","^2","^2"}, + {"\\threesuperior{}","$^3$","^3","^3"}, + {"\\space{}","\\space{}"," "," "}, + {"\\cong{}","$\\cong$","(cong)","<cong>"}, + {"\\therefore{}","$.\\!\\cdot\\!.$","(therefore)","<therefore>"}, + {"\\perp{}","$\\perp$","(perp)","<perp>"}, + {"\\dashsuperior{}","$^-$","^-","^-"}, + {"\\forall{}","$\\forall$","(forall)","<forall>"}, + {"\\exists{}","$\\exists$","(exists)","<exists>"}, + {"\\ni{}","$\\ni$","(ni)","<ni>"}, + {"\\ast{}","$\\ast$","*","*"}, + {"\\sim{}","$\\sim$","~","~"}, + {"\\le{}","$\\le$","<=","<="}, + {"\\ge{}","$\\ge$",">=",">="}, + {"\\infty{}","$\\infty$","(infty)","<infty>"}, + {"\\clubsuit{}","$\\clubsuit$","(clubsuit)","<clubsuit>"}, + {"\\diamondsuit{}","$\\diamondsuit$","(diamondsuit)","<diamondsuit>"}, + {"\\heartsuit{}","$\\heartsuit$","(heartsuit)","<heartsuit>"}, + {"\\spadesuit{}","$\\spadesuit$","(spadesuit)","<spadesuit>"}, + {"\\leftrightarrow{}","$\\leftrightarrow$","$lt;-$gt;","<->"}, + {"\\leftarrow{}","$\\leftarrow$","$lt;-","<-"}, + {"\\uparrow{}","$\\uparrow$","^","^"}, + {"\\rightarrow{}","$\\rightarrow$","-$gt;","->"}, + {"\\downarrow{}","$\\downarrow$","v","v"}, + {"\\propto{}","$\\propto$","(propto)","<propto>"}, + {"\\partial{}","$\\partial$","(partial)","<partial>"}, + {"\\ne{}","$\\ne$","=/=","=/="}, + {"\\equiv{}","$\\equiv$","(equiv)","<equiv>"}, + {"\\approx{}","$\\approx$","(approx)","<approx>"}, + {"\\dots{}","$\\dots$","(dots)","<dots>"}, + {"\\hookleftarrow{}","$\\hookleftarrow$","<-'","<-'"}, + {"\\aleph{}","$\\aleph$","(aleph)","<aleph>"}, + {"\\Im{}","$\\Im$","(Im)","<Im>"}, + {"\\Re{}","$\\Re$","(Re)","<Re>"}, + {"\\wp{}","$\\wp$","p","p"}, + {"\\otimes{}","$\\otimes$","x","x"}, + {"\\oplus{}","$\\oplus$","+","+"}, + {"\\emptyset{}","$\\emptyset$","(emptyset)","<emptyset>"}, + {"\\cap{}","$\\cap$","(cap)","<cap>"}, + {"\\cup{}","$\\cup$","(cup)","<cup>"}, + {"\\supset{}","$\\supset$","(supset)","<supset>"}, + {"\\supseteq{}","$\\supseteq$","(supseteq)","<supseteq>"}, + {"\\notsubset{}","$\\not\\subset$","(notsubset)","<notsubset>"}, + {"\\subset{}","$\\subset$","(subset)","<subset>"}, + {"\\subseteq{}","$\\subseteq$","(subseteq)","<subseteq>"}, + {"\\in{}","$\\in$","(in)","<in>"}, + {"\\notin{}","$\\not\\in$","(notin)","<notin>"}, + {"\\angle{}","$\\angle$","(angle)","<angle>"}, + {"\\nabla{}","$\\nabla$","(nabla)","<nabla>"}, + {"\\prod{}","$\\prod$","(prod)","<prod>"}, + {"\\sqrt{}","$\\sqrt{}$","(sqrt)","<sqrt>"}, + {"\\wedge{}","$\\wedge$","^","^"}, + {"\\vee{}","$\\vee$","v","v"}, + {"\\Leftrightarrow{}","$\\Leftrightarrow$","<=>","<=>"}, + {"\\Leftarrow{}","$\\Leftarrow$","<=","<="}, + {"\\Uparrow{}","$\\Uparrow$","^","^"}, + {"\\Rightarrow{}","$\\Rightarrow$","=>","=>"}, + {"\\Downarrow{}","$\\Downarrow$","v","v"}, + {"\\diamond{}","$\\diamond$","(diamond)","<diamond>"}, + {"\\langle{}","$\\langle$","<","<"}, + {"\\rangle{}","$\\rangle$",">",">"}, + {"\\sum{}","$\\sum$","(sum)","<sum>"}, + {"\\int{}","$\\int$","(int)","<int>"}, + {"\\oldstyleone{}","$\\oldstyle1$","1","1"}, + {"\\!`","!`","!`","!`"}, + {"\\?`","?`","?`","?`"}, + {"\\^_","\\^{ }","^","^"}, + {"\\~_","\\~{ }","~","~"}, + {"\\\"_","\\\"{ }","\"","\""}, + {"\\=_","\\={ }","=","="}, + {"\\'_","\\'{ }","'","'"}, + {"\\._","\\.{ }",".","."}, + {"\\H{_}","\\H{ }","\"","\""}, + {"\\c{_}","\\c{ }",",",","}, + {"\\u{_}","\\u{ }","u","u"}, + {"\\v{_}","\\v{ }","v","v"}, + {"\\`A","\\`A","À","A"}, + {"\\'A","\\'A","Á","A"}, + {"\\^A","\\^A","Â","A"}, + {"\\~A","\\~A","Ã","A"}, + {"\\\"A","\\\"A","Ä","Ae"}, + {"\\AA{}","\\AA{}","Å","AA"}, + {"\\AE{}","\\AE{}","Æ","AE"}, + {"\\c{C}","\\c{C}","Ç","C"}, + {"\\`E","\\`E","È","E"}, + {"\\'E","\\'E","É","E"}, + {"\\^E","\\^E","Ê","E"}, + {"\\\"E","\\\"E","Ë","E"}, + {"\\`I","\\`I","Ì","I"}, + {"\\'I","\\'I","Í","I"}, + {"\\^I","\\^I","Î","I"}, + {"\\\"I","\\\"I","Ï","I"}, + {"\\~N","\\~N","Ñ","N"}, + {"\\`O","\\`O","Ò","O"}, + {"\\'O","\\'O","Ó","O"}, + {"\\^O","\\^O","Ô","O"}, + {"\\~O","\\~O","Õ","O"}, + {"\\\"O","\\\"O","Ö","Oe"}, + {"\\O{}","\\O{}","Ø","Oe"}, + {"\\OE{}","\\OE{}","OE","OE"}, + {"\\v{S}","\\v{S}","S","S"}, + {"\\`U","\\`U","Ù","U"}, + {"\\'U","\\'U","Ú","U"}, + {"\\^U","\\^U","Û","U"}, + {"\\\"U","\\\"U","Ü","Ue"}, + {"\\'Y","\\'Y","Ý","Y"}, + {"\\\"Y","\\\"Y","Y","Y"}, + {"\\`a","\\`a","à","a"}, + {"\\'a","\\'a","á","a"}, + {"\\^a","\\^a","â","a"}, + {"\\~a","\\~a","ã","a"}, + {"\\\"a","\\\"a","ä","ae"}, + {"\\aa{}","\\aa{}","å","aa"}, + {"\\ae{}","\\ae{}","æ","ae"}, + {"\\c{c}","\\c{c}","ç","c"}, + {"\\`e","\\`e","è","e"}, + {"\\'e","\\'e","é","e"}, + {"\\^e","\\^e","ê","e"}, + {"\\\"e","\\\"e","ë","e"}, + {"\\`i","\\`{\\i}","ì","i"}, + {"\\'i","\\'{\\i}","í","i"}, + {"\\^i","\\^{\\i}","î","i"}, + {"\\\"i","\\\"{\\i}","ï","i"}, + {"\\~n","\\~n","ñ","n"}, + {"\\`o","\\`o","ò","o"}, + {"\\'o","\\'o","ó","o"}, + {"\\^o","\\^o","ô","o"}, + {"\\~o","\\~o","õ","o"}, + {"\\\"o","\\\"o","ö","oe"}, + {"\\o{}","\\o{}","ø","oe"}, + {"\\oe{}","\\oe{}","oe","oe"}, + {"\\ss{}","\\ss{}","ß","ss"}, + {"\\v{s}","\\v{s}","s","s"}, + {"\\`u","\\`u","ù","u"}, + {"\\'u","\\'u","ú","u"}, + {"\\^u","\\^u","û","u"}, + {"\\\"u","\\\"u","ü","ue"}, + {"\\'y","\\'y","ý","y"}, + {"\\\"y","\\\"y","ÿ","y"}, + {"\\Delta{}","$\\Delta$","Delta","Delta"}, + {"\\Phi{}","$\\Phi$","Phi","Phi"}, + {"\\Gamma{}","$\\Gamma$","Gamma","Gamma"}, + {"\\Lambda{}","$\\Lambda$","Lambda","Lambda"}, + {"\\Pi{}","$\\Pi$","Pi","Pi"}, + {"\\Theta{}","$\\Theta$","Theta","Theta"}, + {"\\Sigma{}","$\\Sigma$","Sigma","Sigma"}, + {"\\Omega{}","$\\Omega$","Omega","Omega"}, + {"\\Xi{}","$\\Xi$","Xi","Xi"}, + {"\\Psi{}","$\\Psi$","Psi","Psi"}, + {"\\Upsilon{}","$\\Upsilon$","Upsilon","Upsilon"}, + {"\\alpha{}","$\\alpha$","alpha","alpha"}, + {"\\beta{}","$\\beta$","beta","beta"}, + {"\\chi{}","$\\chi$","chi","chi"}, + {"\\delta{}","$\\delta$","delta","delta"}, + {"\\epsilon{}","$\\epsilon$","epsilon","epsilon"}, + {"\\varepsilon{}","$\\varepsilon$","epsilon","epsilon"}, + {"\\phi{}","$\\phi$","phi","phi"}, + {"\\varphi{}","$\\varphi$","phi","phi"}, + {"\\gamma{}","$\\gamma$","gamma","gamma"}, + {"\\eta{}","$\\eta$","eta","eta"}, + {"\\iota{}","$\\iota$","iota","iota"}, + {"\\kappa{}","$\\kappa$","kappa","kappa"}, + {"\\lambda{}","$\\lambda$","lambda","lambda"}, + {"\\mu{}","$\\mu$","mu","mu"}, + {"\\nu{}","$\\nu$","nu","nu"}, + {"\\pi{}","$\\pi$","pi","pi"}, + {"\\varpi{}","$\\varpi$","pi","pi"}, + {"\\theta{}","$\\theta$","theta","theta"}, + {"\\vartheta{}","$\\vartheta$","theta","theta"}, + {"\\rho{}","$\\rho$","rho","rho"}, + {"\\sigma{}","$\\sigma$","sigma","sigma"}, + {"\\varsigma{}","$\\varsigma$","sigma","sigma"}, + {"\\tau{}","$\\tau$","tau","tau"}, + {"\\upsilon{}","$\\upsilon$","upsilon","upsilon"}, + {"\\omega{}","$\\omega$","omega","omega"}, + {"\\xi{}","$\\xi$","xi","xi"}, + {"\\psi{}","$\\psi$","psi","psi"}, + {"\\zeta{}","$\\zeta$","zeta","zeta"} +}; /* trans_string */ + +/* Rich Text Format (RTF) table */ +char *rtf_table[] = { + "\\'00","\\'01","\\'02","\\'03","\\'04","\\'05","\\'06","\\'07", + "\\'08","\\'09","\\'0a","\\'0b","\\'0c","\\'0d","\\'0e","\\'0f", + "\\'10","\\'11","\\'12","\\'13","\\'14","\\'15","\\'16","\\'17", + "\\'18","\\'19","\\'1a","\\'1b","\\'1c","\\'1d","\\'1e","\\'1f", + " ","!","\"","#","$","%","&","'", + "(",")","*","+",",","-",".","/", + "0","1","2","3","4","5","6","7", + "8","9",":",";","<","=",">","?", + "@","A","B","C","D","E","F","G", + "H","I","J","K","L","M","N","O", + "P","Q","R","S","T","U","V","W", + "X","Y","Z","[","\\\\","]","^","_", + "`","a","b","c","d","e","f","g", + "h","i","j","k","l","m","n","o", + "p","q","r","s","t","u","v","w", + "x","y","z","{","|","}","~","\\'7f", + "\\'80","\\'81","\\'82","\\'83","\\'84","\\'85","\\'86","\\'87", + "\\'88","\\'89","\\'8a","\\'8b","\\'8c","\\'8d","\\'8e","\\'8f", + "\\'90","\\'91","\\'92","\\'93","\\'94","\\'95","\\'96","\\'97", + "\\'98","\\'99","\\'9a","\\'9b","\\'9c","\\'9d","\\'9e","\\'9f", + "\\'a0","\\'a1","\\'a2","\\'a3","\\'a4","\\'a5","\\'a6","\\'a7", + "\\'a8","\\'a9","\\'aa","\\'ab","\\'ac","\\'ad","\\'ae","\\'af", + "\\'b0","\\'b1","\\'b2","\\'b3","\\'b4","\\'b5","\\'b6","\\'b7", + "\\'b8","\\'b9","\\'ba","\\'bb","\\'bc","\\'bd","\\'be","\\'bf", + "\\'c0","\\'c1","\\'c2","\\'c3","\\'c4","\\'c5","\\'c6","\\'c7", + "\\'c8","\\'c9","\\'ca","\\'cb","\\'cc","\\'cd","\\'ce","\\'cf", + "\\'d0","\\'d1","\\'d2","\\'d3","\\'d4","\\'d5","\\'d6","\\'d7", + "\\'d8","\\'d9","\\'da","\\'db","\\'dc","\\'dd","\\'de","\\'df", + "\\'e0","\\'e1","\\'e2","\\'e3","\\'e4","\\'e5","\\'e6","\\'e7", + "\\'e8","\\'e9","\\'ea","\\'eb","\\'ec","\\'ed","\\'ee","\\'ef", + "\\'f0","\\'f1","\\'f2","\\'f3","\\'f4","\\'f5","\\'f6","\\'f7", + "\\'f8","\\'f9","\\'fa","\\'fb","\\'fc","\\'fd","\\'fe","\\'ff"}; + +/* 256 entries */ + +/* ASCII to EBCDIC */ +char asc2ebc[] = { + 0x00,0x01,0x02,0x03,0x37,0x2d,0x2e,0x2f, + 0x16,0x05,0x25,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x10,0x11,0x12,0x13,0x3c,0x3d,0x32,0x26, + 0x18,0x19,0x3f,0x27,0x1c,0x1d,0x1e,0x1f, + 0x40,0x4f,0x7f,0x7b,0x5b,0x6c,0x50,0x7d, + 0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x4b,0x61, + 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7, + 0xf8,0xf9,0x7a,0x5e,0x4c,0x7e,0x6e,0x6f, + 0x7c,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, + 0xc8,0xc9,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6, + 0xd7,0xd8,0xd9,0xe2,0xe3,0xe4,0xe5,0xe6, + 0xe7,0xe8,0xe9,0x4a,0xe0,0x5a,0x5f,0x6d, + 0x79,0x81,0x82,0x83,0x84,0x85,0x86,0x87, + 0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96, + 0x97,0x98,0x99,0xa2,0xa3,0xa4,0xa5,0xa6, + 0xa7,0xa8,0xa9,0xc0,0x6a,0xd0,0xa1,0x07, + 0x20,0x21,0x22,0x23,0x24,0x15,0x06,0x17, + 0x28,0x29,0x2a,0x2b,0x2c,0x09,0x0a,0x1b, + 0x30,0x31,0x1a,0x33,0x34,0x35,0x36,0x08, + 0x38,0x39,0x3a,0x3b,0x04,0x14,0x3e,0xe1, + 0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48, + 0x49,0x51,0x52,0x53,0x54,0x55,0x56,0x57, + 0x58,0x59,0x62,0x63,0x64,0x65,0x66,0x67, + 0x68,0x69,0x70,0x71,0x72,0x73,0x74,0x75, + 0x76,0x77,0x78,0x80,0x8a,0x8b,0x8c,0x8d, + 0x8e,0x8f,0x90,0x9a,0x9b,0x9c,0x9d,0x9e, + 0x9f,0xa0,0xaa,0xab,0xac,0xad,0xae,0xaf, + 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7, + 0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, + 0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xda,0xdb, + 0xdc,0xdd,0xde,0xdf,0xea,0xeb,0xec,0xed, + 0xee,0xef,0xfa,0xfb,0xfc,0xfd,0xfe,0xff}; + +/* 256 entries */ + +/* EBCDIC to ASCII */ +char ebc2asc[] = { + 0x00,0x01,0x02,0x03,0x9c,0x09,0x86,0x7f, + 0x97,0x8d,0x8e,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x10,0x11,0x12,0x13,0x9d,0x85,0x08,0x87, + 0x18,0x19,0x92,0x8f,0x1c,0x1d,0x1e,0x1f, + 0x80,0x81,0x82,0x83,0x84,0x0a,0x17,0x1b, + 0x88,0x89,0x8a,0x8b,0x8c,0x05,0x06,0x07, + 0x90,0x91,0x16,0x93,0x94,0x95,0x96,0x04, + 0x98,0x99,0x9a,0x9b,0x14,0x15,0x9e,0x1a, + 0x20,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6, + 0xa7,0xa8,0x5b,0x2e,0x3c,0x28,0x2b,0x21, + 0x26,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, + 0xb0,0xb1,0x5d,0x24,0x2a,0x29,0x3b,0x5e, + 0x2d,0x2f,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7, + 0xb8,0xb9,0x7c,0x2c,0x25,0x5f,0x3e,0x3f, + 0xba,0xbb,0xbc,0xbd,0xbe,0xbf,0xc0,0xc1, + 0xc2,0x60,0x3a,0x23,0x40,0x27,0x3d,0x22, + 0xc3,0x61,0x62,0x63,0x64,0x65,0x66,0x67, + 0x68,0x69,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9, + 0xca,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70, + 0x71,0x72,0xcb,0xcc,0xcd,0xce,0xcf,0xd0, + 0xd1,0x7e,0x73,0x74,0x75,0x76,0x77,0x78, + 0x79,0x7a,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7, + 0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, + 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7, + 0x7b,0x41,0x42,0x43,0x44,0x45,0x46,0x47, + 0x48,0x49,0xe8,0xe9,0xea,0xeb,0xec,0xed, + 0x7d,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50, + 0x51,0x52,0xee,0xef,0xf0,0xf1,0xf2,0xf3, + 0x5c,0x9f,0x53,0x54,0x55,0x56,0x57,0x58, + 0x59,0x5a,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9, + 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, + 0x38,0x39,0xfa,0xfb,0xfc,0xfd,0xfe,0xff}; + +/* 256 entries */ diff --git a/support/charconv/getopt.c b/support/charconv/getopt.c new file mode 100644 index 0000000000..f9dedb09c2 --- /dev/null +++ b/support/charconv/getopt.c @@ -0,0 +1,88 @@ +/* @(#)getopt + * parse command options + * originally from comp.sources.unix/volume3/att_getopt + * BKi 1993/07/04 + */ + +/* +* int getopt PROTO((int argc, char **argv, char *opts)); +* argc: number of parameters passed +* argv[]: parameter string +* opts: string of allowed parameters, +* followed by ':' if argument required +* return option (or EOF) +* (option argument in: char *optarg) +* +* global: char *optarg: argument +* int optind: number of argument +* int optopt +* +* extern int strcmp(); +* extern char *strchr(); +*/ +#include "sys_def.h" +#include <string.h> + +#ifndef EOF +#define EOF -1 +#endif +#ifndef NULL +#define NULL 0L +#endif + +int optind = 1; +int optopt; +char *optarg; + +int +getopt(argc, argv, opts) + int argc; + char **argv, *opts; +{ + static int sp = 1; + register int c; + register char *cp; + + if (sp == 1) + if (optind >= argc || + argv[optind][0] != '-' || argv[optind][1] == '\0') + return (EOF); + else if (strcmp(argv[optind], "--") == 0) + { + optind++; + return (EOF); + } + optopt = c = argv[optind][sp]; + if (c == ':' || (cp = strchr(opts, c)) == NULL) + { + fprintf(stderr, "%c: illegal option -- \n", c); + if (argv[optind][++sp] == '\0') + { + optind++; + sp = 1; + } + return ('?'); + } + if (*++cp == ':') + { + if (argv[optind][sp + 1] != '\0') + optarg = &argv[optind++][sp + 1]; + else if (++optind >= argc) + { + fprintf(stderr, "%c: option requires an argument -- \n", c); + sp = 1; + return ('?'); + } else + optarg = argv[optind++]; + sp = 1; + } else + { + if (argv[optind][++sp] == '\0') + { + sp = 1; + optind++; + } + optarg = NULL; + } + return (c); +} /* getopt */ diff --git a/support/charconv/sys_def.h b/support/charconv/sys_def.h new file mode 100644 index 0000000000..2252b1ae02 --- /dev/null +++ b/support/charconv/sys_def.h @@ -0,0 +1,55 @@ +/* stdio and system definition. 1993/04/23 BKi */ +#ifndef SYS_DEF_H +#define SYS_DEF_H +#include <stdio.h> +#ifdef __TURBOC__ +#define __ANSI +#ifdef __TOS__ +#define __ATARI +#else +#define __PC +#endif /* __TOS__ */ +#else +#ifdef _STDIO_ +#define __MIPS +#define __UNIX +#else +#ifdef _H_STDIO +#define __RS6000 +#define __UNIX +#else +#ifdef _h_STDIO +#define __RT +#define __UNIX +#else +#ifdef sun +#define __UNIX +#else +#ifdef sgi +#define __UNIX +#define __ANSI +#else +#ifdef ns32000 +#define __UNIX +#define __X32 +#else +/* #ifdef __FILE */ +#ifdef __STDIO_LOADED +#define __VAX +#define __ANSI +#else +#define __UNIX +#endif /* __FILE __VAX */ +#endif /* X32 */ +#endif /* sgi */ +#endif /* sun */ +#endif /* _h_STDIO __RT */ +#endif /* _H_STDIO __RS6000 */ +#endif /* _STDIO_ __MIPS */ +#endif /* __TURBOC__ */ +#ifndef __ANSI +#ifdef __GNUC__ +#define __ANSI +#endif +#endif /* gcc */ +#endif /* SYS_DEF_H */ |