* [Cocci] Problem with "already tagged token"
@ 2014-09-10 15:49 Rasmus Villemoes
2014-09-10 16:11 ` Julia Lawall
2014-09-10 16:30 ` [Cocci] Conversion of similar function calls into one with a longer parameter SF Markus Elfring
0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2014-09-10 15:49 UTC (permalink / raw)
To: cocci
Hi,
I'm trying to write a semantic patch to convert consecutive seq_puts()
calls into a single one, with the string literals concatenated. My
attempt below works fine when there are exactly two seq_puts() calls,
but fails when there are more. If I use coccicheck on a directory,
coccinelle seems to silently skip files containing three-or-more
(e.g. kernel/trace/trace.c), but gives me the "already tagged token"
error when I use it on the specific file.
Ideally, I'd of course like coccinelle to apply the spatch iteratively
until only a single call remains. I think I understand why I get the
error, but I'd like to know if there's some obvious fix I've overlooked.
@concat1 depends on patch@
expression s;
constant c1, c2;
position p1, p2;
@@
seq_puts at p1(s, c1);
seq_puts at p2(s, c2);
@script:python concat2@
c1 << concat1.c1;
c2 << concat1.c2;
c3;
@@
// The indentation probably needs to be fixed manually
coccinelle.c3 = c1 + "\n\t" + c2
@concat3 depends on patch@
identifier concat2.c3;
expression concat1.s;
constant concat1.c1, concat1.c2;
position concat1.p1, concat1.p2;
@@
- seq_puts at p1(s, c1);
- seq_puts@p2(s, c2);
+ seq_puts(s, c3);
Thanks,
Rasmus
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cocci] Problem with "already tagged token"
2014-09-10 15:49 [Cocci] Problem with "already tagged token" Rasmus Villemoes
@ 2014-09-10 16:11 ` Julia Lawall
2014-09-11 7:16 ` Rasmus Villemoes
2014-09-10 16:30 ` [Cocci] Conversion of similar function calls into one with a longer parameter SF Markus Elfring
1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2014-09-10 16:11 UTC (permalink / raw)
To: cocci
Clever :)
I haven't tried this, but I think you cudl do the following:
@r@
position p;
@@
seq_puts(...);
seq_puts(...);
seq_puts at p(...);
> @concat1 depends on patch@
> expression s;
> constant c1, c2;
> position p1, p2;
Now change this line to
position p1 != r.p, p2 != r.p;
Then you can either use Coccinelle to do the iteration, or just run the
semantic patch over and over on the code.
julia
> @@
> seq_puts at p1(s, c1);
> seq_puts at p2(s, c2);
>
> @script:python concat2@
> c1 << concat1.c1;
> c2 << concat1.c2;
> c3;
> @@
>
> // The indentation probably needs to be fixed manually
> coccinelle.c3 = c1 + "\n\t" + c2
>
> @concat3 depends on patch@
> identifier concat2.c3;
> expression concat1.s;
> constant concat1.c1, concat1.c2;
> position concat1.p1, concat1.p2;
> @@
> - seq_puts at p1(s, c1);
> - seq_puts at p2(s, c2);
> + seq_puts(s, c3);
>
>
>
> Thanks,
> Rasmus
>
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cocci] Conversion of similar function calls into one with a longer parameter
2014-09-10 15:49 [Cocci] Problem with "already tagged token" Rasmus Villemoes
2014-09-10 16:11 ` Julia Lawall
@ 2014-09-10 16:30 ` SF Markus Elfring
1 sibling, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2014-09-10 16:30 UTC (permalink / raw)
To: cocci
> I'm trying to write a semantic patch to convert consecutive seq_puts()
> calls into a single one, with the string literals concatenated.
> My attempt below works fine when there are exactly two seq_puts() calls,
> but fails when there are more.
How do you think about to process the corresponding syntax and control flow
graph by interfaces for the programming language "OCaml"?
Would it be safer to reuse the available API for such an application where
several similar function calls should be merged together?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cocci] Problem with "already tagged token"
2014-09-10 16:11 ` Julia Lawall
@ 2014-09-11 7:16 ` Rasmus Villemoes
0 siblings, 0 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2014-09-11 7:16 UTC (permalink / raw)
To: cocci
On Wed, Sep 10 2014, Julia Lawall <julia.lawall@lip6.fr> wrote:
> Clever :)
>
> I haven't tried this, but I think you cudl do the following:
>
> @r@
> position p;
> @@
>
> seq_puts(...);
> seq_puts(...);
> seq_puts at p(...);
>
>> @concat1 depends on patch@
>> expression s;
>> constant c1, c2;
>> position p1, p2;
>
> Now change this line to
>
> position p1 != r.p, p2 != r.p;
>
> Then you can either use Coccinelle to do the iteration, or just run the
> semantic patch over and over on the code.
>
Thanks, that seems to work. Can you tell me how I would get coccinelle
to do the iteration? It's not really that important, since the
whitespace has to be fixed manually anyway, and with your suggestion one
finds all places with at least two consecutive seq_puts calls. But it
would be nice if one would _only_ have to fix whitespace
Thanks,
Rasmus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-11 7:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-10 15:49 [Cocci] Problem with "already tagged token" Rasmus Villemoes
2014-09-10 16:11 ` Julia Lawall
2014-09-11 7:16 ` Rasmus Villemoes
2014-09-10 16:30 ` [Cocci] Conversion of similar function calls into one with a longer parameter SF Markus Elfring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.