From 9c6b71e9b3334439ae6348b38412ae6a8fb154ad Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 25 Jun 2010 11:12:21 +0200 Subject: [PATCH 3/8] Comment, whitespace munging; nfc. * libguile/guile-func-name-check: Add comments; refill; kill eol whitespace. --- libguile/guile-func-name-check | 81 +++++++++++++++++++++++---------------- 1 files changed, 48 insertions(+), 33 deletions(-) diff --git a/libguile/guile-func-name-check b/libguile/guile-func-name-check index 8b4924e..f00b522 100644 --- a/libguile/guile-func-name-check +++ b/libguile/guile-func-name-check @@ -1,65 +1,80 @@ #!/usr/bin/awk -f # -# Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. -# +# guile-func-name-check +# +# Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 3, 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 # Lesser General Public License for more details. -# +# # You should have received a copy of the GNU Lesser General Public # License along with this software; see the file COPYING.LESSER. If # not, write to the Free Software Foundation, Inc., 51 Franklin # Street, Fifth Floor, Boston, MA 02110-1301 USA # -# Written by Greg J. Badros, -# 11-Jan-2000 +# Author: Greg J. Badros, BEGIN { - filename = ARGV[1]; - in_a_func = 0; + filename = ARGV[1]; + in_a_func = 0; } -/^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; +# Extract the function name from "SCM_DEFINE (foo, ...". +# FIXME: This loses if the open paren is on the next line. +/^SCM_DEFINE/ { + func_name = $0; + sub (/^[^\(\n]*\([ \t]*/, "", func_name); + sub (/[ \t]*,.*/, "", func_name); + in_a_func = 1; } +# Check that for "SCM_DEFINE (foo, ...)", we see: +# #define FUNC_NAME s_foo +# { +# FIXME: This loses for C string-literal (#define FUNC_NAME "foo"). +# FIXME: This loses if #define is inside the curly brace. /^\{/ && 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"; + 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"; + } } - } } +# If previous line closed the function, check that we see "#undef FUNC_NAME". +# FIXME: This loses if #undef is inside the curly brace. 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; + 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; } +# Note function closing. /^\}/ && in_a_func { - next_line_better_be_undef = 1; + next_line_better_be_undef = 1; } +# Remember this line for the next cycle. { last_line = $0; } + +# guile-func-name-check ends here -- 1.6.3.2