Thanks for the sugestion. Actually I already do have a regular expression for 
inserting RELEASESTR() after the first #include <std.h>, but it doesn't work 
well in all cases. Coccinelle would do the job better. A mixed job where a 
regulaer expression removes RELEASESTR and Coccinelle inserts it would work, 
but a clean Coccinelle expression would be easier to handle.

The problem with regular expressions is to get the spacing right. Over 
thousands of files there are variants where more spacing is added arround like 
"#include    <std.h>  ". There are many variants, Coccinelle as a c-parser do a 
better job - except that I in this case can't make it match RELEASESTR. I have 
no problem in making it match #include <std.h>.

Regards
Andreas Bach Aaen 

-----Original Message-----
From: Håkon Løvdal [mailto:[email protected]] 
Sent: 2. marts 2010 15:50
To: Aaen, Andreas.Bach
Cc: [email protected]
Subject: Re: [Cocci] How to remove a macro...

On 2 March 2010 14:55, Aaen, Andreas.Bach <[email protected]> 
wrote:
> Actually I would like to build a litte more complex rule:
> ---------------
> @@
> @@
> -RELEASESTR("$Id:$");
> @r@
> @@
> #include <std.h>
> +RELEASESTR("$Id:$");
> -----------------
>
> So that I am sure that there only is one RELEASESTR in each file and 
> that it's lpacved right after #include <std.h>

Withouth intending to destroy the fun of trying to make coccinelle do the job, 
I guess that

     perl -ni -e 'print unless /RELEASESTR\(.*\);/; print 
"RELEASESTR(\"\$Id:\$\");\n" if /#include <std.h>/;' *.c

would work as well?

BR Håkon Løvdal

_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to