|
|
1.1 ! root 1: #include <stdio.h> ! 2: ! 3: /* For netlib's pipe f2c: check first line of input for flags: ! 4: * If the line has the form ! 5: * c$f2c -flag -flag... ! 6: * (with "c$f2c " starting in column 1) and no funny characters ! 7: * in the flags (all of which start with -), then echo "-flag -flag..." ! 8: * on stdout; otherwise echo nothing. ! 9: */ ! 10: ! 11: main(argc,argv) ! 12: char **argv; ! 13: { ! 14: FILE *f; ! 15: char buf[128]; ! 16: static char good[256]; ! 17: int i; ! 18: register char *s, *s1; ! 19: ! 20: if (argc <= 1) { ! 21: fprintf(stderr, "%s: expected one arg: a file name\n", *argv); ! 22: return 1; ! 23: } ! 24: if (!(f = fopen(argv[1],"r"))) { ! 25: fprintf(stderr, "%s: can't open %s\n", argv[0], argv[1]); ! 26: return 1; ! 27: } ! 28: if (fgets(buf, sizeof(buf), f)) { ! 29: if (strncmp(buf, "c$f2c ", 6)) ! 30: goto done; ! 31: for(i = 'a'; i <= 'z'; i++) ! 32: good[i] = good[i+'A'-'a'] = 1; ! 33: for(i = '0'; i <= '9'; i++) ! 34: good[i] = 1; ! 35: for(s = "\t -+=,.!%_\n"; *s; s++) ! 36: good[*s] = 1; ! 37: for(s = buf+6; good[*(unsigned char *)s]; s++); ! 38: if (*s) ! 39: goto done; ! 40: for(s = buf+5, s1 = 0;;) { ! 41: while(*++s == ' '); ! 42: if (*s != '-') { ! 43: if (!*s) ! 44: break; ! 45: goto done; ! 46: } ! 47: if (!s1) ! 48: s1 = s; ! 49: while(*++s != ' ') ! 50: if (!*s) ! 51: goto for_done; ! 52: } ! 53: for_done: ! 54: if (s1) ! 55: printf("%s", s1); ! 56: } ! 57: done: ! 58: fclose(f); ! 59: return 0; ! 60: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.