mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 02:00:26 +02:00
* 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.
This commit is contained in:
parent
e723f8de40
commit
0f981281fd
7 changed files with 60 additions and 10 deletions
|
@ -105,7 +105,7 @@ modinclude_HEADERS = \
|
||||||
## and not a header -- headers are included in the distribution.
|
## and not a header -- headers are included in the distribution.
|
||||||
modinclude_DATA = scmconfig.h
|
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_ldadd = libguile.la ${THREAD_LIBS_LOCAL}
|
||||||
check_PROGRAMS = gh_test_c gh_test_repl
|
check_PROGRAMS = gh_test_c gh_test_repl
|
||||||
|
|
|
@ -296,7 +296,7 @@ SCM_DEFINE (scm_make_iloc, "make-iloc", 3, 0, 0,
|
||||||
SCM_DEFINE (scm_iloc_p, "iloc?", 1, 0, 0,
|
SCM_DEFINE (scm_iloc_p, "iloc?", 1, 0, 0,
|
||||||
(SCM obj),
|
(SCM obj),
|
||||||
"")
|
"")
|
||||||
#define FUNC_NAME s_scm_iGUILE_p
|
#define FUNC_NAME s_scm_iloc_p
|
||||||
{
|
{
|
||||||
return SCM_BOOL(SCM_ILOCP (obj));
|
return SCM_BOOL(SCM_ILOCP (obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@ trap "rm -f $temp" 0 1 2 15
|
||||||
## Let the user override the preprocessor autoconf found.
|
## Let the user override the preprocessor autoconf found.
|
||||||
test -n "${CPP+set}" || CPP="@CPP@"
|
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
|
## We must use a temporary file here, instead of a pipe, because we
|
||||||
## need to know if CPP exits with a non-zero status.
|
## need to know if CPP exits with a non-zero status.
|
||||||
${CPP} -DSCM_MAGIC_SNARFER "$@" > ${temp} || exit $?
|
${CPP} -DSCM_MAGIC_SNARFER "$@" > ${temp} || exit $?
|
||||||
|
|
46
libguile/guile-func-name-check.in
Normal file
46
libguile/guile-func-name-check.in
Normal file
|
@ -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; }
|
|
@ -1041,7 +1041,7 @@ the @code{tmpnam} function in the system libraries.")
|
||||||
SCM_SYSCALL (tmpnam (name););
|
SCM_SYSCALL (tmpnam (name););
|
||||||
return scm_makfrom0str (name);
|
return scm_makfrom0str (name);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME;
|
#undef FUNC_NAME
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2050,7 +2050,8 @@ same type, and have corresponding elements which are either
|
||||||
@code{equal?} in that a one dimensional shared array may be
|
@code{equal?} in that a one dimensional shared array may be
|
||||||
@var{array-equal?} but not @var{equal?} to a vector or uniform vector.")
|
@var{array-equal?} but not @var{equal?} to a vector or uniform vector.")
|
||||||
#define FUNC_NAME s_scm_array_equal_p
|
#define FUNC_NAME s_scm_array_equal_p
|
||||||
...
|
{
|
||||||
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -743,7 +743,7 @@ SCM_DEFINE (scm_sort_x, "sort!", 2, 0, 0,
|
||||||
else
|
else
|
||||||
RETURN_SCM_WTA (1,items);
|
RETURN_SCM_WTA (1,items);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME /* scm_sort_x */
|
#undef FUNC_NAME
|
||||||
|
|
||||||
/* scm_sort manages lists and vectors, not stable sort */
|
/* scm_sort manages lists and vectors, not stable sort */
|
||||||
|
|
||||||
|
@ -781,7 +781,7 @@ SCM_DEFINE (scm_sort, "sort", 2, 0, 0,
|
||||||
else
|
else
|
||||||
RETURN_SCM_WTA (1,items);
|
RETURN_SCM_WTA (1,items);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME /* scm_sort */
|
#undef FUNC_NAME
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scm_merge_vector_x (void *const vecbase,
|
scm_merge_vector_x (void *const vecbase,
|
||||||
|
@ -872,7 +872,7 @@ SCM_DEFINE (scm_stable_sort_x, "stable-sort!", 2, 0, 0,
|
||||||
else
|
else
|
||||||
RETURN_SCM_WTA (1,items);
|
RETURN_SCM_WTA (1,items);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME /* scm_stable_sort_x */
|
#undef FUNC_NAME
|
||||||
|
|
||||||
/* stable_sort manages lists and vectors */
|
/* stable_sort manages lists and vectors */
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ SCM_DEFINE (scm_stable_sort, "stable-sort", 2, 0, 0,
|
||||||
else
|
else
|
||||||
RETURN_SCM_WTA (1,items);
|
RETURN_SCM_WTA (1,items);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME /* scm_stable_sort */
|
#undef FUNC_NAME
|
||||||
|
|
||||||
/* stable */
|
/* stable */
|
||||||
SCM_DEFINE (scm_sort_list_x, "sort-list!", 2, 0, 0,
|
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);
|
SCM_VALIDATE_NIM (2,less);
|
||||||
return scm_merge_list_step (&items, scm_cmp_function (less), less, len);
|
return scm_merge_list_step (&items, scm_cmp_function (less), less, len);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME /* scm_sort_list_x */
|
#undef FUNC_NAME
|
||||||
|
|
||||||
/* stable */
|
/* stable */
|
||||||
SCM_DEFINE (scm_sort_list, "sort-list", 2, 0, 0,
|
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);
|
items = scm_list_copy (items);
|
||||||
return scm_merge_list_step (&items, scm_cmp_function (less), less, len);
|
return scm_merge_list_step (&items, scm_cmp_function (less), less, len);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME /* scm_sort_list_x */
|
#undef FUNC_NAME
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_init_sort ()
|
scm_init_sort ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue