summaryrefslogtreecommitdiffstats
path: root/share/man/tools/pages.c
blob: 9e2e6d4215fb047493c7818c0404698ae2d31a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>

#define T_INIT	0100
#define T_STOP	0111

long	charin;			/* number of input character */

main(argc, argv)
char	**argv;
{

	int	 npages = 0;
	register int	c;

	while((c=getchar()) != EOF) {
		charin++;
		c &= 0377;
		if(c != T_INIT)
			continue;
		else {
			c=getchar();
			c &= 0377;
			if(c == T_STOP) {
				npages++;
				charin++;
			}
		}
	}
	if(charin<5) {
		fprintf(stderr, "%s: no input\n", argv[0]);
		exit(1);
	}
	printf("%d\n", npages);
}
OpenPOWER on IntegriCloud