The FSF has a new address.
[bpt/guile.git] / libguile / guile-func-name-check.in
CommitLineData
0f981281 1#!/usr/bin/awk -f
d6a35f3f 2#
58ade102 3# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
d6a35f3f
MV
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this software; see the file COPYING. If not, write to
92205699
MV
17# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301 USA
d6a35f3f 19#
0f981281
GB
20# Written by Greg J. Badros, <gjb@cs.washington.edu>
21# 11-Jan-2000
22
23BEGIN {
24 filename = ARGV[1];
77cd7f80 25 in_a_func = 0;
0f981281
GB
26}
27
28/^SCM_DEFINE/ {
29 func_name = $0;
30 sub(/^[^\(\n]*\([ \t]*/,"", func_name);
31 sub(/[ \t]*,.*/,"", func_name);
32# print func_name; # GJB:FIXME:: flag to do this to list primitives?
33 in_a_func = 1;
34}
35
77cd7f80 36/^\{/ && in_a_func {
0f981281
GB
37 if (!match(last_line,/^#define[ \t]+FUNC_NAME[ \t]+/)) {
38 printf filename ":" NR ":***" > "/dev/stderr";
39 print "Missing or erroneous `#define FUNC_NAME s_" func_name "'" > "/dev/stderr";
40 } else {
41 sub(/^#define[ \t]+FUNC_NAME[ \t]+s_/, "", last_line);
42 sub(/[ \t]*$/,"",last_line);
43 if (last_line != func_name) {
44 printf filename ":" NR ":***" > "/dev/stderr";
45 print "Mismatching FUNC_NAME. Should be: `#define FUNC_NAME s_" func_name "'" > "/dev/stderr";
46 }
47 }
48}
49
501 == next_line_better_be_undef {
51 if (!match($0,/^#undef FUNC_NAME[ \t]*$/)) {
52 printf filename ":" NR ":***" > "/dev/stderr";
53 print "Missing or erroneous #undef for " func_name ": "
54 "Got `" $0 "' instead." > "/dev/stderr";
55 }
56 in_a_func = "";
57 func_name = "";
58 next_line_better_be_undef = 0;
59}
60
77cd7f80 61/^\}/ && in_a_func {
0f981281
GB
62 next_line_better_be_undef = 1;
63}
64
65{ last_line = $0; }