The standard location of dictionary.txt is under codespell's package, on my machine atm (codespell 2.1, Artix Linux): /usr/lib/python3.9/site-packages/codespell_lib/data/dictionary.txt Since we enable the codespell by default for SOF I have constant: No codespell typos will be found - file '/usr/share/codespell/dictionary.txt': No such file or directory The patch proposes to try to fix up the path following the recommendation found here: https://github.com/codespell-project/codespell/issues/1540
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -63,6 +63,7 @@ my $min_conf_desc_length = 4; · 62 unmodified lines | |||
| 63 | my $spelling_file = "$D/spelling.txt"; | 63 | my $spelling_file = "$D/spelling.txt"; |
| 64 | my $codespell = 0; | 64 | my $codespell = 0; |
| 65 | my $codespellfile = "/usr/share/codespell/dictionary.txt"; | 65 | my $codespellfile = "/usr/share/codespell/dictionary.txt"; |
| 66 | my $user_codespellfile = ""; | ||
| 66 | my $conststructsfile = "$D/const_structs.checkpatch"; | 67 | my $conststructsfile = "$D/const_structs.checkpatch"; |
| 67 | my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst"; | 68 | my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst"; |
| 68 | my $typedefsfile; | 69 | my $typedefsfile; |
| @@ -130,7 +131,7 @@ Options: · 61 unmodified lines | |||
| 130 | --ignore-perl-version override checking of perl version. expect | 131 | --ignore-perl-version override checking of perl version. expect |
| 131 | runtime errors. | 132 | runtime errors. |
| 132 | --codespell Use the codespell dictionary for spelling/typos | 133 | --codespell Use the codespell dictionary for spelling/typos |
| 133 | (default:/usr/share/codespell/dictionary.txt) | 134 | (default:$codespellfile) |
| 134 | --codespellfile Use this codespell dictionary | 135 | --codespellfile Use this codespell dictionary |
| 135 | --typedefsfile Read additional types from this file | 136 | --typedefsfile Read additional types from this file |
| 136 | --color[=WHEN] Use colors 'always', 'never', or only when output | 137 | --color[=WHEN] Use colors 'always', 'never', or only when output |
| @@ -317,7 +318,7 @@ GetOptions( · 180 unmodified lines | |||
| 317 | 'debug=s' => \%debug, | 318 | 'debug=s' => \%debug, |
| 318 | 'test-only=s' => \$tst_only, | 319 | 'test-only=s' => \$tst_only, |
| 319 | 'codespell!' => \$codespell, | 320 | 'codespell!' => \$codespell, |
| 320 | 'codespellfile=s' => \$codespellfile, | 321 | 'codespellfile=s' => \$user_codespellfile, |
| 321 | 'typedefsfile=s' => \$typedefsfile, | 322 | 'typedefsfile=s' => \$typedefsfile, |
| 322 | 'color=s' => \$color, | 323 | 'color=s' => \$color, |
| 323 | 'no-color' => \$color, #keep old behaviors of -nocolor | 324 | 'no-color' => \$color, #keep old behaviors of -nocolor |
| @@ -325,9 +326,32 @@ GetOptions( · 1 unmodified line | |||
| 325 | 'kconfig-prefix=s' => \${CONFIG_}, | 326 | 'kconfig-prefix=s' => \${CONFIG_}, |
| 326 | 'h|help' => \$help, | 327 | 'h|help' => \$help, |
| 327 | 'version' => \$help | 328 | 'version' => \$help |
| 328 | ) or help(1); | 329 | ) or $help = 2; |
| 330 | |||
| 331 | if ($user_codespellfile) { | ||
| 332 | # Use the user provided codespell file unconditionally | ||
| 333 | $codespellfile = $user_codespellfile; | ||
| 334 | } elsif (!(-f $codespellfile)) { | ||
| 335 | # If /usr/share/codespell/dictionary.txt is not present, try to find it | ||
| 336 | # under codespell's install directory: <codespell_root>/data/dictionary.txt | ||
| 337 | if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") { | ||
| 338 | my $python_codespell_dict = << "EOF"; | ||
| 339 | |||
| 340 | import os.path as op | ||
| 341 | import codespell_lib | ||
| 342 | codespell_dir = op.dirname(codespell_lib.__file__) | ||
| 343 | codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt') | ||
| 344 | print(codespell_file, end='') | ||
| 345 | EOF | ||
| 346 | |||
| 347 | my $codespell_dict = `python -c "$python_codespell_dict" 2> /dev/null`; | ||
| 348 | $codespellfile = $codespell_dict if (-f $codespell_dict); | ||
| 349 | } | ||
| 350 | } | ||
| 329 | 351 | ||
| 330 | help(0) if ($help); | 352 | # $help is 1 if either -h, --help or --version is passed as option - exitcode: 0 |
| 353 | # $help is 2 if invalid option is passed - exitcode: 1 | ||
| 354 | help($help - 1) if ($help); | ||
| 331 | 355 | ||
| 332 | die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); | 356 | die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); |
| 333 | die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse); | 357 | die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse); |