summaryrefslogtreecommitdiffstats
path: root/bin/checkposix
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-09-02 15:37:49 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-09-02 15:37:49 (GMT)
commit07dacb9486230fe2522efca266ab06f4558527c3 (patch)
tree98a034786d7de44863d7d6e247b8b4261ab40d32 /bin/checkposix
parent064648a1f6c43e36da540ca28136b72bd038084e (diff)
downloadhdf5-07dacb9486230fe2522efca266ab06f4558527c3.zip
hdf5-07dacb9486230fe2522efca266ab06f4558527c3.tar.gz
hdf5-07dacb9486230fe2522efca266ab06f4558527c3.tar.bz2
[svn-r60] ./bin/checkposix NEW
Perl script that looks for Posix functions that haven't been protected by adding `HD' to the beginning of the name. It takes a list of .c file names as arguments. ./bin/errors NEW A filter that takes a function prologue and function body as standard input and updates the error list in the prologue based on the function body. You must add the `ERRORS' or `Errors:' field to the prologue before you pass it through this filter or else the errors come out as a separate comment. The errors field must be terminated with a blank line in the prologue so we know where the end is. I may enhance this in the future to take an entire file as standard input instead of individual functions.
Diffstat (limited to 'bin/checkposix')
-rwxr-xr-xbin/checkposix61
1 files changed, 61 insertions, 0 deletions
diff --git a/bin/checkposix b/bin/checkposix
new file mode 100755
index 0000000..aaf9169
--- /dev/null
+++ b/bin/checkposix
@@ -0,0 +1,61 @@
+#!/usr/local/bin/perl -w
+require 5.003;
+
+# Copyright (C) 1997 National Center for Supercomputing Applications.
+# All rights reserved.
+#
+# Robb Matzke, matzke@llnl.gov
+# 30 Aug 1997
+#
+# Purpose: Given the names of C source files this script will print the
+# file name, line number, and function name of any function that
+# doesn't begin with the letter `h' or `H' as stipulated by the
+# HDF5 programming style guide.
+#
+# Emacs users can run this script as the compile command and
+# use `next-error' (usually bound to M-`) to find each name
+# violation.
+
+while (<>) {
+
+ # Get rid of comments by removing the inside part.
+ s|/\*.*?\*/||g;
+ if ($in_comment) {
+ if (/\*\//) {
+ s|.*?\*/||;
+ $in_comment = 0;
+ } else {
+ $_="\n";
+ }
+ } elsif (m|/\*|) {
+ s|/\*.*||;
+ $in_comment = 1;
+ }
+
+ # Get rid of string constants if they begin and end on this line.
+ s/([\'\"])([^\1]|\\\1)*?\1/$1$1/g;
+
+
+ # Now find all function calls on this line
+ while (($name)=/\b([a-gi-z_A-GI-Z]\w*)\s*\(/) {
+ $_ = $';
+
+ # Ignore C statements that look sort of like function
+ # calls.
+ next if $name =~ /^(if|for|return|sizeof|switch|while)$/;
+
+ # These are really HDF5 functions/macros even though they don't
+ # start with `h' or `H'.
+ next if $name =~ /^FUNC_(ENTER|LEAVE)$/;
+ next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)$/;
+ next if $name =~ /^(MIN|MAX3?|NELMTS|BOUND|CONSTR)$/;
+
+ # These functions/macros are exempt.
+ next if $name =~ /^(assert|main|[fs]?printf)$/;
+
+ print "$ARGV:$.: $name\n";
+ }
+
+} continue {
+ close ARGV if eof;
+}