|
1 | 1 | #!/usr/bin/env perl |
2 | | -# SPDX-License-Identifier: GPL-2.0 |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
3 | 3 | # |
4 | 4 | # (c) 2001, Dave Jones. (the file handling bit) |
5 | 5 | # (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) |
6 | 6 | # (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) |
7 | 7 | # (c) 2008-2010 Andy Whitcroft <apw@canonical.com> |
8 | 8 | # (c) 2010-2018 Joe Perches <joe@perches.com> |
| 9 | +# (c) 2025 Aerlync Labs Inc |
9 | 10 |
|
10 | 11 | use strict; |
11 | 12 | use warnings; |
@@ -3521,39 +3522,39 @@ sub process { |
3521 | 3522 | } |
3522 | 3523 |
|
3523 | 3524 | # check for missing blank lines after declarations |
3524 | | - if ($sline =~ /^\+\s+\S/ && #Not at char 1 |
| 3525 | + if (($sline =~ /^\+\s+\S/ || $sline =~ /^\s+\S/) && # Not at char 1 |
3525 | 3526 | # actual declarations |
3526 | | - ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
| 3527 | + ($prevline =~ /^(\+|\s)\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
3527 | 3528 | # function pointer declarations |
3528 | | - $prevline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ || |
| 3529 | + $prevline =~ /^(\+|\s)\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ || |
3529 | 3530 | # foo bar; where foo is some local typedef or #define |
3530 | | - $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
| 3531 | + $prevline =~ /^(\+|\s)\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
3531 | 3532 | # known declaration macros |
3532 | | - $prevline =~ /^\+\s+$declaration_macros/) && |
| 3533 | + $prevline =~ /^(\+|\s)\s+$declaration_macros/) && |
3533 | 3534 | # for "else if" which can look like "$Ident $Ident" |
3534 | | - !($prevline =~ /^\+\s+$c90_Keywords\b/ || |
| 3535 | + !($prevline =~ /^(\+|\s)\s+$c90_Keywords\b/ || |
3535 | 3536 | # other possible extensions of declaration lines |
3536 | 3537 | $prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ || |
3537 | 3538 | # not starting a section or a macro "\" extended line |
3538 | 3539 | $prevline =~ /(?:\{\s*|\\)$/) && |
3539 | 3540 | # looks like a declaration |
3540 | | - !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
| 3541 | + !($sline =~ /^(\+|\s)\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
3541 | 3542 | # function pointer declarations |
3542 | | - $sline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ || |
| 3543 | + $sline =~ /^(\+|\s)\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ || |
3543 | 3544 | # foo bar; where foo is some local typedef or #define |
3544 | | - $sline =~ /^\+\s+(?:volatile\s+)?$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
| 3545 | + $sline =~ /^(\+|\s)\s+(?:volatile\s+)?$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
3545 | 3546 | # known declaration macros |
3546 | | - $sline =~ /^\+\s+$declaration_macros/ || |
| 3547 | + $sline =~ /^(\+|\s)\s+$declaration_macros/ || |
3547 | 3548 | # start of struct or union or enum |
3548 | | - $sline =~ /^\+\s+(?:volatile\s+)?(?:static\s+)?(?:const\s+)?(?:union|struct|enum|typedef)\b/ || |
| 3549 | + $sline =~ /^(\+|\s)\s+(?:volatile\s+)?(?:static\s+)?(?:const\s+)?(?:union|struct|enum|typedef)\b/ || |
3549 | 3550 | # start or end of block or continuation of declaration |
3550 | | - $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ || |
| 3551 | + $sline =~ /^(\+|\s)\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ || |
3551 | 3552 | # bitfield continuation |
3552 | | - $sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ || |
| 3553 | + $sline =~ /^(\+|\s)\s+$Ident\s*:\s*\d+\s*[,;]/ || |
3553 | 3554 | # other possible extensions of declaration lines |
3554 | | - $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) && |
| 3555 | + $sline =~ /^(\+|\s)\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) && |
3555 | 3556 | # indentation of previous and current line are the same |
3556 | | - (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) { |
| 3557 | + (($prevline =~ /^(\+|\s)(\s+)\S/) && $sline =~ /^(\+|\s)$2\S/)) { |
3557 | 3558 | if (WARN("LINE_SPACING", |
3558 | 3559 | "Missing a blank line after declarations\n" . $hereprev) && |
3559 | 3560 | $fix) { |
|
0 commit comments