mirror of
https://github.com/torvalds/linux.git
synced 2026-04-26 10:32:25 -04:00
docs: kdoc_re: handle strings and escape chars on NextMatch
The logic inside NestedMatch currently doesn't consider that function arguments may have chars and strings, which may eventually contain delimiters. Add logic to handle strings and escape characters on them. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <ac25335bc2d09649e17d1c86c17d3f8f2e8ec27c.1772469446.git.mchehab+huawei@kernel.org>
This commit is contained in:
committed by
Jonathan Corbet
parent
4ff59bdd93
commit
134468b0e2
@@ -216,6 +216,8 @@ class NestedMatch:
|
||||
for match_re in regex.finditer(line):
|
||||
start = match_re.start()
|
||||
offset = match_re.end()
|
||||
string_char = None
|
||||
escape = False
|
||||
|
||||
d = line[offset - 1]
|
||||
if d not in self.DELIMITER_PAIRS:
|
||||
@@ -229,6 +231,22 @@ class NestedMatch:
|
||||
|
||||
d = line[pos]
|
||||
|
||||
if escape:
|
||||
escape = False
|
||||
continue
|
||||
|
||||
if string_char:
|
||||
if d == '\\':
|
||||
escape = True
|
||||
elif d == string_char:
|
||||
string_char = None
|
||||
|
||||
continue
|
||||
|
||||
if d in ('"', "'"):
|
||||
string_char = d
|
||||
continue
|
||||
|
||||
if d in self.DELIMITER_PAIRS:
|
||||
end = self.DELIMITER_PAIRS[d]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user