From 5e5cc440a26c93c9edfcf596eddc0974702d6d2c Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sun, 13 May 2018 22:38:25 +0200 Subject: checkAPIs: handle C++ / C99-style '//' comments Avoids a warning in epan/dissectors/packet-enip.c due to "time" appearing in a comment. Change-Id: I88b6856425c09fc3b8cb2edc345047062a07b662 Reviewed-on: https://code.wireshark.org/review/27516 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- tools/checkAPIs.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl index 725fb2b08a..51af5160de 100755 --- a/tools/checkAPIs.pl +++ b/tools/checkAPIs.pl @@ -1005,8 +1005,9 @@ my $debug = 0; # 1. A complicated regex which matches C-style comments. my $CComment = qr{ / [*] [^*]* [*]+ (?: [^/*] [^*]* [*]+ )* / }x; -# 1.a A regex that matches C++-style comments. -#my $CppComment = qr{ // (.*?) \n }x; +# 1.a A regex that matches C++/C99-style comments. +# XXX handle comments after a statement and not just at the beginning of a line. +my $CppComment = qr{ ^ \s* // (.*?) \n }xm; # 2. A regex which matches double-quoted strings. # ?s added so that strings containing a 'line continuation' @@ -1157,7 +1158,7 @@ while ($_ = pop @filelist) } # Remove all the C-comments - $fileContents =~ s{ $CComment } []xog; + $fileContents =~ s{ $CComment | $CppComment } []xog; # optionally check the hf entries (including those under #if 0) if ($check_hf) { -- cgit v1.2.3