#
/*
 *	pr infile >outfile
 */

/*)BUILD	$(TKBOPTIONS) = {
			TASK	= ...PRX
		}
*/

#ifdef	DOCUMENTATION

title	pr	Print File With Line Numbers
index		Print File With Line Numbers

synopsis

	pr file_list

description

	Each file in the argument is written to stdout.
	Each line of the output is numbered.

diagnostics

	.lm +8
	.s.i -8;Couldn't open "file name"
	.lm -8

author

	Martin Minow

bugs

#endif

#include <stdio.h>
#define	LSIZE	512
char	line[LSIZE];
main(argc, argv)
int	argc;
char	*argv[];
{
	int		argcount;
	register int	i;
	register int	linect;
	register FILE	*fp;

#ifdef vax
	argc = getredirection(argc,argv);
#endif

	for (argcount = 1; argcount < argc; argcount++) {
		if ((fp = fopen(argv[argcount], "r")) == NULL) {
			fprintf(stderr, "Couldn't open \"%s\"\n", argv[1]);
			continue;
		}
		linect = 0;
		for (;;) {
			if (fgets(line, LSIZE, fp) == NULL)
				break;
			printf("%6d: %s", ++linect, line);
		}
	}
}
