1: static char *sccsid = "@(#)num.c	4.2 (Berkeley) 10/13/82";
   2: #include    <stdio.h>
   3: #define     formfeed 0xc
   4: 
   5: /*
   6:  * number - a cat like program which prints a file with line
   7:  *	    numbers. Printing of numbers is suppressed on blank
   8:  *	    lines.
   9:  *
  10:  * Original Version by William Joy, June 1977
  11:  * Updated October 1979 by M. Kirk McKusick
  12:  */
  13: main(ac, av)
  14:     int ac;
  15:     char *av[];
  16:     {
  17:     register int argc = ac;
  18:     register char **argv = av;
  19:     register int lino;
  20:     register char *lineptr;
  21:     register FILE *STDOUT = stdout;
  22:     register FILE *STDIN = stdin;
  23:     char line[512];
  24:     extern char _sibuf[], _sobuf[];
  25: 
  26:     argv++;
  27:     argc--;
  28:     lino = 1;
  29:     setbuf(STDIN,_sibuf);
  30:     setbuf(STDOUT,_sobuf);
  31:     do
  32:         {
  33:         if (argc)
  34:             if (freopen(*argv++, "r", STDIN) == NULL)
  35:                 {
  36:                 perror(*--argv);
  37:                 exit(1);
  38:                 }
  39:         for(;;)
  40:             {
  41:             lineptr = line;
  42:             *lineptr = 0;
  43:             fscanf(STDIN,"%[^\n]",lineptr);
  44:             if (feof(STDIN))
  45:                 break;
  46:             if (*lineptr == formfeed)
  47:                 putc(*lineptr++,STDOUT);
  48:             if (!*lineptr)
  49:                 putc('\n',STDOUT);
  50:             else
  51:                 fprintf(STDOUT,"%6d  %s\n",lino,lineptr);
  52:             lino++;
  53:             getc(STDIN);
  54:             }
  55:         }
  56:         while (--argc > 0);
  57:     exit();
  58:     }

Defined functions

main defined in line 13; never used

Defined variables

sccsid defined in line 1; never used

Defined macros

formfeed defined in line 3; used 1 times
  • in line 46
Last modified: 1982-10-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1010
Valid CSS Valid XHTML 1.0 Strict