cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Problem writing simple patch
@ 2019-11-25 19:57 David Frey
  2019-11-25 21:10 ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: David Frey @ 2019-11-25 19:57 UTC (permalink / raw)
  To: cocci

Hi,

I'm trying to write a .cocci file to transform all calls to a function
"f(ex)" to something like this:

#ifdef USE_F
f(ex)
#else
g(ex)
#endif

The function has this signature:
bool f(int x);

This is the patch that I tried to use:
@@
expression ex;
@@
+#ifdef USE_F
 f(ex)
+#else
+g(ex)
+#endif


This is the result of running it:
$ spatch --show-c --sp-file test.cocci test.c
init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h
plus: parse error:
  File "test.cocci", line 7, column 1, charpos = 50
  around = 'g',
  whole content = +g(ex)

What is wrong with the patch above?

Thanks,
David
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-27  6:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 19:57 [Cocci] Problem writing simple patch David Frey
2019-11-25 21:10 ` Julia Lawall
2019-11-26  7:24   ` [Cocci] Specifying conditional compilation with SmPL Markus Elfring
2019-11-26  7:47     ` Julia Lawall
2019-11-26 23:46   ` [Cocci] Problem writing simple patch David Frey
2019-11-27  6:00     ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).