Merge bitcoin/bitcoin#27302: init: Error if ignored bitcoin.conf file is found
eefe56967bbugfix: Fix incorrect debug.log config file path (Ryan Ofsky)3746f00be1init: Error if ignored bitcoin.conf file is found (Ryan Ofsky)398c3719b0lint: Fix lint-format-strings false positives when format specifiers have argument positions (Ryan Ofsky) Pull request description: Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could happen: - One case reported in [#27246 (comment)](https://github.com/bitcoin/bitcoin/issues/27246#issuecomment-1470006043) happens when a `bitcoin.conf` file in the default datadir (e.g. `$HOME/.bitcoin/bitcoin.conf`) has a `datadir=/path` line that sets different datadir containing a second `bitcoin.conf` file. Currently the second `bitcoin.conf` file is ignored with no warning. - Another way this could happen is if a `-conf=` command line argument points to a configuration file with a `datadir=/path` line and that path contains a `bitcoin.conf` file, which is currently ignored. This change only adds an error message and doesn't change anything about way settings are applied. It also doesn't trigger errors if there are redundant `-datadir` or `-conf` settings pointing at the same configuration file, only if they are pointing at different files and one file is being ignored. ACKs for top commit: pinheadmz: re-ACKeefe56967bwillcl-ark: re-ACKeefe56967bTheCharlatan: ACKeefe56967bTree-SHA512: 939a98a4b271b5263d64a2df3054c56fcde94784edf6f010d78693a371c38aa03138ae9cebb026b6164bbd898d8fd0845a61a454fd996e328fd7bcf51c580c2b
This commit is contained in:
11 files changed
+189
-20
No files matched your search
@@ -241,20 +241,32 @@ def count_format_specifiers(format_string):
|
||||
3
|
||||
>>> count_format_specifiers("foo %d bar %i foo %% foo %*d foo")
|
||||
4
|
||||
>>> count_format_specifiers("foo %5$d")
|
||||
5
|
||||
>>> count_format_specifiers("foo %5$*7$d")
|
||||
7
|
||||
"""
|
||||
assert type(format_string) is str
|
||||
format_string = format_string.replace('%%', 'X')
|
||||
n = 0
|
||||
in_specifier = False
|
||||
for i, char in enumerate(format_string):
|
||||
if char == "%":
|
||||
in_specifier = True
|
||||
n = max_pos = 0
|
||||
for m in re.finditer("%(.*?)[aAcdeEfFgGinopsuxX]", format_string, re.DOTALL):
|
||||
# Increase the max position if the argument has a position number like
|
||||
# "5$", otherwise increment the argument count.
|
||||
pos_num, = re.match(r"(?:(^\d+)\$)?", m.group(1)).groups()
|
||||
if pos_num is not None:
|
||||
max_pos = max(max_pos, int(pos_num))
|
||||
else:
|
||||
n += 1
|
||||
elif char in "aAcdeEfFgGinopsuxX":
|
||||
in_specifier = False
|
||||
elif in_specifier and char == "*":
|
||||
|
||||
# Increase the max position if there is a "*" width argument with a
|
||||
# position like "*7$", and increment the argument count if there is a
|
||||
# "*" width argument with no position.
|
||||
star, star_pos_num = re.match(r"(?:.*?(\*(?:(\d+)\$)?)|)", m.group(1)).groups()
|
||||
if star_pos_num is not None:
|
||||
max_pos = max(max_pos, int(star_pos_num))
|
||||
elif star is not None:
|
||||
n += 1
|
||||
return n
|
||||
return max(n, max_pos)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in new issue
Block a user