SV: [Cocci] adding #include's

Nicolas Palix npalix at diku.dk
Thu Nov 5 11:31:38 CET 2009


On Thursday 05 November 2009 10:59:13 Andreas.Aaen at tieto.com wrote:
> Now how do we combine the two spatches?
> 
> I would like to express: add #include <foo.h> after #include <bar.h> if foo.h isn't included already. If #include <bar.h> isn't present, then add #include <foo.h> after the last #include <> statement.
> 
> @r@
> @@
> #include <foo.h>
> @ s depends on never r @
> @@
> #include <bar.h>
> +#include <foo.h>
> @ depends on never s @

s implies not r, but "not s" does not imply "not r".

So, you need to ensure that foo is not already there..

@ depends on !s && !r @

> @@
> #include <...>
> +#include <foo.h>
> 
> Regards
> Andreas Bach Aaen_______________________________________________
> Cocci mailing list
> Cocci at diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
> 


-- 
Nicolas Palix


More information about the Cocci mailing list