1: #include <stdio.h> 2: FILE *fin; 3: int delim = 0; 4: /* today's version assumes no delimiters; 5: they must be explicitly set 6: */ 7: 8: main(argc, argv) char **argv; { 9: 10: while (argc > 1 && argv[1][0] == '-') { 11: switch (argv[1][1]) { 12: case 'd': 13: delim = argv[1][2]; 14: break; 15: } 16: argc--; 17: argv++; 18: } 19: if (argc <= 1) 20: check(stdin); 21: else 22: while (--argc > 0) { 23: if ((fin = fopen(*++argv, "r")) == NULL) { 24: printf("Can't open %s\n", *argv); 25: exit(1); 26: } 27: printf("%s:\n", *argv); 28: check(fin); 29: fclose(fin); 30: } 31: } 32: 33: check(f) 34: FILE *f; 35: { 36: int start, line, eq, ndel, totdel; 37: char in[600], *p; 38: 39: start = eq = line = ndel = totdel = 0; 40: while (fgets(in, 600, f) != NULL) { 41: line++; 42: ndel = 0; 43: for (p = in; *p; p++) 44: if (*p == delim) 45: ndel++; 46: if (*in=='.' && *(in+1)=='E' && *(in+2)=='Q') { 47: if (eq++) 48: printf(" Spurious EQ, line %d\n", line); 49: if (totdel) 50: printf(" EQ in %c%c, line %d\n", delim, delim, line); 51: } else if (*in=='.' && *(in+1)=='E' && *(in+2)=='N') { 52: if (eq==0) 53: printf(" Spurious EN, line %d\n", line); 54: else 55: eq = 0; 56: if (totdel > 0) 57: printf(" EN in %c%c, line %d\n", delim, delim, line); 58: start = 0; 59: } else if (eq && *in=='d' && *(in+1)=='e' && *(in+2)=='l' && *(in+3)=='i' && *(in+4)=='m') { 60: for (p=in+5; *p; p++) 61: if (*p != ' ') { 62: if (*p == 'o' && *(p+1) == 'f') 63: delim = 0; 64: else { 65: delim = *p; 66: ndel = totdel = 0; 67: } 68: break; 69: } 70: if (delim == 0) 71: printf(" Delim off, line %d\n", line); 72: else 73: printf(" New delims %c%c, line %d\n", delim, delim, line); 74: } 75: if (ndel > 0 && eq > 0) 76: printf(" %c%c in EQ, line %d\n", delim, delim, line); 77: if (ndel == 0) 78: continue; 79: totdel += ndel; 80: if (totdel%2) { 81: if (start == 0) 82: start = line; 83: else { 84: printf(" %d line %c%c, lines %d-%d\n", line-start+1, delim, delim, start, line); 85: start = line; 86: } 87: } else { 88: if (start > 0) { 89: printf(" %d line %c%c, lines %d-%d\n", line-start+1, delim, delim, start, line); 90: start = 0; 91: } 92: totdel = 0; 93: } 94: } 95: if (totdel) 96: printf(" Unfinished %c%c\n", delim, delim); 97: if (eq) 98: printf(" Unfinished EQ\n"); 99: }