aboutsummaryrefslogtreecommitdiff
path: root/scripts/guile-func-name-check
blob: 86b00aeff1ebecff9ff24341c6a62fd5f0a55727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /usr/bin/awk -f
#
#  Copyright (C) 2000 Free Software Foundation, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
# 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; }

Return to:

Send suggestions and report system problems to the System administrator.