1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2 /* All Rights Reserved */ 3 4 5 /* 6 * Copyright (c) 1980 Regents of the University of California. 7 * All rights reserved. The Berkeley software License Agreement 8 * specifies the terms and conditions for redistribution. 9 */ 10 11 /* 12 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 13 * Use is subject to license terms. 14 */ 15 16 #pragma ident "%Z%%M% %I% %E% SMI" 17 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <locale.h> 21 22 static void check(FILE *); 23 24 static FILE *fin; 25 static int delim = '$'; 26 27 int 28 main(int argc, char **argv) 29 { 30 (void) setlocale(LC_ALL, ""); 31 #if !defined(TEXT_DOMAIN) 32 #define TEXT_DOMAIN "SYS_TEST" 33 #endif 34 (void) textdomain(TEXT_DOMAIN); 35 if (argc <= 1) 36 check(stdin); 37 else 38 while (--argc > 0) { 39 if ((fin = fopen(*++argv, "r")) == NULL) { 40 perror(*argv); 41 exit(1); 42 } 43 (void) printf("%s:\n", *argv); 44 check(fin); 45 (void) fclose(fin); 46 } 47 return (0); 48 } 49 50 static void 51 check(FILE *f) 52 { 53 int start, line, eq, ndel, totdel; 54 char in[600], *p; 55 56 start = eq = line = ndel = totdel = 0; 57 while (fgets(in, 600, f) != NULL) { 58 line++; 59 ndel = 0; 60 for (p = in; *p; p++) 61 if (*p == delim) 62 ndel++; 63 if (*in == '.' && *(in+1) == 'E' && *(in+2) == 'Q') { 64 if (eq++) 65 (void) printf( 66 gettext(" Spurious EQ, line %d\n"), 67 line); 68 if (totdel) 69 (void) printf( 70 gettext(" EQ in %c%c, line %d\n"), 71 delim, delim, line); 72 } else if (*in == '.' && *(in+1) == 'E' && *(in+2) == 'N') { 73 if (eq == 0) 74 (void) printf( 75 gettext(" Spurious EN, line %d\n"), 76 line); 77 else 78 eq = 0; 79 if (totdel > 0) 80 (void) printf( 81 gettext(" EN in %c%c, line %d\n"), 82 delim, delim, line); 83 start = 0; 84 } else if (eq && *in == 'd' && *(in+1) == 'e' && 85 *(in+2) == 'l' && *(in+3) == 'i' && *(in+4) == 'm') { 86 for (p = in+5; *p; p++) 87 if (*p != ' ') { 88 if (*p == 'o' && *(p+1) == 'f') 89 delim = 0; 90 else 91 delim = *p; 92 break; 93 } 94 if (delim == 0) 95 (void) printf( 96 gettext(" Delim off, line %d\n"), 97 line); 98 else 99 (void) printf( 100 gettext(" New delims %c%c, line %d\n"), 101 delim, delim, line); 102 } 103 if (ndel > 0 && eq > 0) 104 (void) printf( 105 gettext(" %c%c in EQ, line %d\n"), delim, 106 delim, line); 107 if (ndel == 0) 108 continue; 109 totdel += ndel; 110 if (totdel%2) { 111 if (start == 0) 112 start = line; 113 else { 114 (void) printf( 115 gettext(" %d line %c%c, lines %d-%d\n"), 116 line-start+1, delim, delim, start, line); 117 start = line; 118 } 119 } else { 120 if (start > 0) { 121 (void) printf( 122 gettext(" %d line %c%c, lines %d-%d\n"), 123 line-start+1, delim, delim, start, line); 124 start = 0; 125 } 126 totdel = 0; 127 } 128 } 129 if (totdel) 130 (void) printf(gettext(" Unfinished %c%c\n"), delim, delim); 131 if (eq) 132 (void) printf(gettext(" Unfinished EQ\n")); 133 } 134