Fix spurious conform test failures

Message ID mvmoaix8z6a.fsf@hawking.suse.de
State Committed
Headers

Commit Message

Andreas Schwab July 27, 2015, 2:15 p.m. UTC
  String literals in the preprocessor output causes spurious test failures
because the tokenizer doesn't know how to skip over them, for example:

  Checking the namespace of "arpa/inet.h"... FAIL
    ------------------------------------------------------------------
    Namespace violation: "d"
    Namespace violation: "ror"
    Namespace violation: "swap"
    Namespace violation: "w"
    ------------------------------------------------------------------

Installed as obvious.

Andreas.

	* conform/conformtest.pl (checknamespace): Filter out string
	literals while tokenizing.
---
 conform/conformtest.pl | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Zack Weinberg July 27, 2015, 2:53 p.m. UTC | #1
Since it's not particularly difficult to write a Perl regex that
matches C string constants *with* \-escapes taken into account, can I
suggest we do that now instead of when we trip over it?  Also, should
do the same thing for character
constants.

    # Discard string and character constants.  Since this is preprocessor
    # output we need not worry about \-newline or un-terminated strings,
    # and since we just need to find the end, we don't need to distinguish
    # the various types of \-escapes.
    $str =~ s/" (?: [^"\\] | \\. )* "//xg;
    $str =~ s/' (?: [^'\\] | \\. )* '//xg;

zw
  

Patch

diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index a8a27f5..cc0944a 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -275,9 +275,8 @@  sub checknamespace {
     } else {
       # We have to tokenize the line.
       my($str) = $_;
-      my($index) = 0;
-      my($len) = length ($str);
 
+      $str =~ s/"[^"]*"//g;
       foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
 	if ($token ne "") {
 	  newtoken ($token, @allow);