|
|
1.1 ! root 1: static char *sccsid = "@(#)what.c 4.2 (Berkeley) 11/8/81"; ! 2: #include <stdio.h> ! 3: ! 4: /* ! 5: * what ! 6: */ ! 7: ! 8: char *infile = "Standard input"; ! 9: ! 10: main(argc, argv) ! 11: int argc; ! 12: char *argv[]; ! 13: { ! 14: ! 15: argc--, argv++; ! 16: do { ! 17: if (argc > 0) { ! 18: if (freopen(argv[0], "r", stdin) == NULL) { ! 19: perror(argv[0]); ! 20: exit(1); ! 21: } ! 22: infile = argv[0]; ! 23: printf("%s\n", infile); ! 24: argc--, argv++; ! 25: } ! 26: fseek(stdin, (long) 0, 0); ! 27: find(); ! 28: } while (argc > 0); ! 29: exit(0); ! 30: } ! 31: ! 32: find() ! 33: { ! 34: static char buf[BUFSIZ]; ! 35: register char *cp; ! 36: register int c, cc; ! 37: register char *pat; ! 38: ! 39: contin: ! 40: while ((c = getchar()) != EOF) ! 41: if (c == '@') { ! 42: for (pat = "(#)"; *pat; pat++) ! 43: if ((c = getchar()) != *pat) ! 44: goto contin; ! 45: putchar('\t'); ! 46: while ((c = getchar()) != EOF && c && c != '"' && ! 47: c != '>' && c != '\n') ! 48: putchar(c); ! 49: putchar('\n'); ! 50: } ! 51: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.