USG_PG3/usr/source/sccscommon/dohist.c

# include "../sccshead/sfile.h"

char	dohist___[] "@(#)dohist.c	3.4";
int	peekc;


dohist(dt,histstr)
struct Deltab *dt;
char *histstr;
{
	register char *p, *eoh;
	int bad, tty[3];

	peekc = bad = 0;
	if (!histstr) {
		if (gtty(0,tty) >= 0)
			printf("history? ");
		eoh = &dt->Dhist[sizeof(dt->Dhist)];
		for (p=dt->Dhist; p < eoh && (*p=getpeekc()) != '\n'; p++) {
			if (*p == '\\' && (peekc=getpeekc()) == '\n') {
				*p = ' ';
				peekc = 0;
			}
		}
		if (*p == '\n')
			*p = 0;
		else
			bad = 1;
	}
	else if (size(histstr) > sizeof(dt->Dhist))
		bad = 1;
	else
		copy(histstr,dt->Dhist);
	if (bad)
		fatal("history too long (313)");
}


getpeekc()
{
	register char c;

	if (c = peekc)
		peekc = 0;
	else
		c = getchr();
	return(c);
}