From 8e655da0225eb399675aaa05f4ba36e9347043ca Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Mon, 28 Sep 2020 08:18:32 +0200 Subject: [PATCH] check-format.pl: Extend exceptions for no SPC after trailing ';' in 'for (...;)' Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/13019) --- util/check-format-test-negatives.c | 7 +++++++ util/check-format.pl | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 -- 2.39.5