util/lint/checkpatch.pl: Update to v5.18-2 lines related to "codespell"
Change-Id: I55cc4255ea88723c813a04d87e4c028c64f92dbd Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/63435 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
@@ -22,6 +22,9 @@ my $V = '0.32';
|
|||||||
use Getopt::Long qw(:config no_auto_abbrev);
|
use Getopt::Long qw(:config no_auto_abbrev);
|
||||||
|
|
||||||
my $quiet = 0;
|
my $quiet = 0;
|
||||||
|
my $verbose = 0;
|
||||||
|
my %verbose_messages = ();
|
||||||
|
my %verbose_emitted = ();
|
||||||
my $tree = 1;
|
my $tree = 1;
|
||||||
my $chk_signoff = 1;
|
my $chk_signoff = 1;
|
||||||
my $chk_patch = 1;
|
my $chk_patch = 1;
|
||||||
@@ -60,6 +63,7 @@ my $min_conf_desc_length = 4;
|
|||||||
my $spelling_file = "$D/spelling.txt";
|
my $spelling_file = "$D/spelling.txt";
|
||||||
my $codespell = 0;
|
my $codespell = 0;
|
||||||
my $codespellfile = "/usr/share/codespell/dictionary.txt";
|
my $codespellfile = "/usr/share/codespell/dictionary.txt";
|
||||||
|
my $user_codespellfile = "";
|
||||||
my $conststructsfile = "$D/const_structs.checkpatch";
|
my $conststructsfile = "$D/const_structs.checkpatch";
|
||||||
my $typedefsfile = "";
|
my $typedefsfile = "";
|
||||||
my $color = "auto";
|
my $color = "auto";
|
||||||
@@ -127,7 +131,7 @@ Options:
|
|||||||
--ignore-perl-version override checking of perl version. expect
|
--ignore-perl-version override checking of perl version. expect
|
||||||
runtime errors.
|
runtime errors.
|
||||||
--codespell Use the codespell dictionary for spelling/typos
|
--codespell Use the codespell dictionary for spelling/typos
|
||||||
(default:/usr/share/codespell/dictionary.txt)
|
(default:$codespellfile)
|
||||||
--codespellfile Use this codespell dictionary
|
--codespellfile Use this codespell dictionary
|
||||||
--typedefsfile Read additional types from this file
|
--typedefsfile Read additional types from this file
|
||||||
--color[=WHEN] Use colors 'always', 'never', or only when output
|
--color[=WHEN] Use colors 'always', 'never', or only when output
|
||||||
@@ -235,17 +239,56 @@ GetOptions(
|
|||||||
'debug=s' => \%debug,
|
'debug=s' => \%debug,
|
||||||
'test-only=s' => \$tst_only,
|
'test-only=s' => \$tst_only,
|
||||||
'codespell!' => \$codespell,
|
'codespell!' => \$codespell,
|
||||||
'codespellfile=s' => \$codespellfile,
|
'codespellfile=s' => \$user_codespellfile,
|
||||||
'typedefsfile=s' => \$typedefsfile,
|
'typedefsfile=s' => \$typedefsfile,
|
||||||
'color=s' => \$color,
|
'color=s' => \$color,
|
||||||
'no-color' => \$color, #keep old behaviors of -nocolor
|
'no-color' => \$color, #keep old behaviors of -nocolor
|
||||||
'nocolor' => \$color, #keep old behaviors of -nocolor
|
'nocolor' => \$color, #keep old behaviors of -nocolor
|
||||||
'h|help' => \$help,
|
'h|help' => \$help,
|
||||||
'version' => \$help
|
'version' => \$help
|
||||||
) or help(1);
|
) or $help = 2;
|
||||||
|
|
||||||
help(0) if ($help);
|
if ($user_codespellfile) {
|
||||||
|
# Use the user provided codespell file unconditionally
|
||||||
|
$codespellfile = $user_codespellfile;
|
||||||
|
} elsif (!(-f $codespellfile)) {
|
||||||
|
# If /usr/share/codespell/dictionary.txt is not present, try to find it
|
||||||
|
# under codespell's install directory: <codespell_root>/data/dictionary.txt
|
||||||
|
if (($codespell || $help) && which("python3") ne "") {
|
||||||
|
my $python_codespell_dict = << "EOF";
|
||||||
|
|
||||||
|
import os.path as op
|
||||||
|
import codespell_lib
|
||||||
|
codespell_dir = op.dirname(codespell_lib.__file__)
|
||||||
|
codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt')
|
||||||
|
print(codespell_file, end='')
|
||||||
|
EOF
|
||||||
|
|
||||||
|
my $codespell_dict = `python3 -c "$python_codespell_dict" 2> /dev/null`;
|
||||||
|
$codespellfile = $codespell_dict if (-f $codespell_dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# $help is 1 if either -h, --help or --version is passed as option - exitcode: 0
|
||||||
|
# $help is 2 if invalid option is passed - exitcode: 1
|
||||||
|
help($help - 1) if ($help);
|
||||||
|
|
||||||
|
die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
|
||||||
|
die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse);
|
||||||
|
|
||||||
|
if ($color =~ /^[01]$/) {
|
||||||
|
$color = !$color;
|
||||||
|
} elsif ($color =~ /^always$/i) {
|
||||||
|
$color = 1;
|
||||||
|
} elsif ($color =~ /^never$/i) {
|
||||||
|
$color = 0;
|
||||||
|
} elsif ($color =~ /^auto$/i) {
|
||||||
|
$color = (-t STDOUT);
|
||||||
|
} else {
|
||||||
|
die "$P: Invalid color mode: $color\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
load_docs() if ($verbose);
|
||||||
list_types(0) if ($list_types);
|
list_types(0) if ($list_types);
|
||||||
|
|
||||||
$fix = 1 if ($fix_inplace);
|
$fix = 1 if ($fix_inplace);
|
||||||
|
Reference in New Issue
Block a user