checksrc: verify do-while and spaces between the braces

Updated mprintf.c to comply

Closes #5845
This commit is contained in:
Daniel Stenberg 2020-08-24 09:31:39 +02:00
Родитель 4be1f8dc01
Коммит 4ebac06106
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 5CC908FDB71E12C2
2 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@ -82,6 +82,8 @@ my %warnings = (
'SNPRINTF' => 'use of snprintf',
'ONELINECONDITION' => 'conditional block on the same line as the if()',
'TYPEDEFSTRUCT' => 'typedefed struct',
'DOBRACE' => 'A single space between do and open brace',
'BRACEWHILE' => 'A single space between open brace and while',
);
sub readskiplist {
@ -468,6 +470,14 @@ sub scanfile {
}
}
# check spaces in 'do {'
if($nostr =~ /^( *)do( *)\{/ && length($2) != 1) {
checkwarn("DOBRACE", $line, length($1) + 2, $file, $l, "one space after do before brace");
}
# check spaces in 'do {'
elsif($nostr =~ /^( *)\}( *)while/ && length($2) != 1) {
checkwarn("BRACEWHILE", $line, length($1) + 2, $file, $l, "one space between brace and while");
}
if($nostr =~ /^((.*\s)(if) *\()(.*)\)(.*)/) {
my $pos = length($1);
my $postparen = $5;

Просмотреть файл

@ -99,12 +99,12 @@ static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
/* Upper-case digits. */
static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define OUTCHAR(x) \
do{ \
#define OUTCHAR(x) \
do { \
if(stream((unsigned char)(x), (FILE *)data) != -1) \
done++; \
else \
return done; /* return immediately on failure */ \
done++; \
else \
return done; /* return immediately on failure */ \
} while(0)
/* Data type to read from the arglist */