From de81ad2bf9a3ef9ce1ff2aeaf928c56254618ce6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 17 Jun 1999 00:08:10 +0000 Subject: [PATCH] Ready to ship. --- ascii.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ascii.c b/ascii.c index 12af980..3d0eeff 100644 --- 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 */ } /******************************************************************/ -- 2.43.0