/* interpret single characters as themselves */
if (len == 1) {
speak((unsigned int)str[0]);
- return;
+ /* also interpret single digits as numeric */
+ if(!line && strchr("0123456789ABCDEFabcdef",str[0])) {
+ int hval;
+ (void) sscanf(str, "%x", &hval);
+ speak(hval);
+ } return;
}
/* process multiple letters */
/* interpret ^-escapes as control-character notation */
if (strcmp(str, "^?") == 0)
- { speak((unsigned int)0x7F); return; }
+ { speak((unsigned int)0x7F); return; }
else if (str[0] == '^' && len == 2)
{ speak((unsigned int)(str[1] & 0x1f)); return; }
for (ch = 7; ch < 14; ch++)
for (ptr = &cnames[ch][1]; *ptr; ptr++)
if (**ptr == '\\' && strcmp(str, *ptr) == 0)
- { speak((unsigned int)ch); return; }
+ { speak((unsigned int)ch); return; }
/* interpret 2 and 3-character ASCII control mnemonics */
if (len == 2 || len == 3)
{
/* first check for standard mnemonics */
if (stricmp(str, "DEL") == 0)
- { speak(0x7f); return; }
+ { speak(0x7f); return; }
if (stricmp(str, "BL") == 0)
- { speak(' '); return; }
+ { speak(' '); return; }
else if (isalpha(str[0]))
for (ch = 0; ch <= 32; ch++)
if (!stricmp(str,cnames[ch][0]) || !strcmp(str,cnames[ch][1]))
- { speak(ch); return; }
+ { speak(ch); return; }
}
/* OK, now try to interpret the string as a numeric */
else if (tolower(str[0]) == 'x')
(void) sscanf(str + 1, "%x", &hval);
else if ((len >= 2) && (len <= 3) &&
- (strspn(str,"0123456789ABCDEFabcdef") == (len-1)) &&
- (tolower(str[len - 1]) == 'h'))
+ (strspn(str,"0123456789ABCDEFabcdef") == (len-1)) &&
+ (tolower(str[len - 1]) == 'h'))
(void) sscanf(str, "%x", &hval);
/* accept 0onn, \onnn, onnn and \nnn forms for octal */
}
if (sscanf(str, "%d/%d", &hi, &lo) == 2) /* code table reference? */
- { speak(hi*16 + lo); return; }
+ { speak(hi*16 + lo); return; }
else if (len > 1 && isalpha(str[0])) /* try to match long names */
{
char canbuf[BUFSIZ], *ep;