diff --git a/tests/func_chk.c b/tests/func_chk.c new file mode 100644 index 000000000..7ff8e1eb1 --- /dev/null +++ b/tests/func_chk.c @@ -0,0 +1,49 @@ +/* this can change for balanced ENTERFUNC/RETURNFUNC statements */ +/* RETURNFUNC2 is used when ENTERFUNC is not used in a function */ +#include +#include + +int main(int argc, char *argv[]) +{ + char buf[4096]; + char buf2[4096]; + FILE *fp = fopen(argv[1], "r"); + int linenum = 0; + int enterfunc = 0; + int infunc = 0; + int retval = 0; + retval = 0; + + while (fgets(buf, sizeof(buf), fp)) + { + ++linenum; + buf[16] = 0; + + if (strstr(buf, "ENTERFUNC;")) { enterfunc = 1; } + + if (enterfunc && strstr(buf, "RETURNFUNC2")) + { + printf("Line#%d need RETURNFUNC %s\n", linenum, argv[1]); + retval = 1; + } + + strcpy(buf2, buf); + buf2[15] = 0; // truncate the string + + if (!enterfunc && strstr(buf2, "RETURNFUNC(")) + { + printf("Line#%d need RETURNFUNC2 %s\n", linenum, argv[1]); + retval = 1; + } + + if (strstr(buf2, "RETURNFUNC(")) + { + if (enterfunc == 0) { printf("Line#%d no matching ENTERFUNC %s\n", linenum, argv[1]); } + + enterfunc = 0; + } + } + + fclose(fp); + return retval; +}