DWB troff font bug

Doug Gwyn gwyn at brl-adm.ARPA
Wed Mar 16 22:46:34 AEST 1988


When we expanded troff to support more fonts, a horrible bug surfaced.
When the device had more than 18 fonts, font 'B' got mapped to the
wrong font position!  This bug appears in both DWB 1.0 and DWB 2.0
versions of device-independent troff, in source file t6.c (normally
found in a source directory named "troff.d").  The faulty function
"findft" is identical in both DWB releases.  Here's the fixed function:

findft(i)
register int	i;
{
#if 0	/* DAG -- horrible bug! */
	register k;

	if ((k = i - '0') >= 0 && k <= nfonts && k < smnt)
#else
	register int k, m;

	if (i >= '0' && i <= '9'
	 && (k = i - '0') <= nfonts && k < smnt
	 || (k = (i & 0xFF00) >> 8) >= '0' && k <= '9'
	 && (m = i & 0xFF) >= '0' && m <= '9'
	 && (k = m - '0' + 10 * (k - '0')) <= nfonts && k < smnt)
#endif
		return(k);
	for (k = 0; fontlab[k] != i; k++)
		if (k > nfonts)
			return(-1);
	return(k);
}



More information about the Comp.bugs.sys5 mailing list