]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
docs: kdoc_re: Change NestedMath args replacement to \0
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 2 Mar 2026 16:40:59 +0000 (17:40 +0100)
committerJonathan Corbet <corbet@lwn.net>
Tue, 3 Mar 2026 17:47:25 +0000 (10:47 -0700)
Future patches will allow parsing each argument instead of the
hole set. Prepare for it by changing the replace all args from
\1 to \0.

No functional changes.

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: <46e383118be9d9e432e3814fe819ebb12261d7b4.1772469446.git.mchehab+huawei@kernel.org>

tools/lib/python/kdoc/kdoc_parser.py
tools/lib/python/kdoc/kdoc_re.py

index 503a18212747c2a3ef05c9e90bf517336053c335..0f90c16cb51a6794ae335c36862c72b37d5871ff 100644 (file)
@@ -85,7 +85,7 @@ struct_nested_prefixes = [
     (re.compile(r"__cond_acquires_shared\s*\("), ""),
     (re.compile(r"__acquires_shared\s*\("), ""),
     (re.compile(r"__releases_shared\s*\("), ""),
-    (re.compile(r'\bSTRUCT_GROUP\('), r'\1'),
+    (re.compile(r'\bSTRUCT_GROUP\('), r'\0'),
 ]
 
 #
index 00afa5bccd6ddb4e726a276200eaccfc80a6539e..ea4f6f3d9e4224e18afc3e5b270eefb153b47636 100644 (file)
@@ -188,7 +188,7 @@ class NestedMatch:
     # except that the content inside the match group is delimiter-aligned.
     #
     # The content inside parentheses is converted into a single replace
-    # group (e.g. r`\1').
+    # group (e.g. r`\0').
     #
     # It would be nice to change such definition to support multiple
     # match groups, allowing a regex equivalent to:
@@ -291,7 +291,7 @@ class NestedMatch:
 
         if the sub argument contains::
 
-            r'\1'
+            r'\0'
 
         it will work just like re: it places there the matched paired data
         with the delimiter stripped.
@@ -310,9 +310,9 @@ class NestedMatch:
             # Value, ignoring start/end delimiters
             value = line[end:pos - 1]
 
-            # replaces \1 at the sub string, if \1 is used there
+            # replaces \0 at the sub string, if \0 is used there
             new_sub = sub
-            new_sub = new_sub.replace(r'\1', value)
+            new_sub = new_sub.replace(r'\0', value)
 
             out += new_sub