1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00
guile/libguile/guile-func-name-check.in
Greg J. Badros 0f981281fd * guile-func-name-check.in: Added this script to statically check
#define FUNC_NAME, #undef FUNC_NAME in the source.

* sort.c, posix.c: Fix #undef FUNC_NAME lines to not have trailing
redundant comment, semicolon; caught by new guile-func-name-check
script.

* debug.c: Fix mistaken #define FUNC_NAME for scm_make_iloc.
Caught by new guile-func-name-check-script.

* Makefile.am: Added guile-func-name-check to bin_SCRIPTS

* ramap.c: Fix #if 0'd out code to be syntactically acceptable to
guile-func-name-check.

* guile-doc-snarf.in: Run guile-func-name-check on the file before
doing the snarf.
2000-01-11 21:47:57 +00:00

46 lines
1.2 KiB
Awk

#!/usr/bin/awk -f
# Written by Greg J. Badros, <gjb@cs.washington.edu>
# 11-Jan-2000
BEGIN {
filename = ARGV[1];
}
/^SCM_DEFINE/ {
func_name = $0;
sub(/^[^\(\n]*\([ \t]*/,"", func_name);
sub(/[ \t]*,.*/,"", func_name);
# print func_name; # GJB:FIXME:: flag to do this to list primitives?
in_a_func = 1;
}
in_a_func && /^\{/ {
if (!match(last_line,/^#define[ \t]+FUNC_NAME[ \t]+/)) {
printf filename ":" NR ":***" > "/dev/stderr";
print "Missing or erroneous `#define FUNC_NAME s_" func_name "'" > "/dev/stderr";
} else {
sub(/^#define[ \t]+FUNC_NAME[ \t]+s_/, "", last_line);
sub(/[ \t]*$/,"",last_line);
if (last_line != func_name) {
printf filename ":" NR ":***" > "/dev/stderr";
print "Mismatching FUNC_NAME. Should be: `#define FUNC_NAME s_" func_name "'" > "/dev/stderr";
}
}
}
1 == next_line_better_be_undef {
if (!match($0,/^#undef FUNC_NAME[ \t]*$/)) {
printf filename ":" NR ":***" > "/dev/stderr";
print "Missing or erroneous #undef for " func_name ": "
"Got `" $0 "' instead." > "/dev/stderr";
}
in_a_func = "";
func_name = "";
next_line_better_be_undef = 0;
}
in_a_func && /^\}/ {
next_line_better_be_undef = 1;
}
{ last_line = $0; }