On 8/18/07, Dr.Ruud <[EMAIL PROTECTED]> wrote:
> "Chas Owens" schreef:
> > Dr.Ruud:
> >> mihirtr:
>
> >>> I have multiple C/C++ files which I need to go manually and find out
> >>> specific function call. I want to check 2nd parameter of this
> >>> function
> >>> (Function_To_Look_For) and get value of it and store it in local
> >>> file
> >>
> >> I would use (not Perl but) the preprocessor for that.
> >
> > how?
>
> #define the specific functionname as a macro that builds a specific text
> string that includes the 2nd parameter, run the preprocessor, filter the
> result.
snip
so, something like
[EMAIL PROTECTED]:~$ cat t.c
#include <stdio.h>
return foo (int a, int b, int c) {
return a + b + c;
}
int main (int argc, char** argv) {
foo(foo(10,20,30), 2, 3);
foo(4, 5, 6);
foo(7, 8, 8);
return 0;
}
[EMAIL PROTECTED]:~$ cpp -D"foo(a,b,c)=found func(a, [second parm b], c)"
t.c | perl -lne 'print for /\[second parm .*?\]/g'
[second parm int b]
[second parm 20]
[second parm 2]
[second parm 5]
[second parm 8]
Except for the false positive for the function definition that works
fairly well.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/