BSD 2 development
[unix-history] / src / num.c
CommitLineData
fd888be2
MT
1/* Copyright (c) 1979 Regents of the University of California */
2#include "stdio.h"
3/*
4 * number - a cat like program which prints lines like the editor '#'' command
5 *
6 * Bill Joy UCB June 28, 1977
7 */
8
9int lino;
10
11main(argc, argv)
12 int argc;
13 char *argv[];
14{
15 register c;
16 register lastc;
17
18 argc--, argv++;
19 do {
20 if (argc > 0) {
21 if (freopen(argv[0], "r", stdin) == NULL) {
22 perror(argv[0]);
23 exit(1);
24 }
25 argc--, argv++;
26 }
27 lastc = '\n';
28 for (;;) {
29 c = getchar();
30 if (c == -1)
31 break;
32 if (lastc == '\n')
33 printf("%6d ", ++lino);
34 lastc = c;
35 putchar(c);
36 }
37 } while (argc > 0);
38 exit(0);
39}