1*c81ca039Sbostic /*-
2*c81ca039Sbostic * Copyright (c) 1987 The Regents of the University of California.
3*c81ca039Sbostic * All rights reserved.
4*c81ca039Sbostic *
5*c81ca039Sbostic * %sccs.include.proprietary.c%
603dbb8a8Sbostic */
703dbb8a8Sbostic
803dbb8a8Sbostic #ifndef lint
903dbb8a8Sbostic char copyright[] =
10*c81ca039Sbostic "@(#) Copyright (c) 1987 The Regents of the University of California.\n\
1103dbb8a8Sbostic All rights reserved.\n";
1203dbb8a8Sbostic #endif /* not lint */
1303dbb8a8Sbostic
1403dbb8a8Sbostic #ifndef lint
15*c81ca039Sbostic static char sccsid[] = "@(#)checkeq.c 4.4 (Berkeley) 04/17/91";
1603dbb8a8Sbostic #endif /* not lint */
1703dbb8a8Sbostic
1851abcc9dSbill #include <stdio.h>
1951abcc9dSbill FILE *fin;
2051abcc9dSbill int delim = '$';
2151abcc9dSbill
main(argc,argv)2251abcc9dSbill main(argc, argv) char **argv; {
2351abcc9dSbill
2451abcc9dSbill if (argc <= 1)
2551abcc9dSbill check(stdin);
2651abcc9dSbill else
2751abcc9dSbill while (--argc > 0) {
2851abcc9dSbill if ((fin = fopen(*++argv, "r")) == NULL) {
298315259cSmckusick perror(*argv);
3051abcc9dSbill exit(1);
3151abcc9dSbill }
3251abcc9dSbill printf("%s:\n", *argv);
3351abcc9dSbill check(fin);
3451abcc9dSbill fclose(fin);
3551abcc9dSbill }
3603dbb8a8Sbostic exit(0);
3751abcc9dSbill }
3851abcc9dSbill
check(f)3951abcc9dSbill check(f)
4051abcc9dSbill FILE *f;
4151abcc9dSbill {
4251abcc9dSbill int start, line, eq, ndel, totdel;
4351abcc9dSbill char in[600], *p;
4451abcc9dSbill
4551abcc9dSbill start = eq = line = ndel = totdel = 0;
4651abcc9dSbill while (fgets(in, 600, f) != NULL) {
4751abcc9dSbill line++;
4851abcc9dSbill ndel = 0;
4951abcc9dSbill for (p = in; *p; p++)
5051abcc9dSbill if (*p == delim)
5151abcc9dSbill ndel++;
5251abcc9dSbill if (*in=='.' && *(in+1)=='E' && *(in+2)=='Q') {
5351abcc9dSbill if (eq++)
5451abcc9dSbill printf(" Spurious EQ, line %d\n", line);
5551abcc9dSbill if (totdel)
5651abcc9dSbill printf(" EQ in %c%c, line %d\n", delim, delim, line);
5751abcc9dSbill } else if (*in=='.' && *(in+1)=='E' && *(in+2)=='N') {
5851abcc9dSbill if (eq==0)
5951abcc9dSbill printf(" Spurious EN, line %d\n", line);
6051abcc9dSbill else
6151abcc9dSbill eq = 0;
6251abcc9dSbill if (totdel > 0)
6351abcc9dSbill printf(" EN in %c%c, line %d\n", delim, delim, line);
6451abcc9dSbill start = 0;
6551abcc9dSbill } else if (eq && *in=='d' && *(in+1)=='e' && *(in+2)=='l' && *(in+3)=='i' && *(in+4)=='m') {
6651abcc9dSbill for (p=in+5; *p; p++)
6751abcc9dSbill if (*p != ' ') {
6851abcc9dSbill if (*p == 'o' && *(p+1) == 'f')
6951abcc9dSbill delim = 0;
7051abcc9dSbill else
7151abcc9dSbill delim = *p;
7251abcc9dSbill break;
7351abcc9dSbill }
7451abcc9dSbill if (delim == 0)
7551abcc9dSbill printf(" Delim off, line %d\n", line);
7651abcc9dSbill else
7751abcc9dSbill printf(" New delims %c%c, line %d\n", delim, delim, line);
7851abcc9dSbill }
7951abcc9dSbill if (ndel > 0 && eq > 0)
8051abcc9dSbill printf(" %c%c in EQ, line %d\n", delim, delim, line);
8151abcc9dSbill if (ndel == 0)
8251abcc9dSbill continue;
8351abcc9dSbill totdel += ndel;
8451abcc9dSbill if (totdel%2) {
8551abcc9dSbill if (start == 0)
8651abcc9dSbill start = line;
8751abcc9dSbill else {
8851abcc9dSbill printf(" %d line %c%c, lines %d-%d\n", line-start+1, delim, delim, start, line);
8951abcc9dSbill start = line;
9051abcc9dSbill }
9151abcc9dSbill } else {
9251abcc9dSbill if (start > 0) {
9351abcc9dSbill printf(" %d line %c%c, lines %d-%d\n", line-start+1, delim, delim, start, line);
9451abcc9dSbill start = 0;
9551abcc9dSbill }
9651abcc9dSbill totdel = 0;
9751abcc9dSbill }
9851abcc9dSbill }
9951abcc9dSbill if (totdel)
10051abcc9dSbill printf(" Unfinished %c%c\n", delim, delim);
10151abcc9dSbill if (eq)
10251abcc9dSbill printf(" Unfinished EQ\n");
10351abcc9dSbill }
104