Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 2004 21:50:03 -0400
From:      =?UTF-8?Q?Josh_=C5=8Cckert?= <torstenvl@gmail.com>
To:        "Jeremy C. Reed" <reed@reedmedia.net>
Cc:        freebsd-chat@freebsd.org
Subject:   Re: tool for listing C functions used in source code?
Message-ID:  <126eac4804082018506944fcf6@mail.gmail.com>
In-Reply-To: <126eac48040820184330a9c344@mail.gmail.com>
References:  <Pine.LNX.4.43.0408201620590.11735-100000@pilchuck.reedmedia.net> <126eac48040820184330a9c344@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 20 Aug 2004 21:43:52 -0400, Josh =C5=8Cckert <torstenvl@gmail.com> =
wrote:
>=20
>=20
> On Fri, 20 Aug 2004 16:41:29 -0700 (PDT), Jeremy C. Reed
> <reed@reedmedia.net> wrote:
> > What are some good tools for searching source code that can list all th=
e
> > standard libc functions used?
> >
> > For example, I'd like to point it at some code and have it tell me that=
 it
> > uses:
> >
> > strftime 1 time
> > isatty 1
> > setlocale 1
> > getuid 1
> > getbsize 5
> > strlen 25
> > et cetera
> >
> > Then I could see what the most used functions are for some research I a=
m
> > doing.
> >
> > Does anyone know of a tool that can do that?
> >
> > I am testing cscope, but it doesn't appear to behave like I want. I do
> > like how it looks at the includes though. I don't want it to be
> > interactive. I just want a list of all functions used. I can use sort a=
nd
> > uniq to count if needed.
> >
> > Next I'll look at cflow. But I am not sure if does what I want either.
> >
> >  Jeremy C. Reed
> >
> >                          BSD News, BSD tutorials, BSD links
> >                          http://www.bsdnewsletter.com/
> >
> > _______________________________________________
> > freebsd-chat@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-chat
> > To unsubscribe, send any mail to "freebsd-chat-unsubscribe@freebsd.org"
> >
>=20
> I would try something like....
>=20
> for i in `ls /usr/share/man/man3/ | sed -e '/\\\..*$/d'`; do echo $i;
> grep -c $i filename.c; done
>=20
> in BASH
>=20
> That's untested, but try it. If you don't understand it, try
> man sed
> man grep
>=20

PS -- If you think you might use the same function more than once on a
single line, you might want to replace all tokens that can separate
two function calls with newlines and create a temporary file and then
search that instead... I'm not sure if grep counts a line that matches
twice as one match or two matches. Also, if you want only, say,
ISO/ANSI C standard library functions to be counted, you'll have to
provide your own list and use that instead of the listing of
/usr/share/man/man3



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?126eac4804082018506944fcf6>