コード例 #1
0
ファイル: pr.c プロジェクト: drscream/illumos-joyent
static	int
print(char *name)
{
	static	int	notfirst = 0;
	char	*date = NULL;
	char	*head = NULL;
	int	c;

	if (Multi != 'm' && mustopen(name, &Files[0]) == NULL)
		return (0);
	if (Multi == 'm' && Nfiles == 0 && mustopen(name, &Files[0]) == NULL)
		die("cannot open stdin");
	if (Buffer)
		(void) ungetwc(Files->f_nextc, Files->f_f);
	if (Lnumb)
		Lnumb = 1;
	for (Page = 0; ; putpage()) {
		if (C == WEOF && !(fold && Buffer))
			break;
		if (Buffer)
			nexbuf();
		Inpos = 0;
		if (get(0) == WEOF)
			break;
		(void) fflush(stdout);
		if (++Page >= Fpage) {
			/* Pause if -p and not first page */
			if (Ttyout && Pause && !notfirst++) {
				PROMPT();	/* prompt with bell and pause */
				while ((c = getc(Ttyin)) != EOF && c != '\n')
					;
			}
			if (Margin == 0)
				continue;
			if (date == NULL)
				date = GETDATE();
			if (head == NULL)
				head = Head != NULL ? Head :
				    Nfiles < 2 ? Files->f_name : nulls;
			(void) printf("\n\n");
			Nspace = Offset;
			putspace();
			(void) printf(HEAD);
		}
	}
	C = '\0';
	return (1);
}
コード例 #2
0
ファイル: pr.c プロジェクト: 00001/plan9port
int
pr(char *name)
{
	char *date = 0, *head = 0;

	if(Multi != 'm' && mustopen(name, &Files[0]) == 0)
		return 0;
	if(Buffer)
		Bungetc(Files->f_f);
	if(Lnumb)
		Lnumb = 1;
	for(Page = 0;; putpage()) {
		if(C == -1)
			break;
		if(Buffer)
			nexbuf();
		Inpos = 0;
		if(get(0) == -1)
			break;
		Bflush(&bout);
		Page++;
		if(Page >= Fpage) {
			if(Margin == 0)
				continue;
			if(date == 0)
				date = getdate();
			if(head == 0)
				head = Head != 0 ? Head :
					Nfiles < 2? Files->f_name: nulls;
			Bprint(&bout, "\n\n");
			Nspace = Offset;
			putspace();
			Bprint(&bout, HEAD);
		}
	}
	if(Padodd && (Page&1) == 1) {
		Line = 0;
		if(Formfeed)
			put('\f');
		else
			while(Line < Len)
				put('\n');
	}
	C = '\0';
	return 1;
}