check-format.pl: Fix report on space before ';' and allow it after ')'
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Thu, 6 Jan 2022 22:14:27 +0000 (23:14 +0100)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 20 Jul 2022 11:07:02 +0000 (13:07 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
(cherry picked from commit c30bc4e2093f47a37736944da548653bc08d774d)

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

index 3ea792a72fcb788f48c99cec75e16f3fdc006f2c..4d925572c408ee3dd4ff6f631752b1bfcdbbc3b9 100644 (file)
@@ -70,6 +70,8 @@ int f(void) /*
         ;
     for (i = 0; i < 1;)
         ;
+    for (;;) ; /* should not trigger: space before ';' */
+ lab: ;  /* should not trigger: space before ';' */
 
 #if X
     if (1) /* bad style: just part of control structure depends on #if */
index 836fe30fa910b3aa85cf236e37d2d399bbf9d73b..17bdc0aa15a0ccc1e837d38db862e54b757bb40e 100755 (executable)
@@ -684,7 +684,7 @@ while (<>) { # loop over all lines of all input files
         report("space before '$1'") if $intra_line =~ m/\s(\.|->)/;            # '.' or '->' with preceding space
         report("space after '$1'")  if $intra_line =~ m/(\.|->)\s/;            # '.' or '->' with following space
         $intra_line =~ s/\-\>|\+\+|\-\-/@/g;         # blind '->,', '++', and '--'
-        report("space before '$2'")     if $intra_line =~ m/[^:]\s+(;)/;       # space before ';' but not after ':'
+        report("space before '$1'")     if $intra_line =~ m/[^:)]\s+(;)/;      # space before ';' but not after ':' or ')'
         report("space before '$1'")     if $intra_line =~ m/\s([,)\]])/;       # space before ,)]
         report("space after '$1'")      if $intra_line =~ m/([(\[~!])\s/;      # space after ([~!
         report("space after '$1'")      if $intra_line =~ m/(defined)\s/;      # space after 'defined'