From: utzoo!decvax!cca!dan@BBN-UNIX@sri-unix
Newsgroups: net.unix-wizards
Title: Re: m4 io a line at a time
Article-I.D.: sri-unix.2391
Posted: Sun Aug  1 20:18:23 1982
Received: Mon Aug  2 03:44:35 1982

From: Dan Franklin 
Date:  2 Jul 1982 11:00:29 EDT (Friday)
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))
/*ADD*/ 	setbuf(stdout, NULL);	/* rfg:bbn mod for interactive */
	for (;;) {
	.
	.
	.
			if (infile[infptr]!=stdin)
				fclose(infile[infptr]);
			if (**argv=='-')
	/*ADD*/ 	{
				infile[infptr] = stdin;
	/*ADD*/ 		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