]> thyrsus.com Git - ascii.git/commitdiff
These are Ioannes Tambouras's second round of changes.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 12 Nov 1997 19:58:08 +0000 (19:58 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 12 Nov 1997 19:58:08 +0000 (19:58 +0000)
Makefile
ascii.c
ascii.spec
ascii.xml

index 6286aa54a6be5fe005ec3677eafa4384cd0cbda5..8080ef04cbdf45de23b49c3de16b2891bd748630 100644 (file)
--- 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 9a9d1cfab6a5b31c4dc8d34cbc4f9b26414f40eb..66b63dbeafe9e00f04ca598f5c0939ca6bee35c2 100644 (file)
--- a/ascii.c
+++ b/ascii.c
@@ -2,11 +2,12 @@
  * ascii.c -- quick crossreference for ASCII character aliases
  *
  * by Eric S. Raymond <esr@snark.thyrsus.com>, 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 <unistd.h>
 #include <stdio.h>
@@ -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{
index d611827291a43b647b5bdf206a8debc5c75d1ea3..a6f9b0d75a11c78ca114dd299a032d8b4be46363 100644 (file)
@@ -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
 
index 712adb821a8d760e9379569be485d5581e6c70be..b5c2bd0ec2916b5272ba89fdb05712bc2c427255 100644 (file)
--- 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