guile-func-name-check.in 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/awk -f
  2. # Written by Greg J. Badros, <gjb@cs.washington.edu>
  3. # 11-Jan-2000
  4. BEGIN {
  5. filename = ARGV[1];
  6. }
  7. /^SCM_DEFINE/ {
  8. func_name = $0;
  9. sub(/^[^\(\n]*\([ \t]*/,"", func_name);
  10. sub(/[ \t]*,.*/,"", func_name);
  11. # print func_name; # GJB:FIXME:: flag to do this to list primitives?
  12. in_a_func = 1;
  13. }
  14. in_a_func && /^\{/ {
  15. if (!match(last_line,/^#define[ \t]+FUNC_NAME[ \t]+/)) {
  16. printf filename ":" NR ":***" > "/dev/stderr";
  17. print "Missing or erroneous `#define FUNC_NAME s_" func_name "'" > "/dev/stderr";
  18. } else {
  19. sub(/^#define[ \t]+FUNC_NAME[ \t]+s_/, "", last_line);
  20. sub(/[ \t]*$/,"",last_line);
  21. if (last_line != func_name) {
  22. printf filename ":" NR ":***" > "/dev/stderr";
  23. print "Mismatching FUNC_NAME. Should be: `#define FUNC_NAME s_" func_name "'" > "/dev/stderr";
  24. }
  25. }
  26. }
  27. 1 == next_line_better_be_undef {
  28. if (!match($0,/^#undef FUNC_NAME[ \t]*$/)) {
  29. printf filename ":" NR ":***" > "/dev/stderr";
  30. print "Missing or erroneous #undef for " func_name ": "
  31. "Got `" $0 "' instead." > "/dev/stderr";
  32. }
  33. in_a_func = "";
  34. func_name = "";
  35. next_line_better_be_undef = 0;
  36. }
  37. in_a_func && /^\}/ {
  38. next_line_better_be_undef = 1;
  39. }
  40. { last_line = $0; }