checksrc.pl: add -i and -m options
To sync it with changes made for the libssh2 project. Also cleanup some whitespace.
This commit is contained in:
Родитель
05826081eb
Коммит
cd3903127f
|
@ -6,7 +6,7 @@
|
||||||
# | (__| |_| | _ <| |___
|
# | (__| |_| | _ <| |___
|
||||||
# \___|\___/|_| \_\_____|
|
# \___|\___/|_| \_\_____|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
# Copyright (C) 2011 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
#
|
#
|
||||||
# This software is licensed as described in the file COPYING, which
|
# This software is licensed as described in the file COPYING, which
|
||||||
# you should have received as part of this distribution. The terms
|
# you should have received as part of this distribution. The terms
|
||||||
|
@ -35,10 +35,10 @@ my $verbose;
|
||||||
my %whitelist;
|
my %whitelist;
|
||||||
|
|
||||||
my %warnings = (
|
my %warnings = (
|
||||||
'LONGLINE' => "Line longer than $max_column",
|
'LONGLINE' => "Line longer than $max_column",
|
||||||
'TABS' => 'TAB characters not allowed',
|
'TABS' => 'TAB characters not allowed',
|
||||||
'TRAILINGSPACE' => 'Trailing white space on the line',
|
'TRAILINGSPACE' => 'Trailing white space on the line',
|
||||||
'CPPCOMMENTS' => '// comment detected',
|
'CPPCOMMENTS' => '// comment detected',
|
||||||
'SPACEBEFOREPAREN' => 'space before an open parenthesis',
|
'SPACEBEFOREPAREN' => 'space before an open parenthesis',
|
||||||
'SPACEAFTERPAREN' => 'space after open parenthesis',
|
'SPACEAFTERPAREN' => 'space after open parenthesis',
|
||||||
'SPACEBEFORECLOSE' => 'space before a close parenthesis',
|
'SPACEBEFORECLOSE' => 'space before a close parenthesis',
|
||||||
|
@ -58,7 +58,7 @@ my %warnings = (
|
||||||
'OPENCOMMENT' => 'file ended with a /* comment still "open"',
|
'OPENCOMMENT' => 'file ended with a /* comment still "open"',
|
||||||
'ASTERISKSPACE' => 'pointer declared with space after asterisk',
|
'ASTERISKSPACE' => 'pointer declared with space after asterisk',
|
||||||
'ASTERISKNOSPACE' => 'pointer declared without space before asterisk',
|
'ASTERISKNOSPACE' => 'pointer declared without space before asterisk',
|
||||||
'ASSIGNWITHINCONDITION' => 'assignment within conditional expression',
|
'ASSIGNWITHINCONDITION' => 'assignment within conditional expression',
|
||||||
'EQUALSNOSPACE' => 'equals sign without following space',
|
'EQUALSNOSPACE' => 'equals sign without following space',
|
||||||
'NOSPACEEQUALS' => 'equals sign without preceding space',
|
'NOSPACEEQUALS' => 'equals sign without preceding space',
|
||||||
'SEMINOSPACE' => 'semicolon without following space',
|
'SEMINOSPACE' => 'semicolon without following space',
|
||||||
|
@ -142,6 +142,16 @@ while(1) {
|
||||||
$file = shift @ARGV;
|
$file = shift @ARGV;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
elsif($file =~ /-i([1-9])/) {
|
||||||
|
$indent = $1 + 0;
|
||||||
|
$file = shift @ARGV;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
elsif($file =~ /-m([0-9]+)/) {
|
||||||
|
$max_column = $1 + 0;
|
||||||
|
$file = shift @ARGV;
|
||||||
|
next;
|
||||||
|
}
|
||||||
elsif($file =~ /^(-h|--help)/) {
|
elsif($file =~ /^(-h|--help)/) {
|
||||||
undef $file;
|
undef $file;
|
||||||
last;
|
last;
|
||||||
|
@ -156,6 +166,8 @@ if(!$file) {
|
||||||
print " -D[DIR] Directory to prepend file names\n";
|
print " -D[DIR] Directory to prepend file names\n";
|
||||||
print " -h Show help output\n";
|
print " -h Show help output\n";
|
||||||
print " -W[file] Whitelist the given file - ignore all its flaws\n";
|
print " -W[file] Whitelist the given file - ignore all its flaws\n";
|
||||||
|
print " -i<n> Indent spaces. Default: 2\n";
|
||||||
|
print " -m<n> Maximum line length. Default: 79\n";
|
||||||
print "\nDetects and warns for these problems:\n";
|
print "\nDetects and warns for these problems:\n";
|
||||||
for(sort keys %warnings) {
|
for(sort keys %warnings) {
|
||||||
printf (" %-18s: %s\n", $_, $warnings{$_});
|
printf (" %-18s: %s\n", $_, $warnings{$_});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче