From 71435f202226d500be689464be3fcf8369611fcc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 12 Nov 1997 20:09:46 +0000 Subject: [PATCH] This version works. --- Makefile | 4 ++-- ascii.c | 64 ++++++++++++++++++++++++++++++++++++++++++------------ ascii.spec | 2 +- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 8080ef0..a56294f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # ascii -- interactive ASCII reference # Note: When the version changes, you also have to change -# the RPM spec file -V=2.2 +# the RPM spec file and LSM +V=2.3 ascii: ascii.c diff --git a/ascii.c b/ascii.c index 66b63db..4156620 100644 --- a/ascii.c +++ b/ascii.c @@ -24,7 +24,7 @@ */ -#define REVISION "$Revision: 1.5 $" +#define REVISION "$Revision: 1.6 $" #include #include @@ -34,6 +34,7 @@ typedef char *string; static unsigned char terse = 0; +static unsigned char help = 0; enum { decimal, hex, octal } mode; @@ -300,6 +301,39 @@ or numeric values in hex/octal/decimal/binary.\n"); exit(0); } +/*********************************************************/ +void +showSplash(void) +{ +#define P(s) puts(s); +P("Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Usage: ascii ") +P(" 0 00 NUL \\0 22 16 SYN 44 2C , 66 42 B 88 58 X Displays all aliases") +P(" 1 01 SOH 23 17 ETB 45 2D - 67 43 C 89 59 Y of given chars.") +P(" 2 02 STX 24 18 CAN 46 2E . 68 44 D 90 5A Z Accepts") +P(" 3 03 ETX 25 19 EM 47 2F / 69 45 E 91 5B [ Dec Hex decimal,") +P(" 4 04 EOT 26 1A SUB 48 30 0 70 46 F 92 5C \\ 110 6E n octal,") +P(" 5 05 ENQ 27 1B ESC 49 31 1 71 47 G 93 5D ] 111 6F o hex,") +P(" 6 06 ACK 28 1C FS 50 32 2 72 48 H 94 5E ^ 112 70 p binary,") +P(" 7 07 BEL \\a 29 1D GS 51 33 3 73 49 I 95 5F _ 113 71 q ^X form,") +P(" 8 08 BS \\b 30 1E RS 52 34 4 74 4A J 96 60 ` 114 72 r \\x form,") +P(" 9 09 HT \\t 31 1F US 53 35 5 75 4B K 97 61 a 115 73 s english,") +P(" 10 0A LF \\n 32 20 SPACE 54 36 6 76 4C L 98 62 b 116 74 t mnemonics,") +P(" 11 0B VT \\v 33 21 ! 55 37 7 77 4D M 99 63 c 117 75 u nicknames") +P(" 12 0C FF \\f 34 22 \" 56 38 8 78 4E N 100 64 d 118 76 v") +P(" 13 0D CR \\r 35 23 # 57 39 9 79 4F O 101 65 e 119 77 w") +P(" 14 0E SO 36 24 $ 58 3A : 80 50 P 102 66 f 120 78 x") +P(" 15 0F SI 37 25 % 59 3B ; 81 51 Q 103 67 g 121 79 y") +P(" 16 10 DLE 38 26 & 60 3C < 82 52 R 104 68 h 122 7A z") +P(" 17 11 DC1 39 27 ' 61 3D = 83 53 S 105 69 i 123 7B {") +P(" 18 12 DC2 40 28 ( 62 3E > 84 54 T 106 6A j 124 7C |") +P(" 19 13 DC3 41 29 ) 63 3F ? 85 55 U 107 6B k 125 7D }") +P(" 20 14 DC4 42 2A * 64 40 @ 86 56 V 108 6C l 126 7E ~") +P(" 21 15 NAK 43 2B + 65 41 A 87 57 W 109 6D m 127 7F DEL") +#undef P + + exit(0); +} + /*********************************************************/ void process_options(int argc, char *argv[], char * opt_string) @@ -310,7 +344,7 @@ process_options(int argc, char *argv[], char * opt_string) switch (op) { case 't': - terse=1; + terse = 1; break; case 'd': print_table(decimal); @@ -321,15 +355,15 @@ process_options(int argc, char *argv[], char * opt_string) case 'o': print_table(octal); exit(0); + case '?': case 'h': - showHelp(stdout, argv[0]) ; + help = 1; break; case 'v': printf("%s\n",REVISION); exit(0) ; break; - case '?': default : - showHelp(stderr, argv[0]) ; + help = 1; break; } /*switch*/ }/*while*/ @@ -594,19 +628,21 @@ int main(argc, argv) int argc; char **argv; { - char *optstring="thvxod" ; - + char *optstring="thvxod" ; - process_options(argc, argv, optstring) ; + process_options(argc, argv, optstring) ; - if (argc == optind ) { - showHelp(stderr, argv[0]); - }else{ - for(argc--, argv++ ; argc > 0; argv++, argc--) - ascii(*argv) ; + if (help) + showHelp(stdout, argv[0]); + else if (argc == optind ) + showSplash(); + else { + for(argc--, argv++ ; argc > 0; argv++, argc--) + ascii(*argv) ; } - exit(0); + exit(0); } /******************************************************************/ /* ascii.c ends here */ + diff --git a/ascii.spec b/ascii.spec index a6f9b0d..aef3c72 100644 --- a/ascii.spec +++ b/ascii.spec @@ -1,6 +1,6 @@ Description: interactive ASCII name and synonym chart Name: ascii -Version: 2.2 +Version: 2.3 Release: 1 Source: locke.ccil.org:/pub/esr/ascii-2.2.tar.gz Copyright: distributable -- 2.43.0