checksrc.pl: detect assign followed by more than one space

And fix some code previously doing this.

Closes #19375
This commit is contained in:
Daniel Stenberg 2025-11-05 14:40:18 +01:00
parent c12a1fdd0e
commit 6d7e924e80
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 20 additions and 13 deletions

View file

@ -131,6 +131,7 @@ my %warnings = (
'DOBRACE' => 'A single space between do and open brace',
'EMPTYLINEBRACE' => 'Empty line before the open brace',
'EQUALSNOSPACE' => 'equals sign without following space',
'EQUALSPACE' => 'equals sign with too many spaces following',
'EQUALSNULL' => 'if/while comparison with == NULL',
'ERRNOVAR' => 'use of bare errno define',
'EXCLAMATIONSPACE' => 'Whitespace after exclamation mark in expression',
@ -1039,6 +1040,12 @@ sub scanfile {
$line, length($1)+1, $file, $ol,
"no space before equals sign");
}
# check for equals sign with more than one space after it
elsif($l =~ /(.*)[a-z0-9] \= /i) {
checkwarn("EQUALSPACE",
$line, length($1)+3, $file, $ol,
"more than one space after equals sign");
}
# check for plus signs without spaces next to it
if($nostr =~ /(.*)[^+]\+[a-z0-9]/i) {