247 |
*p = '\0'; |
*p = '\0'; |
248 |
limit = p; |
limit = p; |
249 |
|
|
250 |
strbuf_sprintf(sb, "<a href='%s'>root</a>/", root); |
strbuf_sprintf(sb, "%sroot%s/", gen_href_begin_simple(root), gen_href_end()); |
251 |
{ |
{ |
252 |
char *next; |
char *next; |
253 |
|
|
262 |
} |
} |
263 |
if (p > buf) |
if (p > buf) |
264 |
*(p - 1) = sep; |
*(p - 1) = sep; |
265 |
strbuf_sprintf(sb, "<a href='../files/%s'>%s</a>/", |
strbuf_puts(sb, gen_href_begin("../files", path2fid(path), HTML, NULL)); |
266 |
path2url(path), unit); |
strbuf_puts(sb, unit); |
267 |
|
strbuf_puts(sb, gen_href_end()); |
268 |
|
strbuf_putc(sb, '/'); |
269 |
} |
} |
270 |
} |
} |
271 |
return strbuf_value(sb); |
return strbuf_value(sb); |
275 |
* link_format: make hypertext from anchor array. |
* link_format: make hypertext from anchor array. |
276 |
* |
* |
277 |
* i) (previous, next, first, last, top, bottom) |
* i) (previous, next, first, last, top, bottom) |
278 |
|
* -1: top, -2: bottom, other: line number |
279 |
* r) HTML |
* r) HTML |
280 |
*/ |
*/ |
281 |
char * |
char * |
293 |
sb = strbuf_open(0); |
sb = strbuf_open(0); |
294 |
for (i = 0; i < A_LIMIT; i++) { |
for (i = 0; i < A_LIMIT; i++) { |
295 |
if (i == A_INDEX) { |
if (i == A_INDEX) { |
296 |
strbuf_sprintf(sb, "<a href='../mains.%s'>", normal_suffix); |
strbuf_puts(sb, gen_href_begin("..", "mains", normal_suffix, NULL)); |
297 |
} else if (i == A_HELP) { |
} else if (i == A_HELP) { |
298 |
strbuf_sprintf(sb, "<a href='../help.%s'>", normal_suffix); |
strbuf_puts(sb, gen_href_begin("..", "help", normal_suffix, NULL)); |
299 |
} else if (ref[i]) { |
} else if (ref[i]) { |
300 |
strbuf_puts(sb, "<a href='#"); |
char tmp[32], *key = tmp; |
301 |
|
|
302 |
if (ref[i] == -1) |
if (ref[i] == -1) |
303 |
strbuf_puts(sb, "TOP"); |
key = "TOP"; |
304 |
else if (ref[i] == -2) |
else if (ref[i] == -2) |
305 |
strbuf_puts(sb, "BOTTOM"); |
key = "BOTTOM"; |
306 |
else |
else |
307 |
strbuf_putn(sb, ref[i]); |
snprintf(tmp, sizeof(tmp), "%d", ref[i]); |
308 |
strbuf_puts(sb, "'>"); |
strbuf_puts(sb, gen_href_begin(NULL, NULL, NULL, key)); |
309 |
} |
} |
310 |
if (icon_list) { |
if (icon_list) { |
311 |
char tmp[MAXPATHLEN]; |
char tmp[MAXPATHLEN]; |
315 |
strbuf_sprintf(sb, "[%s]", label[i]); |
strbuf_sprintf(sb, "[%s]", label[i]); |
316 |
} |
} |
317 |
if (i == A_INDEX || i == A_HELP || ref[i] != 0) |
if (i == A_INDEX || i == A_HELP || ref[i] != 0) |
318 |
strbuf_puts(sb, "</a>"); |
strbuf_puts(sb, gen_href_end()); |
319 |
} |
} |
320 |
return strbuf_value(sb); |
return strbuf_value(sb); |
321 |
} |
} |
437 |
} |
} |
438 |
strbuf_puts(outbuf, name); |
strbuf_puts(outbuf, name); |
439 |
} else { |
} else { |
440 |
|
/* |
441 |
|
* About cache record format, please see the comment in cache.c. |
442 |
|
*/ |
443 |
if (*line == ' ') { |
if (*line == ' ') { |
444 |
int id = atoi(++line); |
char tmp[MAXPATHLEN]; |
445 |
|
char *id = strmake(++line, " "); |
446 |
char *count = locatestring(line, " ", MATCH_FIRST) + 1; |
char *count = locatestring(line, " ", MATCH_FIRST) + 1; |
447 |
|
char *dir, *file, *suffix = NULL; |
448 |
|
|
|
strbuf_puts(outbuf, "<a href='"); |
|
449 |
if (dynamic) { |
if (dynamic) { |
450 |
char *dir = (*action == '/') ? "" : "../"; |
dir = (*action == '/') ? NULL : ".."; |
451 |
char *s; |
char *s; |
452 |
|
|
453 |
if (db == GTAGS) |
if (db == GTAGS) |
456 |
s = "reference"; |
s = "reference"; |
457 |
else |
else |
458 |
s = "symbol"; |
s = "symbol"; |
459 |
strbuf_sprintf(outbuf, "%s%s?pattern=%s&type=%s", |
snprintf(tmp, sizeof(tmp), "%s?pattern=%s&type=%s", |
460 |
dir, action, name, s); |
action, name, s); |
461 |
|
file = tmp; |
462 |
} else { |
} else { |
|
char *dir; |
|
|
|
|
463 |
if (type == 'R') |
if (type == 'R') |
464 |
dir = DEFS; |
dir = upperdir(DEFS); |
465 |
else if (type == 'Y') |
else if (type == 'Y') |
466 |
dir = SYMS; |
dir = upperdir(SYMS); |
467 |
else /* 'D', 'M' or 'T' */ |
else /* 'D', 'M' or 'T' */ |
468 |
dir = REFS; |
dir = upperdir(REFS); |
469 |
strbuf_sprintf(outbuf, "../%s/%d.%s", dir, id, HTML); |
file = id; |
470 |
|
suffix = HTML; |
471 |
} |
} |
472 |
strbuf_sprintf(outbuf, "' title='%s'>%s</a>", tooltip(type, -1, count), name); |
strbuf_puts(outbuf, gen_href_begin_with_title(dir, file, suffix, NULL, tooltip(type, -1, count))); |
473 |
|
strbuf_puts(outbuf, name); |
474 |
|
strbuf_puts(outbuf, gen_href_end()); |
475 |
} else { |
} else { |
476 |
int lno = atoi(line); |
char lno[32]; |
477 |
char *filename = strmake(locatestring(line, " ", MATCH_FIRST) + 1, " ") |
char *filename; |
478 |
|
|
479 |
|
strlimcpy(lno, strmake(line, " "), sizeof(lno)); |
480 |
|
filename = strmake(locatestring(line, " ", MATCH_FIRST) + 1, " ") |
481 |
+ 2; /* remove './' */ |
+ 2; /* remove './' */ |
482 |
char *url = path2url(filename); |
strbuf_puts(outbuf, gen_href_begin_with_title(upperdir(SRCS), path2fid(filename), HTML, lno, tooltip(type, atoi(lno), filename))); |
483 |
strbuf_sprintf(outbuf, "<a href='../%s/%s#%d' title='%s'>%s</a>", |
strbuf_puts(outbuf, name); |
484 |
SRCS, url, lno, tooltip(type, lno, filename), name); |
strbuf_puts(outbuf, gen_href_end()); |
485 |
} |
} |
486 |
} |
} |
487 |
} |
} |
496 |
struct data *inc; |
struct data *inc; |
497 |
char *path; |
char *path; |
498 |
{ |
{ |
|
strbuf_puts(outbuf, "<a href='"); |
|
499 |
if (inc->count == 1) |
if (inc->count == 1) |
500 |
strbuf_puts(outbuf, path2url(strbuf_value(inc->contents))); |
strbuf_puts(outbuf, gen_href_begin(NULL, path2fid(strbuf_value(inc->contents)), HTML, NULL)); |
501 |
else |
else { |
502 |
strbuf_sprintf(outbuf, "../%s/%d.%s", INCS, inc->id, HTML); |
char id[32]; |
503 |
strbuf_puts(outbuf, "'>"); |
snprintf(id, sizeof(id), "%d", inc->id); |
504 |
|
strbuf_puts(outbuf, gen_href_begin(upperdir(INCS), id, HTML, NULL)); |
505 |
|
} |
506 |
strbuf_puts(outbuf, path); |
strbuf_puts(outbuf, path); |
507 |
strbuf_puts(outbuf, "</a>"); |
strbuf_puts(outbuf, gen_href_end()); |
508 |
} |
} |
509 |
/* |
/* |
510 |
* Put a reserved word. (if, while, ...) |
* Put a reserved word. (if, while, ...) |
656 |
put_end_of_line(lineno) |
put_end_of_line(lineno) |
657 |
int lineno; |
int lineno; |
658 |
{ |
{ |
659 |
fprintf(out, "<a name='%d'>", lineno); |
fputs(gen_name_number(lineno), out); |
660 |
if (nflag) |
if (nflag) |
661 |
fprintf(out, lineno_format, lineno); |
fprintf(out, lineno_format, lineno); |
662 |
if (warned) |
if (warned) |
725 |
/* |
/* |
726 |
* print the header |
* print the header |
727 |
*/ |
*/ |
728 |
fprintf(out, "<a name='TOP'>%s", header_begin); |
fputs(gen_name_string("TOP"), out); |
729 |
|
fputs(header_begin, out); |
730 |
fputs(fill_anchor(indexlink, src), out); |
fputs(fill_anchor(indexlink, src), out); |
731 |
if (cvsweb_url) { |
if (cvsweb_url) { |
732 |
static STRBUF *sb = NULL; |
static STRBUF *sb = NULL; |
736 |
strbuf_reset(sb); |
strbuf_reset(sb); |
737 |
else |
else |
738 |
sb = strbuf_open(0); |
sb = strbuf_open(0); |
739 |
|
strbuf_puts(sb, cvsweb_url); |
740 |
for (p = src; *p; p++) { |
for (p = src; *p; p++) { |
741 |
int c = (unsigned char)*p; |
int c = (unsigned char)*p; |
742 |
|
|
745 |
else |
else |
746 |
strbuf_sprintf(sb, "%%%02x", c); |
strbuf_sprintf(sb, "%%%02x", c); |
747 |
} |
} |
|
fprintf(out, "%s<a href='%s%s", quote_space, cvsweb_url, strbuf_value(sb)); |
|
748 |
if (cvsweb_cvsroot) |
if (cvsweb_cvsroot) |
749 |
fprintf(out, "?cvsroot=%s", cvsweb_cvsroot); |
strbuf_sprintf(sb, "?cvsroot=%s", cvsweb_cvsroot); |
750 |
fprintf(out, "'>%s[CVS]%s</a>\n", cvslink_begin, cvslink_end); |
fprintf(out, "%s%s", quote_space, gen_href_begin_simple(strbuf_value(sb))); |
751 |
|
fprintf(out, "%s[CVS]%s", cvslink_begin, cvslink_end); |
752 |
|
fprintf(out, "%s\n", gen_href_end()); |
753 |
/* doesn't close string buffer */ |
/* doesn't close string buffer */ |
754 |
} |
} |
755 |
fprintf(out, "%s\n", header_end); |
fprintf(out, "%s\n", header_end); |
770 |
fprintf(out, "%s\n", verbatim_begin); |
fprintf(out, "%s\n", verbatim_begin); |
771 |
last_lineno = 0; |
last_lineno = 0; |
772 |
while ((_ = strbuf_fgets(sb, in, STRBUF_NOCRLF)) != NULL) { |
while ((_ = strbuf_fgets(sb, in, STRBUF_NOCRLF)) != NULL) { |
773 |
fprintf(out, "<a name='%d'>", ++last_lineno); |
fputs(gen_name_number(++last_lineno), out); |
774 |
for (; *_; _++) { |
for (; *_; _++) { |
775 |
int c = *_; |
int c = *_; |
776 |
|
|
807 |
basename = src; |
basename = src; |
808 |
incref = get_included(basename); |
incref = get_included(basename); |
809 |
if (incref) { |
if (incref) { |
810 |
fprintf(out, "%s<a href='", header_begin); |
char s_id[32]; |
811 |
|
char *dir, *file, *suffix, *key, *title; |
812 |
|
|
813 |
|
fputs(header_begin, out); |
814 |
if (incref->count > 1) { |
if (incref->count > 1) { |
815 |
char s_count[32]; |
char s_count[32]; |
816 |
|
|
817 |
snprintf(s_count, sizeof(s_count), "%d", incref->count); |
snprintf(s_count, sizeof(s_count), "%d", incref->count); |
818 |
fprintf(out, "../%s/%d.%s", INCREFS, incref->id, HTML); |
snprintf(s_id, sizeof(s_id), "%d", incref->id); |
819 |
fprintf(out, "' title='%s'>", tooltip('I', -1, s_count)); |
dir = upperdir(INCREFS); |
820 |
|
file = s_id; |
821 |
|
suffix = HTML; |
822 |
|
key = NULL; |
823 |
|
title = tooltip('I', -1, s_count); |
824 |
} else { |
} else { |
|
char *lno, *filename, *save; |
|
825 |
char *p = strbuf_value(incref->contents); |
char *p = strbuf_value(incref->contents); |
826 |
|
char *lno = strmake(p, " "); |
827 |
|
char *filename; |
828 |
|
|
829 |
lno = p; |
p = locatestring(p, " ", MATCH_FIRST); |
830 |
while (*p != ' ') |
if (p == NULL) |
831 |
p++; |
die("internal error.(incref->contents)"); |
832 |
save = p; |
filename = p + 1; |
|
*p++ = '\0'; |
|
|
filename = p; |
|
833 |
if (filename[0] == '.' && filename[1] == '/') |
if (filename[0] == '.' && filename[1] == '/') |
834 |
filename += 2; |
filename += 2; |
835 |
fprintf(out, "%s#%s", path2url(filename), lno); |
dir = NULL; |
836 |
fprintf(out, "' title='%s'>", tooltip('I', atoi(lno), filename)); |
file = path2fid(filename); |
837 |
*save = ' '; |
suffix = HTML; |
838 |
|
key = lno; |
839 |
|
title = tooltip('I', atoi(lno), filename); |
840 |
} |
} |
841 |
fprintf(out, "%s</a>%s\n", title_included_from, header_end); |
fputs(gen_href_begin_with_title(dir, file, suffix, key, title), out); |
842 |
|
fputs(title_included_from, out); |
843 |
|
fputs(gen_href_end(), out); |
844 |
|
fprintf(out, "%s\n", header_end); |
845 |
fprintf(out, "%s\n", hr); |
fprintf(out, "%s\n", hr); |
846 |
} |
} |
847 |
/* |
/* |
853 |
define_index = strbuf_open(0); |
define_index = strbuf_open(0); |
854 |
for (ancref = anchor_first(); ancref; ancref = anchor_next()) { |
for (ancref = anchor_first(); ancref; ancref = anchor_next()) { |
855 |
if (ancref->type == 'D') { |
if (ancref->type == 'D') { |
856 |
strbuf_sprintf(define_index, "%s<a href='#%d' title='%s'>%s</a>%s\n", |
char tmp[32]; |
857 |
item_begin, |
snprintf(tmp, sizeof(tmp), "%d", ancref->lineno); |
858 |
ancref->lineno, |
strbuf_puts(define_index, item_begin); |
859 |
tooltip('R', ancref->lineno, NULL), |
strbuf_puts(define_index, gen_href_begin_with_title(NULL, NULL, NULL, tmp, tooltip('R', ancref->lineno, NULL))); |
860 |
gettag(ancref), |
strbuf_puts(define_index, gettag(ancref)); |
861 |
item_end); |
strbuf_puts(define_index, gen_href_end()); |
862 |
|
strbuf_puts(define_index, item_end); |
863 |
|
strbuf_putc(define_index, '\n'); |
864 |
} |
} |
865 |
} |
} |
866 |
if (strbuf_getlen(define_index) > 0) { |
if (strbuf_getlen(define_index) > 0) { |
867 |
fprintf(out, "%s%s%s\n", header_begin, title_define_index, header_end); |
fputs(header_begin, out); |
868 |
|
fputs(title_define_index, out); |
869 |
|
fprintf(out, "%s\n", header_end); |
870 |
fputs("This source file includes following definitions.\n", out); |
fputs("This source file includes following definitions.\n", out); |
871 |
fprintf(out, "%s\n%s%s\n%s\n", list_begin, strbuf_value(define_index), list_end, hr); |
fprintf(out, "%s\n", list_begin); |
872 |
|
fputs(strbuf_value(define_index), out); |
873 |
|
fprintf(out, "%s\n", list_end); |
874 |
|
fprintf(out, "%s\n", hr); |
875 |
} |
} |
876 |
/* |
/* |
877 |
* print source code |
* print source code |
906 |
fprintf(out, "%s\n", verbatim_end); |
fprintf(out, "%s\n", verbatim_end); |
907 |
} |
} |
908 |
fprintf(out, "%s\n", hr); |
fprintf(out, "%s\n", hr); |
909 |
fputs("<a name='BOTTOM'>\n", out); |
fprintf(out, "%s\n", gen_name_string("BOTTOM")); |
910 |
fprintf(out, "%s/* ", comment_begin); |
fprintf(out, "%s/* ", comment_begin); |
911 |
fputs(link_format(anchor_getlinks(-1)), out); |
fputs(link_format(anchor_getlinks(-1)), out); |
912 |
if (show_position) |
if (show_position) |