|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: */ ! 6: ! 7: #ifndef lint ! 8: char copyright[] = ! 9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\ ! 10: All rights reserved.\n"; ! 11: #endif not lint ! 12: ! 13: #ifndef lint ! 14: static char sccsid[] = "@(#)soelim.c 5.1 (Berkeley) 5/31/85"; ! 15: #endif not lint ! 16: ! 17: #include <stdio.h> ! 18: /* ! 19: * soelim - a filter to process n/troff input eliminating .so's ! 20: * ! 21: * Author: Bill Joy UCB July 8, 1977 ! 22: * ! 23: * This program eliminates .so's from a n/troff input stream. ! 24: * It can be used to prepare safe input for submission to the ! 25: * phototypesetter since the software supporting the operator ! 26: * doesn't let him do chdir. ! 27: * ! 28: * This is a kludge and the operator should be given the ! 29: * ability to do chdir. ! 30: * ! 31: * This program is more generally useful, it turns out, because ! 32: * the program tbl doesn't understand ".so" directives. ! 33: */ ! 34: #define STDIN_NAME "-" ! 35: ! 36: main(argc, argv) ! 37: int argc; ! 38: char *argv[]; ! 39: { ! 40: ! 41: argc--; ! 42: argv++; ! 43: if (argc == 0) { ! 44: (void)process(STDIN_NAME); ! 45: exit(0); ! 46: } ! 47: do { ! 48: (void)process(argv[0]); ! 49: argv++; ! 50: argc--; ! 51: } while (argc > 0); ! 52: exit(0); ! 53: } ! 54: ! 55: int process(file) ! 56: char *file; ! 57: { ! 58: register char *cp; ! 59: register int c; ! 60: char fname[BUFSIZ]; ! 61: FILE *soee; ! 62: int isfile; ! 63: ! 64: if (!strcmp(file, STDIN_NAME)) { ! 65: soee = stdin; ! 66: } else { ! 67: soee = fopen(file, "r"); ! 68: if (soee == NULL) { ! 69: perror(file); ! 70: return(-1); ! 71: } ! 72: } ! 73: for (;;) { ! 74: c = getc(soee); ! 75: if (c == EOF) ! 76: break; ! 77: if (c != '.') ! 78: goto simple; ! 79: c = getc(soee); ! 80: if (c != 's') { ! 81: putchar('.'); ! 82: goto simple; ! 83: } ! 84: c = getc(soee); ! 85: if (c != 'o') { ! 86: printf(".s"); ! 87: goto simple; ! 88: } ! 89: do ! 90: c = getc(soee); ! 91: while (c == ' ' || c == '\t'); ! 92: cp = fname; ! 93: isfile = 0; ! 94: for (;;) { ! 95: switch (c) { ! 96: ! 97: case ' ': ! 98: case '\t': ! 99: case '\n': ! 100: case EOF: ! 101: goto donename; ! 102: ! 103: default: ! 104: *cp++ = c; ! 105: c = getc(soee); ! 106: isfile++; ! 107: continue; ! 108: } ! 109: } ! 110: donename: ! 111: if (cp == fname) { ! 112: printf(".so"); ! 113: goto simple; ! 114: } ! 115: *cp = 0; ! 116: if (process(fname) < 0) ! 117: if (isfile) ! 118: printf(".so %s\n", fname); ! 119: continue; ! 120: simple: ! 121: if (c == EOF) ! 122: break; ! 123: putchar(c); ! 124: if (c != '\n') { ! 125: c = getc(soee); ! 126: goto simple; ! 127: } ! 128: } ! 129: if (soee != stdin) { ! 130: fclose(soee); ! 131: } ! 132: return(0); ! 133: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.