mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
To: mchehab+huawei@kernel.org
Cc: corbet@lwn.net, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	rdunlap@infradead.org, mchehab@kernel.org, paulmck@kernel.org,
	linusw@kernel.org, Julia.Lawall@inria.fr, gary@garyguo.net,
	rmk+kernel@armlinux.org.uk, hemanth.selam@gmail.com,
	Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
Subject: [PATCH v2 1/2] docs: kdoc: handle nested commas in CMatch arguments
Date: Fri, 23 Oct 2026 14:04:14 +0100	[thread overview]
Message-ID: <20261023130444.26270-2-emmaonana18@gmail.com> (raw)
In-Reply-To: <20261023130444.26270-1-emmaonana18@gmail.com>

CMatch argument extraction splits macro arguments at top-level commas,
but it currently also splits on commas inside nested expressions.
This breaks transformations that capture a macro argument containing a nested call.

Only treat delimiters at the outer macro argument level as separators.

add a regression test for a nested call with comma-separated arguments.

Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
---
 tools/lib/python/kdoc/c_lex.py | 3 ++-
 tools/unittests/test_cmatch.py | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/lib/python/kdoc/c_lex.py b/tools/lib/python/kdoc/c_lex.py
index efbc23c01abd..532e2c5a815e 100644
--- a/tools/lib/python/kdoc/c_lex.py
+++ b/tools/lib/python/kdoc/c_lex.py
@@ -430,7 +430,8 @@ class CTokenArgs:
                 if inner_level < 0:
                     break
 
-            if tok.kind in [CToken.PUNC, CToken.ENDSTMT] and delim == tok.value:
+            if (inner_level == 0 and tok.value == delim and
+                    tok.kind in [CToken.PUNC, CToken.ENDSTMT]):
                 pos += 1
                 if self.greedy and pos > self.max_group:
                     pos -= 1
diff --git a/tools/unittests/test_cmatch.py b/tools/unittests/test_cmatch.py
index 109141cd2ab8..978e02acfa4d 100755
--- a/tools/unittests/test_cmatch.py
+++ b/tools/unittests/test_cmatch.py
@@ -259,6 +259,13 @@ class TestSubSimple(TestCaseDiff):
 
         self.assertLogicallyEqual("REPLACE(arg1, arg2)\nbar();", result)
 
+    def test_sub_nested_commas(self):
+        """Commas in nested expressions aren't macro argument delimiters"""
+        line = f"{self.MACRO}(a, inner(b, c), d)"
+        result = self.matcher.sub(r"\1|\2|\3", line)
+
+        self.assertLogicallyEqual("a| inner(b, c)| d", result)
+
     def test_sub_mixed_placeholders(self):
         """Replacement rule for \0, \1 and additional text"""
         line = f"{self.MACRO}(foo, bar)\nbaz();"
-- 
2.43.0


  reply	other threads:[~2026-10-23 13:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02  4:15 [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes Omokefe Emmanuel Onanaroghene
2026-10-02  4:28 ` Randy Dunlap
2026-10-14 17:22 ` Jonathan Corbet
2026-10-14 22:47   ` Omokefe Emmanuel Onanaroghene
2026-10-15  0:53     ` Omokefe Emmanuel Onanaroghene
2026-10-15 13:00       ` Jonathan Corbet
2026-10-15 16:44         ` [PATCH v3 0/2] docs: kdoc: fix TRACE_EVENT_FN and DOMAIN_NS parsing Omokefe Emmanuel Onanaroghene
2026-10-15 16:44           ` [PATCH v3 1/2] docs: kdoc: handle TRACE_EVENT_FN() family in tracepoint parser Omokefe Emmanuel Onanaroghene
2026-10-15 17:06             ` Mauro Carvalho Chehab
2026-10-16 20:43               ` [PATCH] " Omokefe Emmanuel Onanaroghene
2026-10-16 21:11                 ` Mauro Carvalho Chehab
2026-10-23 13:04                   ` [PATCH v2 0/2] docs: kdoc: convert tracepoint parsing to CMatch Omokefe Emmanuel Onanaroghene
2026-10-23 13:04                     ` Omokefe Emmanuel Onanaroghene [this message]
2026-10-23 13:04                     ` [PATCH v2 2/2] docs: kdoc: handle TRACE_EVENT_FN() with CMatch Omokefe Emmanuel Onanaroghene
2026-10-15 16:44           ` [PATCH v3 2/2] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes Omokefe Emmanuel Onanaroghene

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023130444.26270-2-emmaonana18@gmail.com \
    --to=emmaonana18@gmail.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=corbet@lwn.net \
    --cc=gary@garyguo.net \
    --cc=hemanth.selam@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®