summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-09-28 08:18:32 +0200
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-09-30 20:51:23 +0200
commit8e655da0225eb399675aaa05f4ba36e9347043ca (patch)
treea605a682e4c7ee719cdb8811da2213606d246c41 /util
parentdf4ec3920386b1e6cba0976dac36b3c2456090fc (diff)
check-format.pl: Extend exceptions for no SPC after trailing ';' in 'for (...;)'
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13019)
Diffstat (limited to 'util')
-rw-r--r--util/check-format-test-negatives.c7
-rwxr-xr-xutil/check-format.pl3
2 files changed, 9 insertions, 1 deletions
diff --git a/util/check-format-test-negatives.c b/util/check-format-test-negatives.c
index 478fe62e16..d1de4104bc 100644
--- a/util/check-format-test-negatives.c
+++ b/util/check-format-test-negatives.c
@@ -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
diff --git a/util/check-format.pl b/util/check-format.pl
index e3c0eaddb0..8852f3df8c 100755
--- a/util/check-format.pl
+++ b/util/check-format.pl
@@ -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