Hi,

I have a question regarding the new "comments" feature. Suppose the following:

test.cocci
----------
@ r @
identifier fn;
comments c;
@@
fn()@c
{
}

@ script:python @
fn << r.fn;
c << r.c;
@@
print(fn + " has comment: " + c[0].after)


test.c
------
int f() /* a comment */ { }
int g() { }


spatch --sp-file test.cocci test.c
----------------------------------
f has comment: /* a comment */
g has comment:


The issue here is that I would like to trigger the python script
(i.e. satisfy the "r" rule) iff the comment is actually present.
Can I make the rule depend on the comment being there?

Thanks,

--
Christoph Böhmwalder
LINBIT | Keeping the Digital World Running
DRBD HA —  Disaster Recovery — Software defined Storage
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to