On Thu, 22 Jan 2015, Eliseo Martínez wrote:

> > I get nothing
>
> Given that patch (which does not include ‘home_replace’ in the regex), that 
> would be the expected result.
> Note that I didn’t include the full list of functions in my last patch (not 
> to make it more confusing than necessary), but the actual patch I’m using 
> contains all functions, including ‘home_replace’.
>
> In any case, I’ve just realized the problem could be not in spatch, but in 
> how I’m parsing its output through vim’s errorformat.
> So, please, forget about this by now, and sorry for the noise.
> If I do isolate a real failure in spatch, I will get back to you with a 
> complete set of patch/source to reproduce it.

If the regular expression is a positive thing, then you would probably be
better off with

var = \(fun1\|fun2\|fun3\|fun4\)(...)
...
etc.

The Coccinelle will only parse the files that contain either fun1, fun2,
fun3, fun4, etc.

Actually, you don't even have to repeat the long list of functions for the
two rules.  You can say:

@ok@
position p;
@d@

\(fun1\|fun2\|fun3\|fun4\)(...)@p

@@
...
identifier fn;
position ok.p;
@@

var = fn(...)@p
... when != var = E
*if (var == NULL) S

etc.

It will detect that the semantic patch can only do something useful on a
file that contains either fun1, fun2, etc.

julia

>
> Thanks.
>
>
> > On 22 Jan 2015, at 12:52, Julia Lawall <[email protected]> wrote:
> >
> > With the following source code:
> >
> > int main() {
> >     p = home_replace(NULL, files[i]);
> >      if (p != NULL) {
> >        free(files[i]);
> >        files[i] = p;
> >      }
> > }
> >
> > and the following semanticpatch:
> >
> > @@ identifier func =~ "^(vim_strsave|list_alloc)$"; identifier var;
> > statement S; expression E; @@
> >
> >  var = func(...);
> >  ... when != var = E
> > * if (var != NULL)
> >    S
> >
> > I get nothing.  If I remove the regular expression, then I get results
> > with the above semantic patch and with the following semantic partch:
> >
> > @@ identifier func =~ "^(vim_strsave|list_alloc)$"; identifier var;
> > statement S; expression E; @@
> >
> >  var = func(...);
> >  ... when != var = E
> > * if (var != NULL)    S
> >
> > Probably the issue inmy case is the kind of regular expression being used.
> > Are you using pcre?
> >
> > julia
>
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to