[aus.tex] Patches to tangle.c and web2c.yacc

jimr@metro.oz (pri=5 |Jim Richardson) (01/28/89)

I have been installing Tim Morgan's web2c versions of TeX and Metafont
on Apollo SR10.0/BSD4.3, and have found two corrections.

The first is to the C version of tangle, found in the distribution as
tex82/TeXware/tangle.c.  The symptom was that applying tangle to tex.web
produced a problem with the definition of eject_penalty=-inf_bad=-10000.
(I believe somebody asked about a similar problem in comp.text a month or
so ago, but I have lost the item.)  The following change cured the problem: 

*** tangle.c.orig
--- tangle.c
***************
*** 2578,2584 ****
  	  goto lab21 ; 
  	} 
  	{
! 	  accumulator = accumulator + nextsign * ( equiv [ q ] - 32768L ) ; 
  	  nextsign = 1 ; 
  	} 
        } 
--- 2578,2586 ----
  	  goto lab21 ; 
  	} 
  	{
! 	  accumulator = accumulator +
! 		/*  "(integer)" inserted twice for Apollo  */
! 		((integer) nextsign) * (integer)( equiv [ q ] - 32768L ) ; 
  	  nextsign = 1 ; 
  	} 
        } 

The following test program shows why: 

unsigned short	w = 42768;

main()
{
	long	a = 0;
	char	n = 1;

	n = - (long) n;
	printf( "after -, n = %d\n", (long) n );

	a = a + n * ( w - 32768L );
	printf( "after + n*w[1], a = %d\n", a );
}

We want it to produce -10000 for a, but it gives 6553500000.  I'm not sure
whether this is the fault of Apollo C or the original tangle.c, but it seems
safest to use casts to integer in any case.

The other correction is to tex82/web2cdir/web2c.yacc.  The problem only
showed up when applying web2c to mf.web (and presumably only on Apollos!).
Here are the changes:

*** web2c.yacc.orig
--- web2c.yacc
***************
*** 361,368 ****
  STRUCTURED_TYPE:	ARRAY_TYPE
! 				{sym_table[last_type].var_not_needed = TRUE;}
  		|	RECORD_TYPE
  		|	FILE_TYPE
! 				{sym_table[last_type].var_not_needed = TRUE;}
  		;
  
  ARRAY_TYPE:		array_tok '[' INDEX_TYPE ']' of_tok COMPONENT_TYPE
--- 361,372 ----
  STRUCTURED_TYPE:	ARRAY_TYPE
! 				{if (last_type != -1)
! 				    sym_table[last_type].var_not_needed = TRUE;
! 				}
  		|	RECORD_TYPE
  		|	FILE_TYPE
! 				{if (last_type != -1)
! 				    sym_table[last_type].var_not_needed = TRUE;
! 				}
  		;
  
  ARRAY_TYPE:		array_tok '[' INDEX_TYPE ']' of_tok COMPONENT_TYPE

The problem was that when web2c was parsing the declaration of array arg in
function initterminal in mf.p, the assignment statement was performed with
last_type equal to -1, thus overwriting a global variable (mark_sym_free).

Despite the above, I have found the web2c approach very satisfactory, and
would recommend it over using Pascal.

--
Jim Richardson
Department of Pure Mathematics, University of Sydney, NSW 2006, Australia
UUCP:	...!uunet!munnari!summer.oz!jimr
ARPA:	jimr%summer.oz@uunet.uu.net	ACSNET, CSNET:	jimr@summer.oz