all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie<none@example.invalid>
Subject: Re: etags
Date: Thu, 19 Jun 2003 09:36:01 +0000	[thread overview]
Message-ID: <160scb.f6.ln@acm.acm> (raw)
In-Reply-To: mailman.8073.1055852045.21513.help-gnu-emacs@gnu.org

Kevin Dziulko <dziulko@klaatu.canisius.edu> 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 <stdio.h>
> #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

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

       reply	other threads:[~2003-06-19  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.8073.1055852045.21513.help-gnu-emacs@gnu.org>
2003-06-19  9:36 ` Alan Mackenzie [this message]
2003-06-19 12:47   ` etags Kevin Dziulko
2009-11-09  6:53 etags Matzi Kratzi
  -- strict thread matches above, loose matches on Subject: below --
2004-10-06  2:18 etags moheb missaghi
     [not found] <mailman.8237.1056026853.21513.help-gnu-emacs@gnu.org>
2003-06-19 17:42 ` etags Peter Lee
2003-06-17 12:09 etags Kevin Dziulko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160scb.f6.ln@acm.acm \
    --to=none@example.invalid \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.