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