From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Dziulko Newsgroups: gmane.emacs.help Subject: Re: etags Date: Thu, 19 Jun 2003 08:47:28 -0400 (EDT) Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <160scb.f6.ln@acm.acm> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1056026939 2699 80.91.224.249 (19 Jun 2003 12:48:59 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 19 Jun 2003 12:48:59 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 19 14:48:55 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19SyqV-0000h4-00 for ; Thu, 19 Jun 2003 14:48:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19SypQ-0001M1-Gy for gnu-help-gnu-emacs@m.gmane.org; Thu, 19 Jun 2003 08:47:48 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19Syp9-0001Ih-LH for help-gnu-emacs@gnu.org; Thu, 19 Jun 2003 08:47:31 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19Syp7-0001Hh-Ot for help-gnu-emacs@gnu.org; Thu, 19 Jun 2003 08:47:30 -0400 Original-Received: from klaatu.canisius.edu ([138.92.8.100]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19Syp7-0001GA-86 for help-gnu-emacs@gnu.org; Thu, 19 Jun 2003 08:47:29 -0400 Original-Received: from localhost (dziulko@localhost) by klaatu.canisius.edu (8.11.6/8.11.6) with ESMTP id h5JClS919494 for ; Thu, 19 Jun 2003 08:47:28 -0400 Original-To: help-gnu-emacs@gnu.org In-Reply-To: <160scb.f6.ln@acm.acm> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11072 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11072 On Thu, 19 Jun 2003, Alan Mackenzie wrote: > Kevin Dziulko wrote on Tue, 17 Jun 2003 > 08:09:13 -0400 (EDT): > > Hello > > > I am looking for a way to get a list of all user defined #define's in some > > C code that actually gets used. I was reading up a little on etags, and I > > think it might help me with this. Has anyone done or seen anything close > > to this? > > > Example: > > #include > > #define MSG1 "Hello, world!" > > #define CONST1 42 > > > int main () > > { > > (void) printf("\n%s\n", MSG1); > > > return 0; > > } > > > ///////////////// > > > Idealy, I would want something to say: > > > Line 7: MSG1 > > grep is your friend. "man grep" should tell you all you want to know > about it (and a lot more besides). (I'm guessing you're on some sort of > Unix system, by the way.) A command something like the following will > give you the information you want: > > grep -n "^#define" *.c > > You probably won't like the exact form the info takes, so you might want > to pipe it through a small script (written in something like sed or AWK > or Python) to massage it into something more readable. > > The above command assumes that all your files.c are in the current > directory. If they're not, you'll have to "find" them first, then do the > above. Spend a few hours reading "man find"; it'll be time very well > spent. Then you'll end up writing something like this: > > find . -name "*.c" -exec grep -n "^define" \{} \; -print > > > Perhaps this isn't the best place to post this. If you know a better > > place, please let me know. > > It isn't really the best place, no. One of the groups on Unix shell > commands would have been better. But what the heck, have a great day. > > > Thanks a lot! > > Kevin > > Thanks for your reply, but "grep -n "^#define" *.c" isn't even close to what I'm looking for. I don't want a list of #define'ed constants, but rather #define'ed constants *THAT ACTUALLY GET USED*. That's why in my example I just wanted "Line 7: MSG1" and nothing about CONST1 to ever get listed. [also, I only want defines from my local program listed, and not any of the system library defines]. The cxref command is the closest to this that I've found thus far. Which one of the Unix shell groups should I use? I can't seem to find the right mailing list. Thanks again!! Kevin