]> thyrsus.com Git - ascii.git/commitdiff
Ready to ship.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 17 Jun 1999 00:08:10 +0000 (00:08 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 17 Jun 1999 00:08:10 +0000 (00:08 +0000)
ascii.c

diff --git a/ascii.c b/ascii.c
index 12af98094cf0b6b9bc2a2aa9f6d8da46a30100ec..3d0eeffa1c05c80a4ba99fc4ba36006d40c14a52 100644 (file)
--- a/ascii.c
+++ b/ascii.c
@@ -10,7 +10,8 @@
  *     v2.2 November 1997  -- merge in more changes by Ioannis Tambouras.
  *      v2.3 November 1997  -- incorporated Colin Plumb's splash-screen idea.
  *     v2.4 December 1998  -- additions by Brian Ginsbach.
- *     v2.5                -- -s option by David N. Welton.
+ *     v2.5 December 1998  -- -s option by David N. Welton.
+ *      v2.6 June 1999      -- bug fixes by M.R. van Schouwen.
  *
  * Tries to interpret arguments as names or aliases of ascii characters
  * and dumps out *all* the aliases of each. Accepts literal characters,
@@ -19,7 +20,7 @@
  *
  * The slang names used are selected from the 2.2 version of the USENET ascii
  * pronunciation guide.  Some additional ones were merged in from the Jargon
- * File.  Matej Vela added ISO names.
+ * File.
  *
  * Reproduce, use, and modify this as you like, as long as you don't
  * remove the authorship notice and clearly mark your changes. Send me
@@ -508,7 +509,9 @@ char *str;
                (void) sscanf(str + 2, "%x", &hval);
            else if (tolower(str[0]) == 'x')
                (void) sscanf(str + 1, "%x", &hval);
-           else if (tolower(str[len - 1]) == 'h')
+           else if ((len >= 2) && (len <= 3) &&
+               (strspn(str,"0123456789ABCDEFabcdef") == (len-1)) &&
+               (tolower(str[len - 1]) == 'h'))
                (void) sscanf(str, "%x", &hval);
 
        /* accept 0onn, \onnn, onnn and \nnn forms for octal */
@@ -543,10 +546,13 @@ char *str;
            speak(oval & 0xff);
        if (bval > -1 && bval < 256)
            speak(bval & 0xff);
-       if (hval > -1 || dval > -1 || oval > -1 || bval > -1)
-           return;
-       if (hval < 256 || dval < 256 || oval < 256 || bval < 256)
-           return;
+       if (!(hval==-1 && dval==-1 && oval==-1 && bval==-1))
+       {
+           if (hval > -1 || dval > -1 || oval > -1 || bval > -1)
+               return;
+           if (hval < 256 || dval < 256 || oval < 256 || bval < 256)
+               return;
+       }
     }
 
     if (sscanf(str, "%d/%d", &hi, &lo) == 2)    /* code table reference?  */
@@ -576,7 +582,7 @@ char *str;
        for (ch = 0; ch < 128; ch++)
            for (ptr = &cnames[ch][1]; *ptr; ptr++)
                if (!stricmp(*ptr, canbuf))
-                   { speak(ch); return; }
+                   speak(ch);
     } /* outer if */
 }
 /******************************************************************/