/* translit.c -- transliterate a file */ #include #include #include "ios.h" /* using the input/output service module */ #define MAX_LENGTH 40 #define ERR_LINE_SIZE 1 #define ERR_LEN_DIFF 2 static char From [MAX_LENGTH]; static char To [MAX_LENGTH]; static char Table [256]; void main ( int argc, char * argv [] ) { int k, n; char c; int len; char * from; FILE * outfile; if ( argc < 5 ) err_command_line ( "translit fromline toline infile outfile" ); open_input_file ( argv [1] ); n = get_line_sure ( & from ); k = 0; while ( --n >= 0 ) { c = *from++; if ( (signed char) c < 0 || ! isascii ( c ) || ! isspace ( c ) ) { if ( k < MAX_LENGTH ) From [k++] = c; else { printf ( "too long fromline: exceeds %d\n", MAX_LENGTH ); exit ( ERR_LINE_SIZE ); } } } len = k; open_input_file ( argv [2] ); n = get_line_sure ( & from ); k = 0; while ( --n >= 0 ) { c = *from++; if ( (signed char) c < 0 || ! isascii ( c ) || ! isspace ( c ) ) { if ( k < MAX_LENGTH ) To [k++] = c; else { printf ( "too long toline: exceeds %d\n", MAX_LENGTH ); exit ( ERR_LINE_SIZE ); } } } if ( k != len ) { printf ( "fromline is of length %d whereas toline is of length %d\n", len, k ); exit ( ERR_LEN_DIFF ); } for ( k=0; k<256; k++ ) Table [k] = (char) k; for ( k=0; k