I was trying to list all functions from a C language project, initially trying with cscope. But I found this post: http://bytes.com/topic/c/answers/222334-list-all-functions-c-files and decided to do it other way.
Lets assume all functions will be something like bla(…), bla_bla(…), bla(_bla)^N, etc.
Then list all lines with this standard:
$ egrep "*[A-Z,a-z,0-1]\(" * > functions.txt
After openning functions.txt I noticed this standard:
Now let us remove “file.c:” using cut command:
cat functions.txt | cut -d: -f2- > functions_nofiles.txt
My initial idea was just remove any text after “(” from this file, but it will not work because casting (i.e. (int) charfunction(); ).
Then I decided to break all lines with empty space, it will remove the casting complexity:
cat functions_nofiles.txt | tr " " "\n" > functions_perlines.txt
Now I just need to remove all lines that doesn’t have “(” :
cat functions_perlines.txt | grep "(" > functions.txt
We need to get only the function name, then of copy name before “(” :
cat functions.txt | cut -d\( -f-1 > realfunctions.txt
After doing it I noticed some *bla, *)bla, !bla, &bla then I just used text editor to replace it.
Finally used sort and uniq command to get a file will all functions.