121 |
* makecommand: make command line to make global tag file |
* makecommand: make command line to make global tag file |
122 |
* |
* |
123 |
* i) comline skeleton command line |
* i) comline skeleton command line |
124 |
* i) path path name |
* i) path_list \0 separated list of path names |
125 |
* o) sb command line |
* o) sb command line |
126 |
* |
* |
127 |
* command skeleton is like this: |
* command skeleton is like this: |
130 |
* 'gtags-parser -r' |
* 'gtags-parser -r' |
131 |
*/ |
*/ |
132 |
void |
void |
133 |
makecommand(comline, path, sb) |
makecommand(comline, path_list, sb) |
134 |
const char *comline; |
const char *comline; |
135 |
const char *path; |
STRBUF *path_list; |
136 |
STRBUF *sb; |
STRBUF *sb; |
137 |
{ |
{ |
138 |
const char *p = locatestring(comline, "%s", MATCH_FIRST); |
const char *p = locatestring(comline, "%s", MATCH_FIRST); |
139 |
|
const char *path, *end; |
140 |
|
|
141 |
if (p) { |
if (p) { |
142 |
strbuf_nputs(sb, comline, p - comline); |
strbuf_nputs(sb, comline, p - comline); |
|
strbuf_puts(sb, path); |
|
|
strbuf_puts(sb, p + 2); |
|
143 |
} else { |
} else { |
144 |
strbuf_puts(sb, comline); |
strbuf_puts(sb, comline); |
145 |
strbuf_putc(sb, ' '); |
strbuf_putc(sb, ' '); |
146 |
|
} |
147 |
|
|
148 |
|
path = strbuf_value(path_list); |
149 |
|
end = path + strbuf_getlen(path_list); |
150 |
|
while (path < end) { |
151 |
strbuf_puts(sb, path); |
strbuf_puts(sb, path); |
152 |
|
path += strlen(path) + 1; |
153 |
|
if (path < end) |
154 |
|
strbuf_putc(sb, ' '); |
155 |
} |
} |
156 |
|
|
157 |
|
if (p) |
158 |
|
strbuf_puts(sb, p + 2); |
159 |
} |
} |
160 |
/* |
/* |
161 |
* formatcheck: check format of tag command's output |
* formatcheck: check format of tag command's output |
208 |
/* |
/* |
209 |
* path name |
* path name |
210 |
*/ |
*/ |
211 |
if (format == GTAGS_STANDARD) { |
if ((format & (GTAGS_PATHINDEX | GTAGS_COMPACT)) != (GTAGS_PATHINDEX | GTAGS_COMPACT)) { |
212 |
p = ptable.part[2].start; |
p = ptable.part[2].start; |
213 |
if (!(*p == '.' && *(p + 1) == '/' && *(p + 2))) { |
if (!(*p == '.' && *(p + 1) == '/' && *(p + 2))) { |
214 |
recover(&ptable); |
recover(&ptable); |
215 |
die("path name must start with './'.\n'%s'", line); |
die("path name must start with './'.\n'%s'", line); |
216 |
} |
} |
217 |
} |
} else { |
|
if (format & GTAGS_PATHINDEX) { |
|
218 |
for (p = ptable.part[2].start; *p; p++) |
for (p = ptable.part[2].start; *p; p++) |
219 |
if (!isdigit((unsigned char)*p)) { |
if (!isdigit((unsigned char)*p)) { |
220 |
recover(&ptable); |
recover(&ptable); |
350 |
gtop->ib = strbuf_open(MAXBUFLEN); |
gtop->ib = strbuf_open(MAXBUFLEN); |
351 |
else |
else |
352 |
gtop->sb = strbuf_open(0); |
gtop->sb = strbuf_open(0); |
353 |
} |
} else if (gtop->format == GTAGS_PATHINDEX && gtop->mode != GTAGS_READ) |
354 |
|
gtop->sb = strbuf_open(0); |
355 |
return gtop; |
return gtop; |
356 |
} |
} |
357 |
/* |
/* |
361 |
* i) tag tag name |
* i) tag tag name |
362 |
* i) record ctags -x image |
* i) record ctags -x image |
363 |
* |
* |
364 |
* NOTE: If format is GTAGS_COMPACT then this function is destructive. |
* NOTE: If format is GTAGS_COMPACT or GTAGS_PATHINDEX |
365 |
|
* then this function is destructive. |
366 |
*/ |
*/ |
367 |
void |
void |
368 |
gtags_put(gtop, tag, record) |
gtags_put(gtop, tag, record) |
373 |
const char *line, *path; |
const char *line, *path; |
374 |
SPLIT ptable; |
SPLIT ptable; |
375 |
|
|
376 |
if (gtop->format == GTAGS_STANDARD || gtop->format == GTAGS_PATHINDEX) { |
if (gtop->format == GTAGS_STANDARD) { |
377 |
/* entab(record); */ |
/* entab(record); */ |
378 |
dbop_put(gtop->dbop, tag, record); |
dbop_put(gtop->dbop, tag, record); |
379 |
return; |
return; |
380 |
} |
} |
381 |
|
if (gtop->format == GTAGS_PATHINDEX) { |
382 |
|
const char *fid; |
383 |
|
char *p = locatestring(record, "./", MATCH_FIRST); |
384 |
|
int savec; |
385 |
|
|
386 |
|
if (p == NULL) |
387 |
|
die("path name not found."); |
388 |
|
path = p; |
389 |
|
p += 2; |
390 |
|
while (*p && !isspace((unsigned char)*p)) |
391 |
|
p++; |
392 |
|
savec = *p; |
393 |
|
*p = '\0'; |
394 |
|
fid = gpath_path2fid(path); |
395 |
|
if (fid == NULL) |
396 |
|
die("GPATH is corrupted.('%s' not found)", path); |
397 |
|
*p = savec; |
398 |
|
strbuf_reset(gtop->sb); |
399 |
|
strbuf_nputs(gtop->sb, record, path - record); |
400 |
|
strbuf_puts(gtop->sb, fid); |
401 |
|
strbuf_puts(gtop->sb, p); |
402 |
|
dbop_put(gtop->dbop, tag, strbuf_value(gtop->sb)); |
403 |
|
return; |
404 |
|
} |
405 |
/* |
/* |
406 |
* gtop->format & GTAGS_COMPACT |
* gtop->format & GTAGS_COMPACT |
407 |
*/ |
*/ |
438 |
recover(&ptable); |
recover(&ptable); |
439 |
} |
} |
440 |
/* |
/* |
441 |
* gtags_add: add tags belonging to the path into tag file. |
* gtags_add: add tags belonging to the path list into tag file. |
442 |
* |
* |
443 |
* i) gtop descripter of GTOP |
* i) gtop descripter of GTOP |
444 |
* i) comline tag command line |
* i) comline tag command line |
445 |
* i) path source file |
* i) path_list \0 separated list of source files |
446 |
* i) flags GTAGS_UNIQUE, GTAGS_EXTRACTMETHOD, GTAGS_DEBUG |
* i) flags GTAGS_UNIQUE, GTAGS_EXTRACTMETHOD, GTAGS_DEBUG |
447 |
*/ |
*/ |
448 |
void |
void |
449 |
gtags_add(gtop, comline, path, flags) |
gtags_add(gtop, comline, path_list, flags) |
450 |
GTOP *gtop; |
GTOP *gtop; |
451 |
const char *comline; |
const char *comline; |
452 |
const char *path; |
STRBUF *path_list; |
453 |
int flags; |
int flags; |
454 |
{ |
{ |
455 |
const char *ctags_x; |
const char *ctags_x; |
457 |
STRBUF *sb = strbuf_open(0); |
STRBUF *sb = strbuf_open(0); |
458 |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
459 |
const char *fid; |
const char *fid; |
460 |
|
const char *path, *end; |
461 |
|
|
462 |
/* |
/* |
463 |
* add path index if not yet. |
* add path index if not yet. |
464 |
*/ |
*/ |
465 |
gpath_put(path); |
path = strbuf_value(path_list); |
466 |
|
end = path + strbuf_getlen(path_list); |
467 |
|
while (path < end) { |
468 |
|
gpath_put(path); |
469 |
|
path += strlen(path) + 1; |
470 |
|
} |
471 |
/* |
/* |
472 |
* make command line. |
* make command line. |
473 |
*/ |
*/ |
474 |
makecommand(comline, path, sb); |
makecommand(comline, path_list, sb); |
|
/* |
|
|
* get file id. |
|
|
*/ |
|
|
if (gtop->format & GTAGS_PATHINDEX) { |
|
|
if (!(fid = gpath_path2fid(path))) |
|
|
die("GPATH is corrupted.('%s' not found)", path); |
|
|
} else |
|
|
fid = "0"; |
|
475 |
/* |
/* |
476 |
* Compact format. |
* Compact format. |
477 |
*/ |
*/ |
478 |
if (gtop->format & GTAGS_PATHINDEX) { |
if (gtop->format & GTAGS_COMPACT) { |
479 |
strbuf_puts(sb, "| gtags --sed"); |
if (gtop->format & GTAGS_PATHINDEX) { |
480 |
strbuf_putc(sb, ' '); |
/* |
481 |
strbuf_puts(sb, fid); |
* get file id. |
482 |
} |
*/ |
483 |
if (gtop->format & GTAGS_COMPACT) |
path = strbuf_value(path_list); |
484 |
|
if (!(fid = gpath_path2fid(path))) |
485 |
|
die("GPATH is corrupted.('%s' not found)", path); |
486 |
|
strbuf_puts(sb, "| gtags --sed"); |
487 |
|
strbuf_putc(sb, ' '); |
488 |
|
strbuf_puts(sb, fid); |
489 |
|
} |
490 |
|
|
491 |
strbuf_puts(sb, "| gnusort -k 1,1 -k 2,2n"); |
strbuf_puts(sb, "| gnusort -k 1,1 -k 2,2n"); |
492 |
if (flags & GTAGS_UNIQUE) |
if (flags & GTAGS_UNIQUE) |
493 |
strbuf_puts(sb, " -u"); |
strbuf_puts(sb, " -u"); |
494 |
|
} |
495 |
#ifdef DEBUG |
#ifdef DEBUG |
496 |
if (flags & GTAGS_DEBUG) |
if (flags & GTAGS_DEBUG) |
497 |
fprintf(stderr, "gtags_add() executing '%s'\n", strbuf_value(sb)); |
fprintf(stderr, "gtags_add() executing '%s'\n", strbuf_value(sb)); |