On Thu, May 19, 2011 at 14:02, Julia Lawall <[email protected]> wrote:
>
> Do you know ocaml? You can use that as well.
>
I don't know ocaml either...
> In any case, try the following:
>
> @case2@
> constant char [] c;
> expression e;
> position p;
> @@
>
> stralloc@p(c, e)
>
> @script:python name@
> c << case2.c;
> newc;
> @@
>
> coccinelle.newc = "\"%s%%s\"" " c
>
> @@
> position case2.p;
> identifier name.newc;
> expression e1,e2;
> @@
>
> - stralloc@p(e1,e2)
> + g_strdup_printf(newc, e2)
>
> Note that I am not very sure about the right hand side of the assignment
> of newc in the python code. I don't know python either :)
>
fg@erwin ~ $ spatch -sp_file stralloc2-other.cocci t2.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
File "stralloc2-other.cocci", line 24, column 0, charpos = 269
around = '', whole content =
Fatal error: exception Failure("lexing: empty token")
I'm ready to try the ocaml route, not that I would understand any of
it either :p
> You would have a set of rules like this for each of your cases. You
> should put the more specific ones (case 2 and case 3) first. I'm not sure
> what you want to do in the case where there are two explicit strings;
> maybe that can't arise?
>
The latter cannot happen, indeed.
Thanks for your help!
--
Francis Galiegue, [email protected]
"It seems obvious [...] that at least some 'business intelligence'
tools invest so much intelligence on the business side that they have
nothing left for generating SQL queries" (Stéphane Faroult, in "The
Art of SQL", ISBN 0-596-00894-5)
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)