[net.unix-wizards] m4 io asap

FC01@USC-ECL@sri-unix (08/02/82)

From: FC01 <FC01@USC-ECL>
Date:  2 Jul 1982 1144-PDT
The following change to your change is what I am using. - note that the first
if you had was a syntax error (unknown reason since I didn't use it) and the
modified version does great

From: Dan Franklin <dan at BBN-UNIX>
Subject: Re: m4 io a line at a time
We made exactly that change so we could use m4 as a front end to adb.
The change was based on the idea that m4 ought to be interactive if
it is reading standard input and standard input is a terminal. The
change was so simple that I might as well give it here. The file is m4.c.
	if (argc>1)
		putbak(0);
/*ADD*/ else if (isatty(0))		/*fc - ignore to do always*/
/*ADD*/ 	setbuf(stdout, NULL);	/* rfg:bbn mod for interactive */
	for (;;) {
	.
	.
	.
			if (infile[infptr]!=stdin)
				fclose(infile[infptr]);
			if (**argv=='-')
	/*ADD*/ 	{
				infile[infptr] = stdin;
/*ADD*/ /*ignore to do always*/	if (isatty(0)) /*rfg:bbn mod for interactive*/
	/*ADD*/ 			setbuf(stdout, NULL);
	/*ADD*/ 	}

It might be nice to add a command-line option to force interactiveness,
in case m4 is getting its input from another interactive filter.
	Dan Franklin

The ignore to do always comments are my modifications to always do output asap
it seems to work real well in pipesas well as out. What do you think about
making this a permanent fix to m4?
		Fred
-------

dan@BBN-UNIX@sri-unix (08/02/82)

From: Dan Franklin <dan@BBN-UNIX>
Date:  2 Jul 1982 16:52:15 EDT (Friday)
The syntax error was because our m4 has no semicolon in the putbak macro;
sorry about that.

The problem with always doing output asap is that it is incredibly inefficient.
If anyone uses such a modified m4 for preprocessing their huge Fortran program,
it will bring the system to its knees. At least, such has been our experience
with the old m6 program on our 11/70.