68 |
* anchor_prepare: setup input stream. |
* anchor_prepare: setup input stream. |
69 |
* |
* |
70 |
* i) path_list \0 separated list of paths |
* i) path_list \0 separated list of paths |
71 |
|
* |
72 |
*/ |
*/ |
73 |
void |
void |
74 |
anchor_prepare(STRBUF *path_list) |
anchor_prepare(STRBUF *path_list) |
75 |
{ |
{ |
76 |
|
/* |
77 |
|
* Option table: |
78 |
|
* We use blank string instead of null string not to change the length. |
79 |
|
*/ |
80 |
|
char *options[] = {NULL, " ", "r", "s"}; |
81 |
int db; |
int db; |
82 |
struct anchor_input *input; |
struct anchor_input *input; |
|
STRBUF *comline = strbuf_open(0); |
|
83 |
|
|
84 |
for (db = GTAGS; db < GTAGLIM; db++) { |
for (db = GTAGS; db < GTAGLIM; db++) { |
85 |
|
char comline[MAXFILLEN]; |
86 |
|
|
87 |
if (!symbol && db == GSYMS) |
if (!symbol && db == GSYMS) |
88 |
continue; |
continue; |
89 |
input = &anchor_input[db - GTAGS]; |
/* |
90 |
|
* Setup input stream. |
91 |
|
* |
92 |
|
* Htags(1) should not use gtags-parser(1) directly; |
93 |
|
* it should use global(1) with the -f option instead. |
94 |
|
* Because gtags-parser is part of the implementation of |
95 |
|
* gtags(1) and global(1), and htags is only an application |
96 |
|
* program which uses global(1). If htags depends on |
97 |
|
* gtags-parser, it will become difficult to change the |
98 |
|
* implementation of gtags and global. |
99 |
|
*/ |
100 |
|
snprintf(comline, sizeof(comline), "global -fn%s", options[db]); |
101 |
|
input = &anchor_input[db]; |
102 |
input->command = strbuf_open(0); |
input->command = strbuf_open(0); |
103 |
input->ib = strbuf_open(MAXBUFLEN); |
input->ib = strbuf_open(MAXBUFLEN); |
104 |
strbuf_reset(comline); |
makecommand(comline, path_list, input->command); |
|
if (!getconfs(dbname(db), comline)) |
|
|
die("cannot get parser for %s.", dbname(db)); |
|
|
makecommand(strbuf_value(comline), path_list, input->command); |
|
105 |
/* |
/* |
106 |
* We assume that the output of gtags-parser is sorted by the path. |
* Though the output of global -f is not necessarily sorted |
107 |
* About the other parsers, it is not guaranteed, so we sort it |
* by the path, it is guaranteed that the records concerning |
108 |
* using external sort command (gnusort). |
* the same file are consecutive. |
109 |
*/ |
*/ |
|
if (locatestring(strbuf_value(comline), "gtags-parser", MATCH_FIRST) == NULL) |
|
|
strbuf_puts(input->command, "| gnusort -k 3,3"); |
|
110 |
input->ip = popen(strbuf_value(input->command), "r"); |
input->ip = popen(strbuf_value(input->command), "r"); |
111 |
if (input->ip == NULL) |
if (input->ip == NULL) |
112 |
die("cannot execute command '%s'.", strbuf_value(input->command)); |
die("cannot execute command '%s'.", strbuf_value(input->command)); |
132 |
die("The output of parser is illegal.\n%s", input->ctags_x); |
die("The output of parser is illegal.\n%s", input->ctags_x); |
133 |
} |
} |
134 |
} |
} |
|
strbuf_close(comline); |
|
135 |
} |
} |
136 |
/* |
/* |
137 |
* anchor_load: load anchor table |
* anchor_load: load anchor table |
155 |
for (db = GTAGS; db < GTAGLIM; db++) { |
for (db = GTAGS; db < GTAGLIM; db++) { |
156 |
if (!symbol && db == GSYMS) |
if (!symbol && db == GSYMS) |
157 |
continue; |
continue; |
158 |
input = &anchor_input[db - GTAGS]; |
input = &anchor_input[db]; |
159 |
/* |
/* |
160 |
* Read from input stream until it reaches end of file |
* Read from input stream until it reaches end of file |
161 |
* or the line of another file appears. |
* or the line of another file appears. |