usr.bin/mail/lex.c
/*
 * Interpret user commands one by one.  If standard input is not a tty,
 * print no prompt.
 */
Interpret user commands one by one.  If standard input is not a tty,
print no prompt.
Interpret user commands one by one . If standard input is not a tty print no prompt .
void
commands()
{
	int eofloop = 0;
	register int n;
	char linebuf[LINESIZE];
	void intr(), stop(), hangup();
	if (!sourcing) {
		if (signal(SIGINT, SIG_IGN) != SIG_IGN)
			signal(SIGINT, intr);
		if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
			signal(SIGHUP, hangup);
		signal(SIGTSTP, stop);
		signal(SIGTTOU, stop);
		signal(SIGTTIN, stop);
	}
	setexit();
	for (;;) {
		if (!sourcing && value("interactive") != NOSTR) {
			if ((value("autoinc") != NOSTR) && (incfile() > 0))
				printf("New mail has arrived.\n");
			reset_on_stop = 1;
			printf(prompt);
		}
		fflush(stdout);
		sreset();
		n = 0;
		for (;;) {
			if (readline(input, &linebuf[n], LINESIZE - n) < 0) {
				if (n == 0)
					n = -1;
				break;
			}
			if ((n = strlen(linebuf)) == 0)
				break;
			n--;
			if (linebuf[n] != '\\')
				break;
			linebuf[n++] = ' ';
		}
		reset_on_stop = 0;
		if (n < 0) {
			if (loading)
				break;
			if (sourcing) {
				unstack();
				continue;
			}
			if (value("interactive") != NOSTR &&
			    value("ignoreeof") != NOSTR &&
			    ++eofloop < 25) {
				printf("Use \"quit\" to quit.\n");
				continue;
			}
			break;
		}
		eofloop = 0;
		if (execute(linebuf, 0))
			break;
	}
}
void commands ( ) { int eofloop = 0 ; register int n ; char linebuf [ LINESIZE ] ; void intr ( ) , stop ( ) , hangup ( ) ; if ( ! sourcing ) { if ( signal ( SIGINT , SIG_IGN ) != SIG_IGN ) signal ( SIGINT , intr ) ; if ( signal ( SIGHUP , SIG_IGN ) != SIG_IGN ) signal ( SIGHUP , hangup ) ; signal ( SIGTSTP , stop ) ; signal ( SIGTTOU , stop ) ; signal ( SIGTTIN , stop ) ; } setexit ( ) ; for ( ; ; ) { if ( ! sourcing && value ( " " ) != NOSTR ) { if ( ( value ( " " ) != NOSTR ) && ( incfile ( ) > 0 ) ) printf ( " \n " ) ; reset_on_stop = 1 ; printf ( prompt ) ; } fflush ( stdout ) ; sreset ( ) ; n = 0 ; for ( ; ; ) { if ( readline ( input , & linebuf [ n ] , LINESIZE - n ) < 0 ) { if ( n == 0 ) n = -1 ; break ; } if ( ( n = strlen ( linebuf ) ) == 0 ) break ; n -- ; if ( linebuf [ n ] != ' \\ ' ) break ; linebuf [ n ++ ] = ' ' ; } reset_on_stop = 0 ; if ( n < 0 ) { if ( loading ) break ; if ( sourcing ) { unstack ( ) ; continue ; } if ( value ( " " ) != NOSTR && value ( " " ) != NOSTR && ++ eofloop < 25 ) { printf ( " \" \" \n " ) ; continue ; } break ; } eofloop = 0 ; if ( execute ( linebuf , 0 ) ) break ; } }
Interpret user commands one by one.
Interpret user commands one by one .
/*
		 * Print the prompt, if needed.  Clear out
		 * string space, and flush the output.
		 */ /*
		 * Read a line of commands from the current input
		 * and handle end of file specially.
		 */ /* eof */