*
* by Eric S. Raymond <esr@snark.uu.net>, 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.
*
* Tries to interpret arguments as names or aliases of ascii characters
* and dumps out *all* the aliases of each. Accepts literal characters,
* characters, numbers in hex/decimal/octal/binary, English names.
*
* The slang names used are selected from the 2.2 version of the USENET ascii
- * pronunciation guide.
+ * pronunciation guide. Some additional ones were merged in from the Jargon
+ * 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
{"GS", "Group Separator", (char *)NULL},
{"RS", "Record Separator", (char *)NULL},
{"US", "Group Separator", (char *)NULL},
- {"SP", "BL", "Space", "Blank", (char *)NULL},
+ {" ", "SP", "Space", "Blank", (char *)NULL},
{"!", "Exclamation Point",
"Bang", "Excl", "Wow", "Factorial", "Shriek",
"Pling", "Smash", "Cuss", (char *)NULL},
int i;
static char rep[BITSPERCHAR + 1];
- if (val == 0)
- rp = "0";
- else
- {
- int dcount;
-
- /* write out external representation if requested */
- *(rp = rep + BITSPERCHAR) = '\0';
- for (dcount = 0; val && dcount <= BITSPERCHAR; dcount++)
- {
- *--rp = ((val & 1) ? '1' : '0');
- val /= 2;
- }
-
- while (dcount++ <= BITSPERCHAR)
- *--rp = '0';
- }
-
- return(rep);
+ /* write out external representation at least one char */
+ *(rp = rep + BITSPERCHAR) = '\0';
+ do {
+ *--rp = (val & 1) + '0'; /* Is '1' == '0' + 1 in EBCDIC? */
+ val /= 2;
+ } while
+ (val && rp > rep);
+
+#ifndef SHORT_BINARY_REPRESENTATION
+ while (rp > rep)
+ *--rp = '0';
+#endif
+
+ return(rp);
}
static void speak(ch)
/* first check for standard mnemonics */
if (strcmp(str, "DEL") == 0)
speak(0x7f);
+ if (strcmp(str, "BL") == 0)
+ speak(' ');
else if (isalpha(str[0]))
- for (ch = 0; ch < 32; ch++)
+ for (ch = 0; ch <= 32; ch++)
if (!stricmp(str,cnames[ch][0]) || !strcmp(str,cnames[ch][1]))
speak(ch);
}