Explorar o código

check-format.pl: Fix report on space before ';' and allow it after ')'

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17434)
Dr. David von Oheimb %!s(int64=2) %!d(string=hai) anos
pai
achega
c30bc4e209
Modificáronse 2 ficheiros con 3 adicións e 1 borrados
  1. 2 0
      util/check-format-test-negatives.c
  2. 1 1
      util/check-format.pl

+ 2 - 0
util/check-format-test-negatives.c

@@ -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 */

+ 1 - 1
util/check-format.pl

@@ -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'