1: #ifndef lint
   2: static char *sccsid = "@(#)soelim.c	4.1 (Berkeley) 10/1/80";
   3: #endif
   4: #include <stdio.h>
   5: /*
   6:  * soelim - a filter to process n/troff input eliminating .so's
   7:  *
   8:  * Author: Bill Joy UCB July 8, 1977
   9:  *
  10:  * This program eliminates .so's from a n/troff input stream.
  11:  * It can be used to prepare safe input for submission to the
  12:  * phototypesetter since the software supporting the operator
  13:  * doesn't let him do chdir.
  14:  *
  15:  * This is a kludge and the operator should be given the
  16:  * ability to do chdir.
  17:  *
  18:  * This program is more generally useful, it turns out, because
  19:  * the program tbl doesn't understand ".so" directives.
  20:  */
  21: 
  22: main(argc, argv)
  23:     int argc;
  24:     char *argv[];
  25: {
  26: 
  27:     argc--;
  28:     argv++;
  29:     if (argc == 0) {
  30:         fprintf(stderr, "Usage: %s file [ file ... ]\n", argv[-1]);
  31:         exit(1);
  32:     }
  33:     do {
  34:         process(argv[0]);
  35:         argv++;
  36:         argc--;
  37:     } while (argc > 0);
  38:     exit(0);
  39: }
  40: 
  41: process(file)
  42:     char *file;
  43: {
  44:     register char *cp;
  45:     register int c;
  46:     char fname[BUFSIZ];
  47:     FILE *soee;
  48: 
  49:     soee = fopen(file, "r");
  50:     if (soee == NULL) {
  51:         perror(file);
  52:         return;
  53:     }
  54:     for (;;) {
  55:         c = getc(soee);
  56:         if (c < 0)
  57:             break;
  58:         if (c != '.')
  59:             goto simple;
  60:         c = getc(soee);
  61:         if (c != 's') {
  62:             putchar('.');
  63:             goto simple;
  64:         }
  65:         c = getc(soee);
  66:         if (c != 'o') {
  67:             printf(".s");
  68:             goto simple;
  69:         }
  70:         do
  71:             c = getc(soee);
  72:         while (c == ' ' || c == '\t');
  73:         cp = fname;
  74:         for (;;) {
  75:             switch (c) {
  76: 
  77:             case ' ':
  78:             case '\t':
  79:             case '\n':
  80:             case EOF:
  81:                 goto donename;
  82: 
  83:             default:
  84:                 *cp++ = c;
  85:                 c = getc(soee);
  86:                 continue;
  87:             }
  88:         }
  89: donename:
  90:         if (cp == fname) {
  91:             printf(".so");
  92:             goto simple;
  93:         }
  94:         *cp++ = 0;
  95:         process(fname);
  96:         continue;
  97: simple:
  98:         if (c == EOF)
  99:             break;
 100:         putchar(c);
 101:     }
 102:     fclose(soee);
 103: }

Defined functions

main defined in line 22; never used
process defined in line 41; used 2 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1982-09-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 471
Valid CSS Valid XHTML 1.0 Strict