Jussi Jumppanen a écrit :
Vincent Richomme Wrote:I would like to know if there are some parsers/scripts that could parse some C/C++ language and that could insert printf in each function.One option would be to use a regular expression within a search and replace.Just as a simple test I came up regexp that does seems do the trick: Search string: (^[_a-z0-9]+[ &*\t]+[_a-z0-9 &*\t]*[_a-z0-9]+[ \t]*[(]+.*[^;]+)(\n{\n) Replace String: \0fprintf(stderr, ("\1") Any regexp enabled text editor should be able to handle the search and replace. It worked just fine in the Zeus IDE ;) You could also use SED or AWK to do a batch mode regexp search and replace.NOTE: The regexp was only tested for the function declaration that you posted, so it will almost certainly need to be tweaked for other variations of function definitions.
Hul doesn't work because it matches some typedef struct like this :
typedef struct c_parser GTY(())
{
...
} c_parser;
