diff options
author | Greg J. Badros <gjb@cs.washington.edu> | 2000-01-11 21:47:57 +0000 |
---|---|---|
committer | Greg J. Badros <gjb@cs.washington.edu> | 2000-01-11 21:47:57 +0000 |
commit | 0f981281fd134c61c30fad8e25f26647890848d2 (patch) | |
tree | 0aeb4be29d73014f43a8347ffa30b8b8742962ab | |
parent | e723f8de40a7b727c7c970cdaaf1e580b8720d66 (diff) | |
download | guile-0f981281fd134c61c30fad8e25f26647890848d2.tar.gz |
* 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.
-rw-r--r-- | libguile/Makefile.am | 2 | ||||
-rw-r--r-- | libguile/debug.c | 2 | ||||
-rwxr-xr-x | libguile/guile-doc-snarf.in | 3 | ||||
-rw-r--r-- | libguile/guile-func-name-check.in | 46 | ||||
-rw-r--r-- | libguile/posix.c | 2 | ||||
-rw-r--r-- | libguile/ramap.c | 3 | ||||
-rw-r--r-- | libguile/sort.c | 12 |
7 files changed, 60 insertions, 10 deletions
diff --git a/libguile/Makefile.am b/libguile/Makefile.am index e750d887d..14f27da8d 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -105,7 +105,7 @@ modinclude_HEADERS = \ ## and not a header -- headers are included in the distribution. modinclude_DATA = scmconfig.h -bin_SCRIPTS = guile-snarf guile-doc-snarf guile-snarf.awk +bin_SCRIPTS = guile-snarf guile-doc-snarf guile-snarf.awk guile-func-name-check check_ldadd = libguile.la ${THREAD_LIBS_LOCAL} check_PROGRAMS = gh_test_c gh_test_repl diff --git a/libguile/debug.c b/libguile/debug.c index ad1be6a99..c2af8bbfa 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -296,7 +296,7 @@ SCM_DEFINE (scm_make_iloc, "make-iloc", 3, 0, 0, SCM_DEFINE (scm_iloc_p, "iloc?", 1, 0, 0, (SCM obj), "") -#define FUNC_NAME s_scm_iGUILE_p +#define FUNC_NAME s_scm_iloc_p { return SCM_BOOL(SCM_ILOCP (obj)); } diff --git a/libguile/guile-doc-snarf.in b/libguile/guile-doc-snarf.in index 600ee0b62..2aa0f7ce2 100755 --- a/libguile/guile-doc-snarf.in +++ b/libguile/guile-doc-snarf.in @@ -21,6 +21,9 @@ trap "rm -f $temp" 0 1 2 15 ## Let the user override the preprocessor autoconf found. test -n "${CPP+set}" || CPP="@CPP@" +## Must run guile-func-name-check on the unpreprocessed source +guile-func-name-check "$filename" + ## We must use a temporary file here, instead of a pipe, because we ## need to know if CPP exits with a non-zero status. ${CPP} -DSCM_MAGIC_SNARFER "$@" > ${temp} || exit $? diff --git a/libguile/guile-func-name-check.in b/libguile/guile-func-name-check.in new file mode 100644 index 000000000..fcd29b17c --- /dev/null +++ b/libguile/guile-func-name-check.in @@ -0,0 +1,46 @@ +#!/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; } diff --git a/libguile/posix.c b/libguile/posix.c index 9b7abe591..3efc6aa02 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1041,7 +1041,7 @@ the @code{tmpnam} function in the system libraries.") SCM_SYSCALL (tmpnam (name);); return scm_makfrom0str (name); } -#undef FUNC_NAME; +#undef FUNC_NAME #endif diff --git a/libguile/ramap.c b/libguile/ramap.c index 133d0e2db..0aa6582a7 100644 --- a/libguile/ramap.c +++ b/libguile/ramap.c @@ -2050,7 +2050,8 @@ same type, and have corresponding elements which are either @code{equal?} in that a one dimensional shared array may be @var{array-equal?} but not @var{equal?} to a vector or uniform vector.") #define FUNC_NAME s_scm_array_equal_p -... +{ +} #undef FUNC_NAME #endif diff --git a/libguile/sort.c b/libguile/sort.c index 7a1d5914a..da1f5bb0f 100644 --- a/libguile/sort.c +++ b/libguile/sort.c @@ -743,7 +743,7 @@ SCM_DEFINE (scm_sort_x, "sort!", 2, 0, 0, else RETURN_SCM_WTA (1,items); } -#undef FUNC_NAME /* scm_sort_x */ +#undef FUNC_NAME /* scm_sort manages lists and vectors, not stable sort */ @@ -781,7 +781,7 @@ SCM_DEFINE (scm_sort, "sort", 2, 0, 0, else RETURN_SCM_WTA (1,items); } -#undef FUNC_NAME /* scm_sort */ +#undef FUNC_NAME static void scm_merge_vector_x (void *const vecbase, @@ -872,7 +872,7 @@ SCM_DEFINE (scm_stable_sort_x, "stable-sort!", 2, 0, 0, else RETURN_SCM_WTA (1,items); } -#undef FUNC_NAME /* scm_stable_sort_x */ +#undef FUNC_NAME /* stable_sort manages lists and vectors */ @@ -916,7 +916,7 @@ SCM_DEFINE (scm_stable_sort, "stable-sort", 2, 0, 0, else RETURN_SCM_WTA (1,items); } -#undef FUNC_NAME /* scm_stable_sort */ +#undef FUNC_NAME /* stable */ SCM_DEFINE (scm_sort_list_x, "sort-list!", 2, 0, 0, @@ -929,7 +929,7 @@ SCM_DEFINE (scm_sort_list_x, "sort-list!", 2, 0, 0, SCM_VALIDATE_NIM (2,less); return scm_merge_list_step (&items, scm_cmp_function (less), less, len); } -#undef FUNC_NAME /* scm_sort_list_x */ +#undef FUNC_NAME /* stable */ SCM_DEFINE (scm_sort_list, "sort-list", 2, 0, 0, @@ -943,7 +943,7 @@ SCM_DEFINE (scm_sort_list, "sort-list", 2, 0, 0, items = scm_list_copy (items); return scm_merge_list_step (&items, scm_cmp_function (less), less, len); } -#undef FUNC_NAME /* scm_sort_list_x */ +#undef FUNC_NAME void scm_init_sort () |