summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-06-26 21:04:01 -0700
committerAnders Broman <a.broman58@gmail.com>2015-06-27 16:25:41 +0000
commit48f7ce79e272636c407219a7df15f6f0cb0f93d6 (patch)
treedbb43d2958a515d66040bb980c81772de98912fe
parent13df6e9d9df2f8acb5e0093f437bcdab4c3cdfc5 (diff)
downloadwireshark-48f7ce79e272636c407219a7df15f6f0cb0f93d6.tar.gz
checkAPIs.pl: check how ui class files are included
flag up a warning if a ui class file is included from the current directory by using #include "" Visual Studio needs #include <> to make sure that we always pick up these files from the build directory if we're building with CMake combine this check with the other check for gcrypt.h so that included files are checked in one common subroutine Change-Id: If8420ff5886f8eb2a71aa8fbfe6bc5d2bda607ce Reviewed-on: https://code.wireshark.org/review/9189 Petri-Dish: Anders Broman <a.broman58@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rwxr-xr-xtools/checkAPIs.pl41
1 files changed, 31 insertions, 10 deletions
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index bc6059fd27..5738f9dc0b 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -1546,26 +1546,47 @@ sub check_value_string_arrays($$$)
return $cnt;
}
+
sub check_included_files($$)
{
my ($fileContentsRef, $filename) = @_;
my @incFiles;
- # wsutils/wsgcrypt.h is our wrapper around gcrypt.h, it must be excluded from the tests
- if ($filename =~ /wsgcrypt\.h/) {
- return;
+ @incFiles = (${$fileContentsRef} =~ m/\#include \s* ([<"].+[>"])/gox);
+
+ # only our wrapper file wsutils/wsgcrypt.h may include gcrypt.h
+ # all other files should include the wrapper
+ if ($filename !~ /wsgcrypt\.h/) {
+ foreach (@incFiles) {
+ if ( m#([<"]|/+)gcrypt\.h[>"]$# ) {
+ print STDERR "Warning: ".$filename.
+ " includes gcrypt.h directly. ".
+ "Include wsutil/wsgrypt.h instead.\n";
+ last;
+ }
+ }
}
- @incFiles = (${$fileContentsRef} =~ m/\#include \s* [<"](.+)[>"]/gox);
- foreach (@incFiles) {
- if ( m#(^|/+)gcrypt\.h$# ) {
- print STDERR "Warning: ".$filename." includes gcrypt.h directly. ".
- "Include wsutil/wsgrypt.h instead.\n";
- last;
+ # files in the ui/qt directory should include the ui class includes
+ # by using #include <>
+ # this ensures that Visual Studio picks up these files from the
+ # build directory if we're compiling with cmake
+ if ($filename =~ m#ui/qt/# ) {
+ foreach (@incFiles) {
+ if ( m#"ui_.*\.h"$# ) {
+ # strip the quotes to get the base name
+ # for the error message
+ s/\"//g;
+
+ print STDERR "$filename: ".
+ "Please use #include <$_> ".
+ "instead of #include \"$_\".\n";
+ }
}
}
}
+
sub check_proto_tree_add_XXX_encoding($$)
{
my ($fileContentsRef, $filename) = @_;
@@ -1905,7 +1926,7 @@ my $debug = 0;
(defined $_[1]) && print " >$_[1]<\n";
}
- # #if/#if 0/#else/#ndif processing
+ # #if/#if 0/#else/#endif processing
if (defined $_[1]) {
my ($if) = $_[1];
if ($if eq 'if') {