check-format.pl: Extend exceptions for no SPC after trailing ';' in 'for (...;)'
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Mon, 28 Sep 2020 06:18:32 +0000 (08:18 +0200)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 30 Sep 2020 18:51:23 +0000 (20:51 +0200)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13019)

util/check-format-test-negatives.c
util/check-format.pl

index 478fe62e169ac61ead09937848928d6ca3b46dd6..d1de4104bc7869742317c34602e802e7533a0a11 100644 (file)
@@ -29,6 +29,13 @@ int f(void) /*
         /* entire-line comment may have same indent as normal code */
     }
 
+    for (;;)
+        ;
+    for (i = 0;;)
+        ;
+    for (i = 0; i < 1;)
+        ;
+
 #if X
     if (1) /* bad style: just part of control structure depends on #if */
 #else
index e3c0eaddb0094df3a213fba86fa2ef9c2c4ef8d3..8852f3df8cbc232ed4b1ebcdc574316758d8229e 100755 (executable)
@@ -658,7 +658,8 @@ while (<>) { # loop over all lines of all input files
         # treat remaining blinded comments and string literal contents as (single) space during matching below
         $intra_line =~ s/@+/ /g;                     # note that double SPC has already been handled above
         $intra_line =~ s/\s+$//;                     # strip any (resulting) space at EOL
-        $intra_line =~ s/(for\s*\();;(\))/"$1$2"/eg; # strip ';;' in for (;;)
+        $intra_line =~ s/(for\s*\([^;]*);;(\))/"$1$2"/eg; # strip trailing ';;' in for (;;)
+        $intra_line =~ s/(for\s*\([^;]+;[^;]+);(\))/"$1$2"/eg; # strip trailing ';' in for (;;)
         $intra_line =~ s/(=\s*)\{ /"$1@ "/eg;        # do not report {SPC in initializers such as ' = { 0, };'
         $intra_line =~ s/, \};/, @;/g;               # do not report SPC} in initializers such as ' = { 0, };'
         report("SPC before '$1'") if $intra_line =~ m/[\w)\]]\s+(\+\+|--)/;  # postfix ++/-- with preceding space