how to count # of functions in a c/c++ project repository


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to count # of functions in a c/c++ project repository
# 1  
Old 05-13-2005
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.
# 2  
Old 05-16-2005
You can try as,

find <dir> -name "*.c" | xargs grep "();" | wc

Try out.
# 3  
Old 05-16-2005
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  
Old 05-16-2005
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  
Old 05-16-2005
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  
Old 05-16-2005
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

Explanation for the above.

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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FINDING DUPLICATE PROJECT ( directory project )

I have a project tree like that. after running find command with the -no -empty option, i am able to have a list of non empty directory DO_MY_SEARCH="find . -type d -not -empty -print0" MY_EXCLUDE_DIR1=" -e NOT_IN_USE -e RTMAP -e NOT_USEFULL " echo " " > $MY_TEMP_RESULT_1 while... (2 Replies)
Discussion started by: jcdole
2 Replies

2. Red Hat

Error: Cannot retrieve repository metadata (repomd.xml) for repository: InstallMedia.

Most of my commands are returning this error on RHEL 6 64 bit: Also I tried installing many sofwtares, but it fails to correctly work. For example I treid installing dos2unix: # rpm -ivh dos2unix-5.3.3-5.ram0.98.src.rpm 1:dos2unix warning: user mockbuild does not... (0 Replies)
Discussion started by: India_2014
0 Replies

3. News, Links, Events and Announcements

A new project was posted on The UNIX and Linux Forums project board.

A new project was posted on your project board. Project title: Bash Shell Tutoring Estimated Budget: $50/hr Start date: Immediately Required skills: Linux, Bash, Shell, UNIX I work as a datawarehouse designer and developer. Although I usually stick to the role of an analyst,... (0 Replies)
Discussion started by: Neo
0 Replies

4. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

5. Solaris

Solaris repository

Someone know good software repositories for Solaris 10? I'm searching one with updated packages like Samba3,smbldaptools,openldap,etc Thanks (2 Replies)
Discussion started by: Linusolaradm1
2 Replies

6. Solaris

what is the use of /etc/project file and project administration commands?

i have two doubts.. 1. what is the use /etc/project file. i renamed this file and when i tried to switch user or login with some user account the login was happening slowly. but when i renamed it to original name it was working fine... why so? 2. unix already has useradd and grouadd for... (4 Replies)
Discussion started by: chidori
4 Replies

7. UNIX for Dummies Questions & Answers

Problem when I use Repository

Hi Gurus of Unix I use the Package Manager of OpenSolaris I set my Package Manager : "http://pkg.sunfreeware.com:9000/" But when I try to install packet appear the following Error: Please check the network connection. Is the repository accessible? Transfer from... (0 Replies)
Discussion started by: andresguillen
0 Replies

8. Solaris

SSH doesn't pick up user's project from /etc/project

We have a system running ssh. When a user logs in, they do not get the project they are assigned to (they run under "system"). I verify the project using the command "ps -e -o user,pid,ppid,args,project". If you do a "su - username", the user does get the project they are assigned to (and all... (2 Replies)
Discussion started by: kurgan
2 Replies

9. UNIX for Dummies Questions & Answers

Repository of HP-UX 10.20 packages

Hello, What the adresses of ftps or websites the packages depots to HP-UX 10.20 I am search and google I did not get success. Thanks :D (1 Reply)
Discussion started by: markos
1 Replies
Login or Register to Ask a Question