date and time created 80/10/01 17:25:18 by bill
authorBill Joy <bill@ucbvax.Berkeley.EDU>
Thu, 2 Oct 1980 09:25:18 +0000 (01:25 -0800)
committerBill Joy <bill@ucbvax.Berkeley.EDU>
Thu, 2 Oct 1980 09:25:18 +0000 (01:25 -0800)
SCCS-vsn: old/eqn/checkeq/checkeq.c 4.1

usr/src/old/eqn/checkeq/checkeq.c [new file with mode: 0644]

diff --git a/usr/src/old/eqn/checkeq/checkeq.c b/usr/src/old/eqn/checkeq/checkeq.c
new file mode 100644 (file)
index 0000000..4522008
--- /dev/null
@@ -0,0 +1,86 @@
+static char *sccsid = "@(#)checkeq.c   4.1 (Berkeley) %G%";
+#include <stdio.h>
+FILE   *fin;
+int    delim   = '$';
+
+main(argc, argv) char **argv; {
+
+       if (argc <= 1)
+               check(stdin);
+       else
+               while (--argc > 0) {
+                       if ((fin = fopen(*++argv, "r")) == NULL) {
+                               printf("Can't open %s\n", *argv);
+                               exit(1);
+                       }
+                       printf("%s:\n", *argv);
+                       check(fin);
+                       fclose(fin);
+               }
+}
+
+check(f)
+FILE   *f;
+{
+       int start, line, eq, ndel, totdel;
+       char in[600], *p;
+
+       start = eq = line = ndel = totdel = 0;
+       while (fgets(in, 600, f) != NULL) {
+               line++;
+               ndel = 0;
+               for (p = in; *p; p++)
+                       if (*p == delim)
+                               ndel++;
+               if (*in=='.' && *(in+1)=='E' && *(in+2)=='Q') {
+                       if (eq++)
+                               printf("   Spurious EQ, line %d\n", line);
+                       if (totdel)
+                               printf("   EQ in %c%c, line %d\n", delim, delim, line);
+               } else if (*in=='.' && *(in+1)=='E' && *(in+2)=='N') {
+                       if (eq==0)
+                               printf("   Spurious EN, line %d\n", line);
+                       else
+                               eq = 0;
+                       if (totdel > 0)
+                               printf("   EN in %c%c, line %d\n", delim, delim, line);
+                       start = 0;
+               } else if (eq && *in=='d' && *(in+1)=='e' && *(in+2)=='l' && *(in+3)=='i' && *(in+4)=='m') {
+                       for (p=in+5; *p; p++)
+                               if (*p != ' ') {
+                                       if (*p == 'o' && *(p+1) == 'f')
+                                               delim = 0;
+                                       else
+                                               delim = *p;
+                                       break;
+                               }
+                       if (delim == 0)
+                               printf("   Delim off, line %d\n", line);
+                       else
+                               printf("   New delims %c%c, line %d\n", delim, delim, line);
+               }
+               if (ndel > 0 && eq > 0)
+                       printf("   %c%c in EQ, line %d\n", delim, delim, line);
+               if (ndel == 0)
+                       continue;
+               totdel += ndel;
+               if (totdel%2) {
+                       if (start == 0)
+                               start = line;
+                       else {
+                               printf("   %d line %c%c, lines %d-%d\n", line-start+1, delim, delim, start, line);
+                               start = line;
+                       }
+               } else {
+                       if (start > 0) {
+                               printf("   %d line %c%c, lines %d-%d\n", line-start+1, delim, delim, start, line);
+                               start = 0;
+                       }
+                       totdel = 0;
+               }
+       }
+       if (totdel)
+               printf("   Unfinished %c%c\n", delim, delim);
+       if (eq)
+               printf("   Unfinished EQ\n");
+}