![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SSH doesn't pick up user's project from /etc/project | kurgan | SUN Solaris | 2 | 05-21-2008 09:52 AM |
| Repository Backup Using Unix | MANISH KU | UNIX for Advanced & Expert Users | 0 | 07-04-2007 10:34 PM |
| backup repository in cvs | murad.jaber | SUN Solaris | 9 | 06-03-2007 04:15 AM |
| How to count the record count in an EBCDIC file. | oracle8 | UNIX for Dummies Questions & Answers | 1 | 07-26-2006 04:22 PM |
| Repository of HP-UX 10.20 packages | markos | UNIX for Dummies Questions & Answers | 1 | 03-05-2005 03:54 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
how to count # of functions in a c/c++ project repository
hi,
does anyone know how to count # of functions in a c/c++ project repository using bash or csh? is there a mixture of grep/wc/and redirecting operators. say for instance there is a proj directory called Foo with subfolders A,B,C. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You can try as,
find <dir> -name "*.c" | xargs grep "();" | wc Try out. |
|
#3
|
||||
|
||||
|
muthu,
Wouldnt your query look for zero argument functions ? I was thinking of something on the lines of ctags. Have to read up the man page of ctags. Vino |
|
#4
|
|||
|
|||
|
I am sorry. It will not work. One simple way is, if you use debugging symbols in object then you can use gdb <object> gdb> info function
it will give. Using bash have to think some good ways. |
|
#5
|
||||
|
||||
|
Try this
ctags --c-types=f *.c will produce a tags file. cat tags | wc -l Since there are some extra lines in tags( i think 4-5 lines), this will give you a close count. vino |
|
#6
|
||||
|
||||
|
This should work.
Current directory is your foo directory: Code:
prompt> ctags --c-types=f -R prompt> sed -e '/[ ]*m$/d' -e '/TAG/d' <tags>functions prompt> cat functions | wc -l ctags with --c-types=f will collect all the functions for you. -R will recursivly go into sub-dir a,b,c. sed is needed to remove the TAG entries introduced by ctags Also to remove all lines ending with m i.e. from man ctags m class, struct, or union members functions is the file that holds all the functions under foo And finally wc -l gives you the count you are looking for. Have a look at man ctags. Will help you if you have constraints other than functions. Vino |
||||
| Google The UNIX and Linux Forums |