157 |
* formatcheck: check format of tag command's output |
* formatcheck: check format of tag command's output |
158 |
* |
* |
159 |
* i) line input |
* i) line input |
|
* i) format format |
|
160 |
* |
* |
|
* [STANDARD FORMAT] |
|
161 |
* 0 1 2 3 |
* 0 1 2 3 |
162 |
* ---------------------------------------------------- |
* ---------------------------------------------------- |
163 |
* func 83 ./func.c func() |
* func 83 ./func.c func() |
|
* |
|
|
* [PATHINDEX FORMAT] |
|
|
* 0 1 2 3 |
|
|
* ---------------------------------------------------- |
|
|
* func 83 38 func() |
|
|
* |
|
|
* [COMPACT FORMAT] |
|
|
* 0 1 2 |
|
|
* ---------------------------------------------------- |
|
|
* func 38 83,95,103,205 |
|
164 |
*/ |
*/ |
165 |
void |
void |
166 |
formatcheck(line, format) |
formatcheck(line) |
167 |
const char *line; /* virtually const */ |
const char *line; /* virtually const */ |
|
int format; |
|
168 |
{ |
{ |
169 |
int n; |
int n; |
170 |
const char *p; |
const char *p; |
191 |
/* |
/* |
192 |
* path name |
* path name |
193 |
*/ |
*/ |
194 |
if ((format & (GTAGS_PATHINDEX | GTAGS_COMPACT)) != (GTAGS_PATHINDEX | GTAGS_COMPACT)) { |
p = ptable.part[2].start; |
195 |
p = ptable.part[2].start; |
if (!(*p == '.' && *(p + 1) == '/' && *(p + 2))) { |
196 |
if (!(*p == '.' && *(p + 1) == '/' && *(p + 2))) { |
recover(&ptable); |
197 |
recover(&ptable); |
die("path name must start with './'.\n'%s'", line); |
|
die("path name must start with './'.\n'%s'", line); |
|
|
} |
|
|
} else { |
|
|
for (p = ptable.part[2].start; *p; p++) |
|
|
if (!isdigit((unsigned char)*p)) { |
|
|
recover(&ptable); |
|
|
die("file number includes other than digit.\n'%s'", line); |
|
|
} |
|
198 |
} |
} |
199 |
|
|
200 |
recover(&ptable); |
recover(&ptable); |
201 |
} |
} |
202 |
/* |
/* |
346 |
const char *tag; |
const char *tag; |
347 |
const char *record; /* virtually const */ |
const char *record; /* virtually const */ |
348 |
{ |
{ |
349 |
const char *line, *path; |
const char *line, *path, *fid; |
350 |
SPLIT ptable; |
SPLIT ptable; |
351 |
|
|
352 |
if (gtop->format == GTAGS_STANDARD) { |
if (gtop->format == GTAGS_STANDARD) { |
355 |
return; |
return; |
356 |
} |
} |
357 |
if (gtop->format == GTAGS_PATHINDEX) { |
if (gtop->format == GTAGS_PATHINDEX) { |
|
const char *fid; |
|
358 |
char *p = locatestring(record, "./", MATCH_FIRST); |
char *p = locatestring(record, "./", MATCH_FIRST); |
359 |
int savec; |
int savec; |
360 |
|
|
401 |
strbuf_reset(gtop->sb); |
strbuf_reset(gtop->sb); |
402 |
strbuf_puts(gtop->sb, strmake(record, " \t")); |
strbuf_puts(gtop->sb, strmake(record, " \t")); |
403 |
strbuf_putc(gtop->sb, ' '); |
strbuf_putc(gtop->sb, ' '); |
404 |
|
if (gtop->format & GTAGS_PATHINDEX) { |
405 |
|
fid = gpath_path2fid(path); |
406 |
|
if (fid == NULL) |
407 |
|
die("GPATH is corrupted.('%s' not found)", path); |
408 |
|
path = fid; |
409 |
|
} |
410 |
strbuf_puts(gtop->sb, path); |
strbuf_puts(gtop->sb, path); |
411 |
strbuf_putc(gtop->sb, ' '); |
strbuf_putc(gtop->sb, ' '); |
412 |
strbuf_puts(gtop->sb, line); |
strbuf_puts(gtop->sb, line); |
437 |
FILE *ip; |
FILE *ip; |
438 |
STRBUF *sb = strbuf_open(0); |
STRBUF *sb = strbuf_open(0); |
439 |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
STRBUF *ib = strbuf_open(MAXBUFLEN); |
|
const char *fid; |
|
440 |
const char *path, *end; |
const char *path, *end; |
441 |
|
|
442 |
/* |
/* |
456 |
* Compact format. |
* Compact format. |
457 |
*/ |
*/ |
458 |
if (gtop->format & GTAGS_COMPACT) { |
if (gtop->format & GTAGS_COMPACT) { |
459 |
if (gtop->format & GTAGS_PATHINDEX) { |
strbuf_puts(sb, "| gnusort -k3,3 -k 1,1 -k 2,2n"); |
|
/* |
|
|
* get file id. |
|
|
*/ |
|
|
path = strbuf_value(path_list); |
|
|
if (!(fid = gpath_path2fid(path))) |
|
|
die("GPATH is corrupted.('%s' not found)", path); |
|
|
strbuf_puts(sb, "| gtags --sed"); |
|
|
strbuf_putc(sb, ' '); |
|
|
strbuf_puts(sb, fid); |
|
|
} |
|
|
|
|
|
strbuf_puts(sb, "| gnusort -k 1,1 -k 2,2n"); |
|
460 |
if (flags & GTAGS_UNIQUE) |
if (flags & GTAGS_UNIQUE) |
461 |
strbuf_puts(sb, " -u"); |
strbuf_puts(sb, " -u"); |
462 |
} |
} |
472 |
strbuf_trim(ib); |
strbuf_trim(ib); |
473 |
#ifdef DEBUG |
#ifdef DEBUG |
474 |
if (flags & GTAGS_DEBUG) |
if (flags & GTAGS_DEBUG) |
475 |
formatcheck(ctags_x, gtop->format); |
formatcheck(ctags_x); |
476 |
#endif |
#endif |
477 |
/* tag = $1 */ |
/* tag = $1 */ |
478 |
strlimcpy(tag, strmake(ctags_x, " \t"), sizeof(tag)); |
strlimcpy(tag, strmake(ctags_x, " \t"), sizeof(tag)); |