[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [feature request] search the place where the header file is included
From: |
Shigio Yamaguchi |
Subject: |
Re: [feature request] search the place where the header file is included |
Date: |
Sat, 15 Mar 2003 03:32:28 +0900 |
> I want the function to find quickly the place where the header file is used
> by following operation.
>
> >global -Prx 'die.h'
> die.h 42 gctags/C.c #include "die.h"
> die.h 42 gctags/Cpp.c #include "die.h"
> die.h 38 gctags/java.c #include "die.h"
> die.h 38 libutil/conf.c #include "die.h"
> die.h 43 libutil/dbop.c #include "die.h"
> die.h 34 libutil/defined.c #include "die.h"
> die.h 30 libutil/die.c #include "die.h"
> ....
How about using -I option?
% global -xI die.h
die.h 42 gctags/C.c #include "die.h"
die.h 42 gctags/Cpp.c #include "die.h"
die.h 38 gctags/java.c #include "die.h"
die.h 38 libutil/conf.c #include "die.h"
die.h 43 libutil/dbop.c #include "die.h"
...
By the way, I have found a bug about -I option.
I have already committed this patch.
Index: global/global.c
===================================================================
RCS file: /cvsroot/global/global/global/global.c,v
retrieving revision 1.55
diff -c -r1.55 global.c
*** global/global.c 22 Jul 2002 06:29:15 -0000 1.55
--- global/global.c 14 Mar 2003 17:55:18 -0000
***************
*** 412,417 ****
--- 412,419 ----
strbuf_puts(pathfilter, " --absolute ");
else /* relative path name */
strbuf_puts(pathfilter, " --relative ");
+ if (xflag)
+ strbuf_puts(pathfilter, " --cxref ");
strbuf_puts(pathfilter, root);
strbuf_putc(pathfilter, ' ');
strbuf_puts(pathfilter, cwd);
Index: gtags/gtags.c
===================================================================
RCS file: /cvsroot/global/global/gtags/gtags.c,v
retrieving revision 1.61
diff -c -r1.61 gtags.c
*** gtags/gtags.c 1 Mar 2003 15:37:26 -0000 1.61
--- gtags/gtags.c 14 Mar 2003 17:55:22 -0000
***************
*** 58,64 ****
char *now(void);
int printconf(char *);
void set_base_directory(char *, char *);
! void put_converting(char *, int);
int cflag; /* compact format */
int iflag; /* incremental update */
--- 58,64 ----
char *now(void);
int printconf(char *);
void set_base_directory(char *, char *);
! void put_converting(char *, int, int);
int cflag; /* compact format */
int iflag; /* incremental update */
***************
*** 80,85 ****
--- 80,86 ----
int do_write;
int do_relative;
int do_absolute;
+ int cxref;
int do_expand;
int do_date;
int do_pwd;
***************
*** 113,118 ****
--- 114,120 ----
static struct option const long_options[] = {
{"absolute", no_argument, &do_absolute, 1},
{"compact", no_argument, NULL, 'c'},
+ {"cxref", no_argument, &cxref, 1},
{"incremental", no_argument, NULL, 'i'},
{"omit-gsyms", no_argument, NULL, 'o'},
{"quiet", no_argument, NULL, 'q'},
***************
*** 533,539 ****
die("do_relative: 2 arguments needed.");
set_base_directory(root, cwd);
while (strbuf_fgets(ib, stdin, 0) != NULL)
! put_converting(strbuf_value(ib), do_absolute ? 1 : 0);
strbuf_close(ib);
exit(0);
} else if (Iflag) {
--- 535,541 ----
die("do_relative: 2 arguments needed.");
set_base_directory(root, cwd);
while (strbuf_fgets(ib, stdin, 0) != NULL)
! put_converting(strbuf_value(ib), do_absolute ? 1 : 0,
cxref);
strbuf_close(ib);
exit(0);
} else if (Iflag) {
***************
*** 1117,1122 ****
--- 1119,1125 ----
*
* i) line raw output from global(1)
* i) absolute 1: absolute, 0: relative
+ * i) cxref 1: -x format, 0: file name only
*/
static STRBUF *abspath;
static char basedir[MAXPATHLEN+1];
***************
*** 1137,1154 ****
/* leave abspath unclosed. */
}
void
! put_converting(line, absolute)
char *line;
int absolute;
{
char buf[MAXPATHLEN+1];
! char *p;
/*
* print until path name.
*/
! for (p = line; *p && *p != '.'; p++)
! (void)putc(*p, stdout);
if (*p++ == '\0')
return;
/*
--- 1140,1164 ----
/* leave abspath unclosed. */
}
void
! put_converting(line, absolute, cxref)
char *line;
int absolute;
+ int cxref;
{
char buf[MAXPATHLEN+1];
! char *p = line;
/*
* print until path name.
*/
! if (cxref) {
! /* print tag name */
! for (; *p && !isspace(*p); p++)
! (void)putc(*p, stdout);
! /* print blanks and line number */
! for (; *p && *p != '.'; p++)
! (void)putc(*p, stdout);
! }
if (*p++ == '\0')
return;
/*
--
Shigio Yamaguchi <address@hidden> - Tama Communications Corporation
PGP fingerprint: D1CB 0B89 B346 4AB6 5663 C4B6 3CA5 BBB3 57BE DDA3