From: Eric S. Raymond Date: Wed, 12 Nov 1997 19:58:08 +0000 (+0000) Subject: These are Ioannes Tambouras's second round of changes. X-Git-Tag: 2-2 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=eafe5cba099425e0b17f78dfecdcc62212d3d80c;p=ascii.git These are Ioannes Tambouras's second round of changes. --- diff --git a/Makefile b/Makefile index 6286aa5..8080ef0 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Note: When the version changes, you also have to change # the RPM spec file -V=2.1 +V=2.2 ascii: ascii.c diff --git a/ascii.c b/ascii.c index 9a9d1cf..66b63db 100644 --- a/ascii.c +++ b/ascii.c @@ -2,11 +2,12 @@ * ascii.c -- quick crossreference for ASCII character aliases * * by Eric S. Raymond , v1.0 March 1990 - * v1.1 November 1990 -- revised `slang' from the 2.2 pronunciation guide - * v1.2 March 1995 -- Fixed a core-dump bug - * v1.3 October 1995 -- Fixed a bug that shows up only under ELF. - * v2.0 December 1995 -- Interpret ISO-style code table escapes. - * v2.1 August 1997 -- nerge in changes by Ioannes Tambouras. + * v1.1 November 1990 -- revised `slang' from the 2.2 pronunciation guide + * v1.2 March 1995 -- Fixed a core-dump bug + * v1.3 October 1995 -- Fixed a bug that shows up only under ELF. + * v2.0 December 1995 -- Interpret ISO-style code table escapes. + * v2.1 August 1997 -- merge in changes by Ioannis Tambouras. + * v2.2 November 1997 -- merge in more changes by Ioannis Tambouras. * * Tries to interpret arguments as names or aliases of ascii characters * and dumps out *all* the aliases of each. Accepts literal characters, @@ -23,7 +24,7 @@ */ -#define REVISION "$Revision$" +#define REVISION "$Revision: 1.5 $" #include #include @@ -34,6 +35,11 @@ typedef char *string; static unsigned char terse = 0; +enum { decimal, hex, octal } mode; + +void print_table(unsigned short delivery); + + static string cnames[128][15] = { {"NUL", "Null", (char *)NULL}, @@ -276,9 +282,13 @@ char *str; void showHelp(FILE *out, char *progname) { - fprintf(out,"Usage: $ %s [options] char-alias...\n",progname); + fprintf(out,"Usage: $ %s [t] char-alias...\n",progname); + fprintf(out," $ %s [dxo] \n",progname); fprintf(out,"Options:\n"); - fprintf(out," -t \t\t Script-friendly mode; output is brief and terse\n"); + fprintf(out," -t \t\t Script-friendly mode with terse output \n"); + fprintf(out," -d \t\t Ascii table in decimal \n"); + fprintf(out," -x \t\t Ascii table in hex \n"); + fprintf(out," -o \t\t Ascii table in octal \n"); fprintf(out," -h \t\t This help screen\n"); fprintf(out," -v \t\t Version info\n"); fprintf(out,"Description:\n"); @@ -302,6 +312,15 @@ process_options(int argc, char *argv[], char * opt_string) case 't': terse=1; break; + case 'd': + print_table(decimal); + exit(0); + case 'x': + print_table(hex); + exit(0); + case 'o': + print_table(octal); + exit(0); case 'h': showHelp(stdout, argv[0]) ; break; @@ -543,16 +562,44 @@ char *str; } /* outer if */ } /******************************************************************/ +void +print_table(unsigned short delivery) +{ + static unsigned short i, j, len; + char separator[]= " "; + char *tail = separator + 3 ; + char *space; + char *name ; + + for (i=0;i<16; i++) { + for (j=0; j<8; j++) { + name= *cnames[i+(j*16)]; + len = strlen(name); + space = tail - (len % 3) ; + switch (delivery) { + case decimal: printf("%5d %1s%1s",i+(j*16),name,space); + break; + case octal : printf("%5o %1s%1s",i+(j*16),name,space); + break; + case hex : printf("%5X %1s%1s",i+(j*16),name,space); + break; + } + } + printf("\n"); + } + +} /*----------------------------------------- M A I N --------------*/ int main(argc, argv) int argc; char **argv; { - char *optstring="thv" ; + char *optstring="thvxod" ; process_options(argc, argv, optstring) ; + if (argc == optind ) { showHelp(stderr, argv[0]); }else{ diff --git a/ascii.spec b/ascii.spec index d611827..a6f9b0d 100644 --- a/ascii.spec +++ b/ascii.spec @@ -1,8 +1,8 @@ Description: interactive ASCII name and synonym chart Name: ascii -Version: 2.1 +Version: 2.2 Release: 1 -Source: locke.ccil.org:/pub/esr/ascii-2.1.tar.gz +Source: locke.ccil.org:/pub/esr/ascii-2.2.tar.gz Copyright: distributable Group: Utilities/Text diff --git a/ascii.xml b/ascii.xml index 712adb8..b5c2bd0 100644 --- a/ascii.xml +++ b/ascii.xml @@ -10,6 +10,15 @@ A summary of options are included below: Script-friendly mode, emits only ISO/decimal/hex/octal/binary encodings of the character. .TP +.B \-d +Ascii table in decimal. +.TP +.B \-x +Ascii table in hex. +.TP +.B \-o +Ascii table in octal. +.TP .B \-h Show summary of options. .TP