1997-09-02 23:37:49 +08:00
|
|
|
#!/usr/local/bin/perl -w
|
|
|
|
require 5.003;
|
|
|
|
|
2003-04-01 01:39:53 +08:00
|
|
|
#
|
|
|
|
# Copyright by the Board of Trustees of the University of Illinois.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This file is part of HDF5. The full HDF5 copyright notice, including
|
|
|
|
# terms governing use, modification, and redistribution, is contained in
|
|
|
|
# the files COPYING and Copyright.html. COPYING can be found at the root
|
|
|
|
# of the source code distribution tree; Copyright.html can be found at the
|
|
|
|
# root level of an installed copy of the electronic HDF5 document set and
|
|
|
|
# is linked from the top-level documents page. It can also be found at
|
|
|
|
# http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have
|
|
|
|
# access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu.
|
1997-09-02 23:37:49 +08:00
|
|
|
#
|
|
|
|
# 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;
|
|
|
|
|
1998-07-18 03:03:43 +08:00
|
|
|
# Get rid of preprocessor directives
|
|
|
|
s/^\#.*//;
|
1997-09-02 23:37:49 +08:00
|
|
|
|
|
|
|
# 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.
|
1998-01-31 03:25:44 +08:00
|
|
|
next if $name =~ /^(if|for|return|sizeof|switch|while|void)$/;
|
1997-09-02 23:37:49 +08:00
|
|
|
|
1998-09-09 03:15:44 +08:00
|
|
|
# Ignore things that get misdetected because of the simplified
|
|
|
|
# parsing that takes place here.
|
|
|
|
next if $name =~ /^int$/;
|
|
|
|
|
1997-09-02 23:37:49 +08:00
|
|
|
# These are really HDF5 functions/macros even though they don't
|
|
|
|
# start with `h' or `H'.
|
1998-01-31 03:25:44 +08:00
|
|
|
next if $name =~ /^FUNC_(ENTER|LEAVE)(_INIT)?$/;
|
1997-09-02 23:37:49 +08:00
|
|
|
next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)$/;
|
1998-09-09 03:15:44 +08:00
|
|
|
next if $name =~ /^(MIN3?|MAX3?|NELMTS|BOUND|CONSTR)$/;
|
2002-04-03 06:08:23 +08:00
|
|
|
next if $name =~ /^IS_H5FD_MPIO$/;
|
1998-09-09 03:15:44 +08:00
|
|
|
next if $name =~ /^addr_defined$/;
|
1997-09-02 23:37:49 +08:00
|
|
|
|
|
|
|
# These functions/macros are exempt.
|
1998-09-09 03:15:44 +08:00
|
|
|
next if $name =~ /^(assert|main|[fs]?printf|va_(start|arg|end))$/;
|
1997-09-02 23:37:49 +08:00
|
|
|
|
2002-04-03 06:08:23 +08:00
|
|
|
# These are MPI function calls. Ignore them.
|
|
|
|
next if $name =~ /^MPI_/;
|
|
|
|
|
|
|
|
# These are POSIX threads function calls. Ignore them.
|
|
|
|
next if $name =~ /^pthread_/;
|
|
|
|
|
1997-09-02 23:37:49 +08:00
|
|
|
print "$ARGV:$.: $name\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
} continue {
|
|
|
|
close ARGV if eof;
|
|
|
|
}
|