guile-func-name-check 2.0 KB

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