Merge bitcoin/bitcoin#32434: lint: Remove string exclusion from locale check

fa24fdcb7f lint: Remove string exclusion from locale check (MarcoFalke)

Pull request description:

  The exclusion isn't needed. In fact, it prevents detection of `"bla" + wrong()`.

  For example, the following is not detected:

  ```diff
  diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp
  index 1c2951deee..c1209013e5 100644
  --- a/src/wallet/rpc/addresses.cpp
  +++ b/src/wallet/rpc/addresses.cpp
  @@ -336,7 +336,8 @@ RPCHelpMan addmultisigaddress()
   RPCHelpMan keypoolrefill()
   {
       return RPCHelpMan{"keypoolrefill",
  -                "\nFills the keypool."+
  +                "\nRefills each descriptor keypool in the wallet up to the specified number of new keys.\n"
  +                "By default, descriptor wallets have 4 active ranged descriptors (\"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"), each with " + std::to_string(DEFAULT_KEYPOOL_SIZE) + " entries.\n" +
           HELP_REQUIRING_PASSPHRASE,
                   {
                       {"newsize", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%u, or as set by -keypool", DEFAULT_KEYPOOL_SIZE)}, "The new keypool size"},
  ```

  Fix the script by detecting it.

ACKs for top commit:
  laanwj:
    Code review ACK fa24fdcb7f.
  rkrux:
    ACK fa24fdcb7f
  w0xlt:
    ACK fa24fdcb7f

Tree-SHA512: cb7e6ed9fec5d2089e94031329ebf26b83a1814ffbbbca94f7527c127bc759d13c0f4ea79b71ff7f5f009d071dcf01958c8921163d6dc5e1ae6256cc40b57eea
This commit is contained in:
merge-script
2025-05-08 10:42:30 +01:00
2 changed files with 5 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright (c) 2018-2022 The Bitcoin Core developers
# Copyright (c) 2018-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
@@ -43,6 +43,7 @@ from subprocess import check_output, CalledProcessError
KNOWN_VIOLATIONS = [
"src/dbwrapper.cpp:.*vsnprintf",
"src/span.h:.*printf",
"src/test/fuzz/locale.cpp:.*setlocale",
"src/test/util_tests.cpp:.*strtoll",
"src/util/syserror.cpp:.*strerror", # Outside this function use `SysErrorString`
@@ -214,7 +215,7 @@ LOCALE_DEPENDENT_FUNCTIONS = [
def find_locale_dependent_function_uses():
regexp_locale_dependent_functions = "|".join(LOCALE_DEPENDENT_FUNCTIONS)
exclude_args = [":(exclude)" + excl for excl in REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS]
git_grep_command = ["git", "grep", "-E", "[^a-zA-Z0-9_\\`'\"<>](" + regexp_locale_dependent_functions + ")(_r|_s)?[^a-zA-Z0-9_\\`'\"<>]", "--", "*.cpp", "*.h"] + exclude_args
git_grep_command = ["git", "grep", "--extended-regexp", "[^a-zA-Z0-9_\\`'\"<>](" + regexp_locale_dependent_functions + ")(_r|_s)?\\(", "--", "*.cpp", "*.h"] + exclude_args
git_grep_output = list()
try:
@@ -234,8 +235,8 @@ def main():
for locale_dependent_function in LOCALE_DEPENDENT_FUNCTIONS:
matches = [line for line in git_grep_output
if re.search("[^a-zA-Z0-9_\\`'\"<>]" + locale_dependent_function + "(_r|_s)?[^a-zA-Z0-9_\\`'\"<>]", line)
and not re.search("\\.(c|cpp|h):\\s*(//|\\*|/\\*|\").*" + locale_dependent_function, line)
if re.search("[^a-zA-Z0-9_\\`'\"<>]" + locale_dependent_function + "(_r|_s)?\\(", line)
and not re.search("\\.(c|cpp|h):\\s*//.*" + locale_dependent_function, line)
and not re.search(regexp_ignore_known_violations, line)]
if matches:
print(f"The locale dependent function {locale_dependent_function}(...) appears to be used:")