221 |
{ |
{ |
222 |
char *start = sp->start; |
char *start = sp->start; |
223 |
char *last = sp->last - 1; |
char *last = sp->last - 1; |
224 |
char *p; |
const char *p; |
225 |
|
|
226 |
fprintf(stderr, "%s(%s): ", label, sp->name); |
fprintf(stderr, "%s(%s): ", label, sp->name); |
227 |
for (p = sp->buf; p < last; p++) { |
for (p = sp->buf; p < last; p++) { |
331 |
* i) sp stack descriptor |
* i) sp stack descriptor |
332 |
* r) string |
* r) string |
333 |
*/ |
*/ |
334 |
static char * |
static const char * |
335 |
top_stack(sp) |
top_stack(sp) |
336 |
struct dirstack *sp; |
struct dirstack *sp; |
337 |
{ |
{ |
360 |
* i) cur current value |
* i) cur current value |
361 |
* r) string |
* r) string |
362 |
*/ |
*/ |
363 |
static char * |
static const char * |
364 |
next_stack(sp, cur) |
next_stack(sp, cur) |
365 |
struct dirstack *sp; |
struct dirstack *sp; |
366 |
char *cur; |
const char *cur; |
367 |
{ |
{ |
368 |
char *last = sp->last; |
char *last = sp->last; |
369 |
|
|
382 |
* i) sp stack descriptor |
* i) sp stack descriptor |
383 |
* r) string |
* r) string |
384 |
*/ |
*/ |
385 |
static char * |
static const char * |
386 |
pop_stack(sp) |
pop_stack(sp) |
387 |
struct dirstack *sp; |
struct dirstack *sp; |
388 |
{ |
{ |
389 |
char *last = top_stack(sp); |
char *last = (char *)top_stack(sp); |
390 |
int length = strlen(last) + 1; |
int length = strlen(last) + 1; |
391 |
|
|
392 |
if (!last) |
if (!last) |
404 |
* i) sp stack descriptor |
* i) sp stack descriptor |
405 |
* r) string |
* r) string |
406 |
*/ |
*/ |
407 |
static char * |
static const char * |
408 |
shift_stack(sp) |
shift_stack(sp) |
409 |
struct dirstack *sp; |
struct dirstack *sp; |
410 |
{ |
{ |
454 |
* i) sp stack descriptor |
* i) sp stack descriptor |
455 |
* r) path name |
* r) path name |
456 |
*/ |
*/ |
457 |
static char * |
static const char * |
458 |
join_stack(sp) |
join_stack(sp) |
459 |
struct dirstack *sp; |
struct dirstack *sp; |
460 |
{ |
{ |
489 |
* i) url URL |
* i) url URL |
490 |
* r) encoded URL |
* r) encoded URL |
491 |
*/ |
*/ |
492 |
static char * |
static const char * |
493 |
encode(url) |
encode(url) |
494 |
const char *url; |
const char *url; |
495 |
{ |
{ |
515 |
* i) is_php 1: is PHP source |
* i) is_php 1: is PHP source |
516 |
* r) last name |
* r) last name |
517 |
*/ |
*/ |
518 |
static char * |
static const char * |
519 |
extract_lastname(image, is_php) |
extract_lastname(image, is_php) |
520 |
const char *image; |
const char *image; |
521 |
int is_php; |
int is_php; |
611 |
FILE *FIND, *FILEMAP, *FILES, *STDOUT, *op = NULL; |
FILE *FIND, *FILEMAP, *FILES, *STDOUT, *op = NULL; |
612 |
char *_; |
char *_; |
613 |
int count = 0; |
int count = 0; |
614 |
char *indexlink = (Fflag) ? "../files" : "../mains"; |
const char *indexlink = (Fflag) ? "../files" : "../mains"; |
615 |
STRBUF *sb = strbuf_open(0); |
STRBUF *sb = strbuf_open(0); |
616 |
STRBUF *input = strbuf_open(0); |
STRBUF *input = strbuf_open(0); |
617 |
char *target = (Fflag) ? "mains" : "_top"; |
const char *target = (Fflag) ? "mains" : "_top"; |
618 |
struct dirstack *dirstack = make_stack("dirstack"); |
struct dirstack *dirstack = make_stack("dirstack"); |
619 |
struct dirstack *fdstack = make_stack("fdstack"); |
struct dirstack *fdstack = make_stack("fdstack"); |
620 |
char *command = (other_files) ? "gtags --find --other | gnusort -t / -k 2" |
const char *command = (other_files) ? "gtags --find --other | gnusort -t / -k 2" |
621 |
: "gtags --find"; |
: "gtags --find"; |
622 |
struct dirstack *push = make_stack("push"); |
struct dirstack *push = make_stack("push"); |
623 |
struct dirstack *pop = make_stack("pop"); |
struct dirstack *pop = make_stack("pop"); |
632 |
strbuf_reset(sb); |
strbuf_reset(sb); |
633 |
strbuf_puts(sb, "\\.("); |
strbuf_puts(sb, "\\.("); |
634 |
{ |
{ |
635 |
char *p = include_file_suffixes; |
const char *p = include_file_suffixes; |
636 |
int c; |
int c; |
637 |
|
|
638 |
while ((c = (unsigned char)*p++) != '\0') { |
while ((c = (unsigned char)*p++) != '\0') { |
695 |
(void)shift_stack(pop); |
(void)shift_stack(pop); |
696 |
} |
} |
697 |
if (count_stack(push) || count_stack(pop)) { |
if (count_stack(push) || count_stack(pop)) { |
698 |
char *parent, *path, *suffix; |
const char *parent, *path, *suffix; |
699 |
|
|
700 |
while (count_stack(pop)) { |
while (count_stack(pop)) { |
701 |
(void)pop_stack(dirstack); |
(void)pop_stack(dirstack); |
727 |
} |
} |
728 |
while (count_stack(push)) { |
while (count_stack(push)) { |
729 |
char cur[MAXPATHLEN], tmp[MAXPATHLEN]; |
char cur[MAXPATHLEN], tmp[MAXPATHLEN]; |
730 |
char *last; |
const char *last; |
731 |
if (count_stack(dirstack)) { |
if (count_stack(dirstack)) { |
732 |
parent = path2fid(join_stack(dirstack)); |
parent = path2fid(join_stack(dirstack)); |
733 |
suffix = HTML; |
suffix = HTML; |
770 |
fprintf(STDOUT, "%s%sroot%s/", header_begin, gen_href_begin(NULL, indexlink, normal_suffix, NULL), gen_href_end()); |
fprintf(STDOUT, "%s%sroot%s/", header_begin, gen_href_begin(NULL, indexlink, normal_suffix, NULL), gen_href_end()); |
771 |
{ |
{ |
772 |
struct dirstack *p = make_stack("tmp"); |
struct dirstack *p = make_stack("tmp"); |
773 |
char *s; |
const char *s; |
774 |
int anchor; |
int anchor; |
775 |
|
|
776 |
for (s = bottom_stack(dirstack); s; s = next_stack(dirstack, s)) { |
for (s = bottom_stack(dirstack); s; s = next_stack(dirstack, s)) { |
813 |
strbuf_puts(sb, item_begin); |
strbuf_puts(sb, item_begin); |
814 |
|
|
815 |
{ |
{ |
816 |
char tmp[1024], *file, *suffix = NULL, *dir = NULL; |
char tmp[1024]; |
817 |
|
const char *file, *suffix = NULL, *dir = NULL; |
818 |
|
|
819 |
if (notsource && dynamic) { |
if (notsource && dynamic) { |
820 |
if (!(*action == '/' || count_stack(dirstack) == 0)) |
if (!(*action == '/' || count_stack(dirstack) == 0)) |
845 |
if (full_path) { |
if (full_path) { |
846 |
strbuf_puts(sb, _); |
strbuf_puts(sb, _); |
847 |
} else { |
} else { |
848 |
char *last = locatestring(_, "/", MATCH_LAST); |
const char *last = locatestring(_, "/", MATCH_LAST); |
849 |
if (last) |
if (last) |
850 |
last++; |
last++; |
851 |
else |
else |
870 |
if (pclose(FIND) != 0) |
if (pclose(FIND) != 0) |
871 |
die("cannot traverse directory.(%s)", command); |
die("cannot traverse directory.(%s)", command); |
872 |
while (count_stack(dirstack) > 0) { |
while (count_stack(dirstack) > 0) { |
873 |
char *parent, *suffix; |
const char *parent, *suffix; |
874 |
|
|
875 |
pop_stack(dirstack); |
pop_stack(dirstack); |
876 |
if (count_stack(dirstack) > 0) { |
if (count_stack(dirstack) > 0) { |
921 |
{ |
{ |
922 |
FILE *PIPE; |
FILE *PIPE; |
923 |
STRBUF *input = strbuf_open(0); |
STRBUF *input = strbuf_open(0); |
|
char *command; |
|
924 |
char *_; |
char *_; |
925 |
struct data *inc; |
struct data *inc; |
926 |
char *target = (Fflag) ? "mains" : "_top"; |
char *target = (Fflag) ? "mains" : "_top"; |
927 |
|
const char *command = "global -gnx \"^[ \\t]*(#[ \\t]*(import|include)|include[ \\t]*\\()\""; |
928 |
|
|
929 |
/* |
/* |
930 |
* Pick up include pattern. |
* Pick up include pattern. |
932 |
* C: #include "xxx.h" |
* C: #include "xxx.h" |
933 |
* PHP: include("xxx.inc.php"); |
* PHP: include("xxx.inc.php"); |
934 |
*/ |
*/ |
|
command = "global -gnx \"^[ \\t]*(#[ \\t]*(import|include)|include[ \\t]*\\()\""; |
|
935 |
if ((PIPE = popen(command, "r")) == NULL) |
if ((PIPE = popen(command, "r")) == NULL) |
936 |
die("cannot fork."); |
die("cannot fork."); |
937 |
strbuf_reset(input); |
strbuf_reset(input); |
938 |
while ((_ = strbuf_fgets(input, PIPE, STRBUF_NOCRLF)) != NULL) { |
while ((_ = strbuf_fgets(input, PIPE, STRBUF_NOCRLF)) != NULL) { |
939 |
SPLIT ptable; |
SPLIT ptable; |
940 |
char *last, buf[MAXBUFLEN]; |
char buf[MAXBUFLEN]; |
941 |
int is_php = 0; |
int is_php = 0; |
942 |
const char *lang, *suffix; |
const char *last, *lang, *suffix; |
943 |
|
|
944 |
if (split(_, 4, &ptable) < 4) { |
if (split(_, 4, &ptable) < 4) { |
945 |
recover(&ptable); |
recover(&ptable); |
957 |
* s/^[^ \t]+/$last/; |
* s/^[^ \t]+/$last/; |
958 |
*/ |
*/ |
959 |
{ |
{ |
960 |
char *p, *q = buf; |
const char *p; |
961 |
|
char *q = buf; |
962 |
|
|
963 |
for (p = last; *p; p++) |
for (p = last; *p; p++) |
964 |
*q++ = *p; |
*q++ = *p; |
974 |
die("terminated abnormally."); |
die("terminated abnormally."); |
975 |
|
|
976 |
for (inc = first_inc(); inc; inc = next_inc()) { |
for (inc = first_inc(); inc; inc = next_inc()) { |
977 |
char *last = inc->name; |
const char *last = inc->name; |
978 |
int no = inc->id; |
int no = inc->id; |
979 |
struct data *data; |
struct data *data; |
980 |
FILE *INCLUDE; |
FILE *INCLUDE; |
988 |
fputs_nl(body_begin, INCLUDE); |
fputs_nl(body_begin, INCLUDE); |
989 |
fputs_nl(verbatim_begin, INCLUDE); |
fputs_nl(verbatim_begin, INCLUDE); |
990 |
{ |
{ |
991 |
char *filename = strbuf_value(inc->contents); |
const char *filename = strbuf_value(inc->contents); |
992 |
int count = inc->count; |
int count = inc->count; |
993 |
|
|
994 |
for (; count; filename += strlen(filename) + 1, count--) { |
for (; count; filename += strlen(filename) + 1, count--) { |
1032 |
fputs_nl(body_begin, INCLUDE); |
fputs_nl(body_begin, INCLUDE); |
1033 |
fputs_nl(gen_list_begin(), INCLUDE); |
fputs_nl(gen_list_begin(), INCLUDE); |
1034 |
{ |
{ |
1035 |
char *line = strbuf_value(data->contents); |
const char *line = strbuf_value(data->contents); |
1036 |
int count = data->count; |
int count = data->count; |
1037 |
|
|
1038 |
for (; count; line += strlen(line) + 1, count--) |
for (; count; line += strlen(line) + 1, count--) |