@@ -792,7 +792,7 @@ sub check_nested_nonblock_indents {
792
792
# treat remaining blinded comments and string literal contents as (single) space during matching below
793
793
$intra_line =~ s / @+/ / g ; # note that extra SPC has already been handled above
794
794
$intra_line =~ s /\s +$// ; # strip any (resulting) space at EOL
795
- # replace ';;' or '; ;' by ';' in "for(;;)" and in "for (...)" unless "..." contains just SPC and ';' characters:
795
+ # replace ';;' or '; ;' by ';' in "for (;;)" and in "for (...)" unless "..." contains just SPC and ';' characters:
796
796
$intra_line =~ s / ((^|\W )for\s *\( )([^;]*?)(\s *)(;\s ?);(\s *)([^;]*)(\) )/
797
797
"$1$3$4 ".("$3$4$5$6$7 " eq ";" || $3 ne "" || $7 ne "" ? "" : $5 ).";$6$7$8 "/ eg ;
798
798
# strip trailing ';' or '; ' in "for (...)" except in "for (;;)" or "for (;; )":
@@ -905,7 +905,7 @@ sub check_nested_nonblock_indents {
905
905
# handle opening brace '{' after if/else/while/for/switch/do on line before
906
906
if ($hanging_offset > 0 && m/^[\s @]*{/ && # leading opening '{'
907
907
$line_before > 0 &&
908
- $contents_before_ =~ m/(^|^.*\W )(if|else|while|for|switch|do)(\W .*$ |$ )/) {
908
+ $contents_before_ =~ m/(^|^.*\W )(if|else|while|for|(OSSL_)?LIST_FOREACH(_ \w +)?| switch|do)(\W .*$ |$ )/) {
909
909
$keyword_opening_brace = $1 ;
910
910
$hanging_offset -= INDENT_LEVEL; # cancel newly hanging_offset
911
911
}
@@ -967,7 +967,7 @@ sub check_nested_nonblock_indents {
967
967
968
968
my $outermost_level = $block_indent - $preproc_offset == 0;
969
969
970
- report("more than one stmt") if !m/(^|\W )for(\W .*|$ )/ && # no 'for' - TODO improve matching
970
+ report("more than one stmt") if !m/(^|\W )( for|(OSSL_)?LIST_FOREACH(_ \w +)?) (\W .*|$ )/ && # no 'for' - TODO improve matching
971
971
m/;.*;/; # two or more terminators ';', so more than one statement
972
972
973
973
# check for code block containing a single line/statement
@@ -1005,7 +1005,7 @@ sub check_nested_nonblock_indents {
1005
1005
my $assignment_start = 0;
1006
1006
my $tmp = $_ ;
1007
1007
$tmp =~ s/[\! <>=]=/@@/g; # blind (in-)equality symbols like '<=' as '@@' to prevent matching them as '=' below
1008
- if (m/^((^|.*\W )(if|while|for|switch))(\W .*|$ )$ /) { # (last) if/for/while/switch
1008
+ if (m/^((^|.*\W )(if|while|for|(OSSL_)?LIST_FOREACH(_ \w +)?| switch))(\W .*|$ )$ /) { # (last) if/for/while/switch
1009
1009
$paren_expr_start = 1;
1010
1010
} elsif (m/^((^|.*\W )(return|enum))(\W .*|$ )/ # (last) return/enum
1011
1011
&& !$in_expr && @nested_indents == 0 && parens_balance($1 ) == 0) { # not nested enum
@@ -1136,7 +1136,7 @@ sub check_nested_nonblock_indents {
1136
1136
$line_body_start = $contents =~ m/LONG BODY/ ? 0 : $line if $line_function_start != 0;
1137
1137
}
1138
1138
} else {
1139
- $line_opening_brace = $line if $keyword_opening_brace =~ m/if|do|while|for/;
1139
+ $line_opening_brace = $line if $keyword_opening_brace =~ m/if|do|while|for|(OSSL_)?LIST_FOREACH(_ \w +)? /;
1140
1140
# using, not assigning, $keyword_opening_brace here because it could be on an earlier line
1141
1141
$line_opening_brace = $line if $keyword_opening_brace eq "else" && $extended_1_stmt &&
1142
1142
# TODO prevent false positives for if/else where braces around single-statement branches
@@ -1149,11 +1149,11 @@ sub check_nested_nonblock_indents {
1149
1149
}
1150
1150
}
1151
1151
1152
- # check for opening brace after if/while/for/switch/do not on same line
1152
+ # check for opening brace after if/while/for/switch/do missing on same line
1153
1153
# note that "missing '{' on same line after '} else'" is handled further below
1154
1154
if (/^[\s @]*{/ && # leading '{'
1155
1155
$line_before > 0 && !($contents_before_ =~ m/^\s *#/) && # not preprocessor directive '#if
1156
- (my ($head , $mid , $tail ) = ($contents_before_ =~ m/(^|^.*\W )(if|while|for|switch|do)(\W .*$ |$ )/))) {
1156
+ (my ($head , $mid , $tail ) = ($contents_before_ =~ m/(^|^.*\W )(if|while|for|(OSSL_)?LIST_FOREACH(_ \w +)?| switch|do)(\W .*$ |$ )/))) {
1157
1157
my $brace_after = $tail =~ /^[\s @]*{/; # any whitespace or comments then '{'
1158
1158
report("'{' not on same line as preceding '$mid '") if !$brace_after ;
1159
1159
}
0 commit comments