[4494] in Athena Bugs

home help back first fref pref prev next nref lref last post

patch from the net to m4

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Sun Mar 11 19:01:15 1990

Date: Sun, 11 Mar 90 19:01:03 -0500
From: Jonathan I. Kamens <jik@pit-manager.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
In article <5753@videovax.tv.tek.com>, bart@videovax.tv.tek.com (Bart
Massey) writes:
> m4 mysteriously started dumping core on me today, and after a couple hours
> of flailing, I figured out that it doesn't check for overrun on its input
> or output buffers.  In my case, the input buffer was overflowing, apparently
> due to an infinite recursion, and corrupting the symbol table.
> 
> Now while one could argue that I shouldn't be using m4 if I'm not smart
> enough to know that whenever it dumps core it's because the input buffer has
> overflowed due to infinite recursion :-), the following patch seems to do a
> reasonable job of making m4 a little more user-friendly in this situation.
> Incidentally, I also rewrote the put macro while I was at it :-) -- it's now
> an expression rather than a statement.
> 
> While I'm at it, is there a more modern and/or free version of m4 out
> there?  How about source for other interesting macro pre-processors?
> 
> 					Bart Massey
> 					
> 					Tektronix, Inc.
> 					TV Systems Engineering
> 					M.S. 58-639
> 					P.O. Box 500
> 					Beaverton, OR 97077
> 					(503) 627-5320
> 
> 					..tektronix!videovax.tv.tek.com!bart
> 
> 
> *** /tmp/,RCSt1013776	Wed Mar  7 21:29:50 1990
> --- m4.c	Wed Mar  7 21:28:47 1990
> ***************
> *** 35,43 ****
>   #define	SAVS	4096
>   #define	TOKS	128
>   
> ! #define	putbak(c)	*ip++ = c;
> ! #define	getchr()	(ip>cur_ip?*--ip: getc(infile[infptr]))
> ! #define	putchr(c)	if (cp==NULL) {if (curfile)putc(c,curfile);} else
*op++ = c
>   char	type[] = {
>   	0,	0,	0,	0,	0,	0,	0,	0,
>   	0,	0,	0,	0,	0,	0,	0,	0,
> --- 35,56 ----
>   #define	SAVS	4096
>   #define	TOKS	128
>   
> ! puterr()
> ! {
> ! 	fprintf( stderr, "m4: output buffer overflow\n" );
> ! 	delexit();
> ! }
> ! 
> ! putbakerr()
> ! {
> ! 	fprintf( stderr, "m4: input buffer overflow (infinite recursion?)\n" );
> ! 	delexit();
> ! }
> ! 
> ! #define	putbak(c)	((ip<ibuf+sizeof(ibuf))?(*ip++ = (c)):putbakerr())
> ! #define	getchr()	((ip>cur_ip)?*--ip:getc(infile[infptr]))
> ! #define	putchr(c)
(cp?((op<obuf+sizeof(obuf))?(*op++=(c)):puterr()):(curfile?putc((c),curf
file):0))
> ! 
>   char	type[] = {
>   	0,	0,	0,	0,	0,	0,	0,	0,
>   	0,	0,	0,	0,	0,	0,	0,	0,

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710

home help back first fref pref prev next nref lref last post