Skip to contentSkip to conversation

please help me with a "repetition"

Cocci Robert Larice 2 participants 4 messages Apr 29, 2018

lore
Share & tools
lore
#0 lore raw

Hello,

probably a stupid question,
I'm failing to match something like this

+ int newvar;
i++; i++; ... any sequence of only "i++";
+ buckbear(42);

I don't succeed to express this "maximum length repetition"
in the mids of those two insertions.

Best Regards,
Robert

#1 lore raw

Review

Quoted 11 lines · Robert Larice

Hello,

probably a stupid question,
I'm failing to match something like this

(quoted diff) +2 -0
+  int newvar;
   i++; i++; ... any sequence of only "i++";
+  buckbear(42);
 
  I don't succeed to express this "maximum length repetition"
    in the mids of those two insertions.

It's not completely straightforward. You could try:

@r1@
position p;
@@

i++;
i++;@p

@@
position p != r1.p;
@@

+ int newvar;
i++;@p

@r2@
position p;
@@

i++;@p
i++;

@@
position p != r2.p;
@@

i++;@p
+ buckbear(42);

julia

Quoted 8 lines

Best Regards,
Robert
_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw
Quoted 14 lines · Julia Lawall

Review

Quoted 11 lines · Robert Larice

Hello,

probably a stupid question,
I'm failing to match something like this

(quoted diff) +2 -0
+  int newvar;
   i++; i++; ... any sequence of only "i++";
+  buckbear(42);
 
  I don't succeed to express this "maximum length repetition"
    in the mids of those two insertions.
Quoted 7 lines

It's not completely straightforward. You could try:

@r1@
position p;
@@

...

Thank You very much,

your suggestion works perfectly well in my actual task.

I was trying something different,
very aproximately something like:

      ... when != i++;
    + int newvar;
      i++;

and didn't get anywhere.

Thanks !
Robert

#3 lore raw
Quoted 26 lines · Robert Larice
Quoted 14 lines · Julia Lawall

Review

Quoted 11 lines · Robert Larice

Hello,

probably a stupid question,
I'm failing to match something like this

(quoted diff) +2 -0
+  int newvar;
   i++; i++; ... any sequence of only "i++";
+  buckbear(42);
 
  I don't succeed to express this "maximum length repetition"
    in the mids of those two insertions.
Quoted 7 lines

It's not completely straightforward. You could try:

@r1@
position p;
@@

...

Thank You very much,

Quoted 8 lines

your suggestion works perfectly well in my actual task.

I was trying something different,
very aproximately something like:

      ... when != i++;
    + int newvar;
      i++;

and didn't get anywhere.

This should work for the first bunch of i++;'s, but not if there are several of them.

julia