On Fri, 2 Aug 2019, Christoph Böhmwalder wrote: > 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? A choice could have been to let c only match if there is a comment in at least one place (before, within, or after). I don't know if that would be desirable. But in your case, would it suffice just to put an if in the python code? Or is it essential that the first rule actually not match? julia > > 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 >