13 int check_expr(char *buffer, char *error_report)
21 for(cp=buffer;*cp;cp++)
37 || *cp == ')' These are pretty hard to track, as they are in funcalls, etc. */
42 /* skip to the other end */
44 while( *cp && *cp != '"' )
48 fprintf(stderr,"Trouble? Unterminated double quote found at line %d\n",
54 if( ((*cp == '>'||*cp == '<' ||*cp=='!') && *(cp+1) == '=' ) )
63 if( (cp > buffer && *(cp-1) != ' ') || *(cp+oplen) != ' ' )
67 sprintf(tbuf,"WARNING: line %d, '%c' operator not separated by spaces. This may lead to confusion. You may wish to use double quotes to quote the grouping it is in. Please check!\n",
70 sprintf(tbuf,"WARNING: line %d, '%c%c' operator not separated by spaces. This may lead to confusion. You may wish to use double quotes to quote the grouping it is in. Please check!\n",
71 lineno, *cp, *(cp+1));
72 strcat(error_report,tbuf);
84 void parse_file(char *fname)
86 FILE *f = fopen(fname,"r");
87 FILE *l = fopen("expr2_log","w");
90 char buffer[30000]; /* I sure hope no expr gets this big! */
94 fprintf(stderr,"Couldn't open %s for reading... need an extensions.conf file to parse!\n");
99 fprintf(stderr,"Couldn't open 'expr2_log' file for writing... please fix and re-run!\n");
105 while( (c1 = fgetc(f)) != EOF )
111 if( last_char == '$' )
117 char error_report[30000];
119 while( (c1 = fgetc(f)) != EOF )
127 fprintf(l, "ERROR-- A newline in an expression? Weird! ...at line %d\n", lineno);
130 printf("--- ERROR --- A newline in the middle of an expression at line %d!\n", lineno);
135 buffer[bufcount++] = c1;
139 fprintf(l, "ERROR-- End of File Reached in the middle of an Expr at line %d\n", lineno);
142 printf("--- ERROR --- EOF reached in middle of an expression at line %d!\n", lineno);
146 buffer[bufcount] = 0;
148 expr_tot_size += bufcount;
150 if( bufcount > expr_max_size )
151 expr_max_size = bufcount;
153 retval = check_expr(buffer, error_report); /* check_expr should bump the warning counter */
156 /* print error report */
157 printf("Warning(s) at line %d, expression: $[%s]; see expr2_log file for details\n",
159 fprintf(l, "%s", error_report);
163 printf("OK -- $[%s] at line %d\n", buffer, lineno);
170 printf("Summary:\n Expressions detected: %d\n Expressions OK: %d\n Total # Warnings: %d\n Longest Expr: %d chars\n Ave expr len: %d chars\n",
175 (expr_count) ? expr_tot_size/expr_count : 0);
182 main(int argc,char **argv)
186 printf("Hey-- give me a path to an extensions.conf file!\n");