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