72 |
void createtags(const char *, const char *, int); |
void createtags(const char *, const char *, int); |
73 |
int printconf(const char *); |
int printconf(const char *); |
74 |
void set_base_directory(const char *, const char *); |
void set_base_directory(const char *, const char *); |
75 |
void put_converting(const char *, int, int); |
void put_converting(const char *, int, int, int); |
76 |
|
|
77 |
int cflag; /* compact format */ |
int cflag; /* compact format */ |
78 |
int iflag; /* incremental update */ |
int iflag; /* incremental update */ |
90 |
int do_relative; |
int do_relative; |
91 |
int do_absolute; |
int do_absolute; |
92 |
int cxref; |
int cxref; |
93 |
|
int fileid; |
94 |
int gtagsconf; |
int gtagsconf; |
95 |
int gtagslabel; |
int gtagslabel; |
96 |
int debug; |
int debug; |
133 |
{"convert", no_argument, &do_convert, 1}, |
{"convert", no_argument, &do_convert, 1}, |
134 |
{"cxref", no_argument, &cxref, 1}, |
{"cxref", no_argument, &cxref, 1}, |
135 |
{"debug", no_argument, &debug, 1}, |
{"debug", no_argument, &debug, 1}, |
136 |
|
{"fileid", no_argument, &fileid, 1}, |
137 |
{"gtagsconf", required_argument, >agsconf, 1}, |
{"gtagsconf", required_argument, >agsconf, 1}, |
138 |
{"gtagslabel", required_argument, >agslabel, 1}, |
{"gtagslabel", required_argument, >agslabel, 1}, |
139 |
{"relative", no_argument, &do_relative, 1}, |
{"relative", no_argument, &do_relative, 1}, |
284 |
fprintf(stdout, "%s\n", getconfline()); |
fprintf(stdout, "%s\n", getconfline()); |
285 |
} |
} |
286 |
exit(0); |
exit(0); |
|
} else if (do_convert) { |
|
|
STRBUF *ib = strbuf_open(MAXBUFLEN); |
|
|
const char *fid; |
|
|
char *p, *q; |
|
|
|
|
|
/* |
|
|
* [Job] |
|
|
* |
|
|
* Read line from stdin and replace " ./<file name> " |
|
|
* with the file number like this. |
|
|
* |
|
|
* <a href='http://xxx/global/S/ ./main.c .html#110'>main</a>\n |
|
|
* | |
|
|
* v |
|
|
* <a href='http://xxx/global/S/39.html#110'>main</a>\n |
|
|
* |
|
|
*/ |
|
|
if (gpath_open(".", 0) < 0) |
|
|
die("GPATH not found."); |
|
|
while (strbuf_fgets(ib, stdin, 0) != NULL) { |
|
|
p = strbuf_value(ib); |
|
|
if (!locatestring(p, "<a ", MATCH_AT_FIRST)) |
|
|
continue; |
|
|
q = locatestring(p, "/S/ ", MATCH_FIRST); |
|
|
if (q == NULL) { |
|
|
printf("%s: ERROR(1): %s", progname, strbuf_value(ib)); |
|
|
continue; |
|
|
} |
|
|
/* Print from the head of line to "/S/". */ |
|
|
for (; p < q; p++) |
|
|
putc(*p, stdout); |
|
|
for (; *p && *p != ' '; p++) |
|
|
putc(*p, stdout); |
|
|
/* Extract path name. */ |
|
|
for (q = ++p; *q && *q != ' '; q++) |
|
|
; |
|
|
if (*q == '\0') { |
|
|
printf("%s: ERROR(2): %s", progname, strbuf_value(ib)); |
|
|
continue; |
|
|
} |
|
|
*q++ = '\0'; |
|
|
/* Convert path name into URL. */ |
|
|
fid = gpath_path2fid(p, NULL); |
|
|
if (fid == NULL) |
|
|
die("GPATH is corrupted.('%s' not found)", p); |
|
|
fputs(fid, stdout); |
|
|
fputs(q, stdout); |
|
|
} |
|
|
gpath_close(); |
|
|
strbuf_close(ib); |
|
|
exit(0); |
|
287 |
} else if (do_sort) { |
} else if (do_sort) { |
288 |
/* |
/* |
289 |
* This code and the makedupindex() in htags(1) compose |
* This code and the makedupindex() in htags(1) compose |
364 |
* main 22 /prj/xxx/libc/func.c main(argc, argv)\n |
* main 22 /prj/xxx/libc/func.c main(argc, argv)\n |
365 |
*/ |
*/ |
366 |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
367 |
const char *root = argv[0]; |
const char *a_root = argv[0]; |
368 |
const char *cwd = argv[1]; |
const char *a_cwd = argv[1]; |
369 |
|
const char *a_dbpath = argv[2]; |
370 |
const char *ctags_x; |
const char *ctags_x; |
371 |
|
|
372 |
if (argc < 2) |
if (argc < 2) |
373 |
die("do_relative: 2 arguments needed."); |
die("do_relative: 2 arguments needed."); |
374 |
set_base_directory(root, cwd); |
set_base_directory(a_root, a_cwd); |
375 |
|
if (gpath_open(a_dbpath, 0) < 0) |
376 |
|
die("GPATH not found."); |
377 |
while ((ctags_x = strbuf_fgets(ib, stdin, 0)) != NULL) |
while ((ctags_x = strbuf_fgets(ib, stdin, 0)) != NULL) |
378 |
put_converting(ctags_x, do_absolute ? 1 : 0, cxref); |
put_converting(ctags_x, do_absolute ? 1 : 0, cxref, fileid); |
379 |
|
gpath_close(); |
380 |
strbuf_close(ib); |
strbuf_close(ib); |
381 |
exit(0); |
exit(0); |
382 |
} else if (Iflag) { |
} else if (Iflag) { |
988 |
/* |
/* |
989 |
* put_converting: convert path into relative or absolute and print. |
* put_converting: convert path into relative or absolute and print. |
990 |
* |
* |
991 |
* i) line raw output from global(1) |
* i) ctags_x raw output from global(1) |
992 |
* i) absolute 1: absolute, 0: relative |
* i) absolute 1: absolute, 0: relative |
993 |
* i) cxref 1: -x format, 0: file name only |
* i) cxref 1: -x format, 0: file name only |
994 |
|
* i) fileid 1: add fid to the head of line, 0: do nothing |
995 |
*/ |
*/ |
996 |
static STRBUF *abspath; |
static STRBUF *abspath; |
997 |
static char basedir[MAXPATHLEN+1]; |
static char basedir[MAXPATHLEN+1]; |
1010 |
/* leave abspath unclosed. */ |
/* leave abspath unclosed. */ |
1011 |
} |
} |
1012 |
void |
void |
1013 |
put_converting(const char *line, int absolute, int cxref) |
put_converting(const char *ctags_x, int absolute, int cxref, int fileid) |
1014 |
{ |
{ |
1015 |
|
SPLIT ptable; |
1016 |
char buf[MAXPATHLEN+1]; |
char buf[MAXPATHLEN+1]; |
1017 |
const char *p = line; |
const char *fid, *path, *p = ctags_x; |
1018 |
|
|
1019 |
/* |
/* |
1020 |
|
* Extract path name and convert it to the file id. |
1021 |
|
*/ |
1022 |
|
if (split((char *)ctags_x, 4, &ptable) < 4) { |
1023 |
|
recover(&ptable); |
1024 |
|
die("too small number of parts.\n'%s'", ctags_x); |
1025 |
|
} |
1026 |
|
path = ptable.part[PART_PATH].start; |
1027 |
|
fid = gpath_path2fid(path, NULL); |
1028 |
|
recover(&ptable); |
1029 |
|
/* |
1030 |
* print until path name. |
* print until path name. |
1031 |
*/ |
*/ |
1032 |
if (cxref) { |
if (cxref) { |
1033 |
/* print tag name */ |
/* |
1034 |
for (; *p && !isspace((unsigned char)*p); p++) |
* Put file id to the head of the output. |
1035 |
(void)putc(*p, stdout); |
* Global.cgi script generated by htags(1) refers it to |
1036 |
/* print blanks and line number */ |
* generate anchor. |
1037 |
for (; *p && *p != '.'; p++) |
* |
1038 |
|
* 120@main 32 ./main.c main(int argc, char **argv) |
1039 |
|
* ~~~ ~~~~~~~~~ |
1040 |
|
* ^ | |
1041 |
|
* +---------------------+ |
1042 |
|
*/ |
1043 |
|
if (fileid) { |
1044 |
|
fputs(fid, stdout); |
1045 |
|
putc('@', stdout); |
1046 |
|
} |
1047 |
|
for (; *p && p < path; p++) |
1048 |
(void)putc(*p, stdout); |
(void)putc(*p, stdout); |
1049 |
} |
} |
1050 |
if (*p++ == '\0') |
if (*p++ == '\0') |