984 |
/* |
/* |
985 |
* put_converting: convert path into relative or absolute and print. |
* put_converting: convert path into relative or absolute and print. |
986 |
* |
* |
987 |
* i) ctags_x raw output from global(1) |
* i) raw output from global(1) |
988 |
* i) absolute 1: absolute, 0: relative |
* i) absolute 1: absolute, 0: relative |
989 |
* i) cxref 1: -x format, 0: file name only |
* i) cxref 1: -x format, 0: file name only |
990 |
* i) fileid 1: add fid to the head of line, 0: do nothing |
* i) fileid 1: add fid to the head of line, 0: do nothing |
1006 |
/* leave abspath unclosed. */ |
/* leave abspath unclosed. */ |
1007 |
} |
} |
1008 |
void |
void |
1009 |
put_converting(const char *ctags_x, int absolute, int cxref, int fileid) |
put_converting(const char *ctags, int absolute, int cxref, int fileid) |
1010 |
{ |
{ |
|
SPLIT ptable; |
|
1011 |
char buf[MAXPATHLEN+1]; |
char buf[MAXPATHLEN+1]; |
1012 |
const char *fid, *path, *p = ctags_x; |
char *path, *p; |
1013 |
|
|
1014 |
/* |
/* |
|
* Extract path name and convert it to the file id. |
|
|
*/ |
|
|
if (split((char *)ctags_x, 4, &ptable) < 4) { |
|
|
recover(&ptable); |
|
|
die("too small number of parts.\n'%s'", ctags_x); |
|
|
} |
|
|
path = ptable.part[PART_PATH].start; |
|
|
fid = gpath_path2fid(path, NULL); |
|
|
recover(&ptable); |
|
|
/* |
|
1015 |
* print until path name. |
* print until path name. |
1016 |
*/ |
*/ |
1017 |
if (cxref) { |
if (cxref) { |
1018 |
|
int savec = 0; |
1019 |
/* |
/* |
1020 |
* Put file id to the head of the output. |
* Move to the head of path name. |
1021 |
* Global.cgi script generated by htags(1) refers it to |
* |
1022 |
* generate anchor. |
* Don't use split() function, since we must support |
1023 |
|
* following both format: |
1024 |
|
* ctags: main ./main.c 20 |
1025 |
|
* ctags -x: main 20 ./main.c main() |
1026 |
|
*/ |
1027 |
|
/* skip tag name */ |
1028 |
|
for (p = (char *)ctags; *p && !isspace((unsigned char)*p); p++) |
1029 |
|
; |
1030 |
|
/* skip blanks (and line number) */ |
1031 |
|
for (; *p && *p != '.'; p++) |
1032 |
|
; |
1033 |
|
path = p; |
1034 |
|
/* |
1035 |
|
* The --fileid option specified, put file id to the head |
1036 |
|
* of the output like follows. |
1037 |
* |
* |
1038 |
* 120@main 32 ./main.c main(int argc, char **argv) |
* 120@main 32 ./main.c main(int argc, char **argv) |
1039 |
* ~~~ ~~~~~~~~~ |
* ~~~ ~~~~~~~~~ |
1040 |
* ^ | |
* ^ | |
1041 |
* +---------------------+ |
* +---------------------+ |
1042 |
|
* |
1043 |
|
* Global.cgi script generated by htags(1) refers it to |
1044 |
|
* generate anchor. |
1045 |
*/ |
*/ |
1046 |
if (fileid) { |
if (fileid) { |
1047 |
fputs(fid, stdout); |
for (; *p && !isspace((unsigned char)*p); p++) |
1048 |
|
; |
1049 |
|
savec = *p; |
1050 |
|
*p = '\0'; |
1051 |
|
fputs(gpath_path2fid(path, NULL), stdout); |
1052 |
|
*p = savec; |
1053 |
putc('@', stdout); |
putc('@', stdout); |
1054 |
} |
} |
1055 |
for (; *p && p < path; p++) |
for (p = (char *)ctags; *p && p < path; p++) |
1056 |
(void)putc(*p, stdout); |
(void)putc(*p, stdout); |
1057 |
|
} else { |
1058 |
|
path = (char *)ctags; |
1059 |
} |
} |
1060 |
if (*p++ == '\0') |
if (*path++ == '\0') |
1061 |
return; |
return; |
1062 |
/* |
/* |
1063 |
* make absolute path. |
* make absolute path. |
1064 |
*/ |
*/ |
1065 |
strbuf_setlen(abspath, start_point); |
strbuf_setlen(abspath, start_point); |
1066 |
for (; *p && !isspace((unsigned char)*p); p++) |
for (p = path; *p && !isspace((unsigned char)*p); p++) |
1067 |
strbuf_putc(abspath, *p); |
strbuf_putc(abspath, *p); |
1068 |
/* |
/* |
1069 |
* put path with converting. |
* put path with converting. |