Here is a small awk script to change the comments :
Code:
# if we are in a C comment, remember it
$0 ~ /\/\*/ {
in_c_comments = 1;
}
# if we are in a C++ comment
$0 ~ /\/\// {
# and not in a C comment
if( in_c_comments == 0 )
{
# embrace with /* */
sub( /\/\/.*/, "/* & */", $0 );
# remove //
sub( /\/\//, "", $0 );
}
}
# if we are going out of a C comment, remember it
$0 ~ /\*\// {
in_c_comments = 0;
}
# for every (modified or not) line
{
# print the line
print $0;
}
Here is a sample header :
Code:
#ifndef _HEADER_TEST_H
#define _HEADER_TEST_H
//TODO changer ce commentaire
/* celui là est bon */
/*
// celui là aussi
// et aussi celui là
*/
//mais pas celui là
#endif /* _HEADER_TEST_H */
And with the command:
awk -f PATH_TO_THE_AWK_SCRIPT PATH_TO_THE_HEADER_TO_MODIFY
the result is:
Code:
#ifndef _HEADER_TEST_H
#define _HEADER_TEST_H
/* TODO changer ce commentaire */
/* celui là est bon */
/*
// celui là aussi
// et aussi celui là
*/
/* mais pas celui là */
#endif /* _HEADER_TEST_H */
I let you create a script that modify every header file, but now that shoul be simple.
See ya,
Vincent
PS: I am quite new to awk, may be my script is not the best solution, but it does what we want it to do...