43 |
#include "getopt.h" |
#include "getopt.h" |
44 |
#include "regex.h" |
#include "regex.h" |
45 |
#include "global.h" |
#include "global.h" |
46 |
|
#include "anchor.h" |
47 |
#include "cache.h" |
#include "cache.h" |
48 |
#include "common.h" |
#include "common.h" |
49 |
#include "htags.h" |
#include "htags.h" |
755 |
fclose(op); |
fclose(op); |
756 |
} |
} |
757 |
/* |
/* |
758 |
|
* Wrapper of src2html() |
759 |
|
*/ |
760 |
|
static int |
761 |
|
do_src2html(path_list, count, total) |
762 |
|
STRBUF *path_list; |
763 |
|
int count; |
764 |
|
int total; |
765 |
|
{ |
766 |
|
int notsource; |
767 |
|
char path[MAXPATHLEN]; |
768 |
|
const char *_ = strbuf_value(path_list); |
769 |
|
const char *end = _ + strbuf_getlen(path_list); |
770 |
|
const char *p; |
771 |
|
|
772 |
|
while (_ < end) { |
773 |
|
notsource = *_++; |
774 |
|
count++; |
775 |
|
message(" [%d/%d] converting %s", count, total, _); |
776 |
|
p = path2fid(_); |
777 |
|
snprintf(path, sizeof(path), "%s/%s/%s.%s", distpath, SRCS, p, HTML); |
778 |
|
src2html(_, path, notsource); |
779 |
|
_ += strlen(_) + 1; |
780 |
|
} |
781 |
|
return count; |
782 |
|
} |
783 |
|
/* |
784 |
* makehtml: make html files |
* makehtml: make html files |
785 |
* |
* |
786 |
* i) total number of files. |
* i) total number of files. |
792 |
FILE *ip; |
FILE *ip; |
793 |
const char *_; |
const char *_; |
794 |
int count = 0; |
int count = 0; |
795 |
char command[MAXFILLEN], path[MAXPATHLEN]; |
char command[MAXFILLEN]; |
796 |
STRBUF *sb = strbuf_open(0); |
STRBUF *sb = strbuf_open(0); |
797 |
|
STRBUF *alllist = strbuf_open(0); |
798 |
|
STRBUF *srclist = strbuf_open(0); |
799 |
|
int path_list_max = anchor_pathlist_limit(); |
800 |
|
|
801 |
if (other_files && !dynamic) |
if (other_files && !dynamic) |
802 |
snprintf(command, sizeof(command), "%s --other | gnusort -t / -k 2", findcom); |
snprintf(command, sizeof(command), "%s --other | gnusort -t / -k 2", findcom); |
807 |
die("cannot execute command '%s'.", command); |
die("cannot execute command '%s'.", command); |
808 |
while ((_ = strbuf_fgets(sb, ip, STRBUF_NOCRLF)) != NULL) { |
while ((_ = strbuf_fgets(sb, ip, STRBUF_NOCRLF)) != NULL) { |
809 |
int notsource = 0; |
int notsource = 0; |
|
const char *p; |
|
810 |
|
|
811 |
if (*_ == ' ') { |
if (*_ == ' ') { |
812 |
if (!other_files) |
if (!other_files) |
818 |
continue; |
continue; |
819 |
} |
} |
820 |
notsource = 1; |
notsource = 1; |
821 |
|
} else { |
822 |
|
/* |
823 |
|
* Execute parser when path name collects enough. |
824 |
|
* Though the path_list is \0 separated list of string, |
825 |
|
* we can think its length equals to the length of |
826 |
|
* argument string because each \0 can be replaced |
827 |
|
* with a blank. |
828 |
|
*/ |
829 |
|
if (strbuf_getlen(srclist)) { |
830 |
|
if (strbuf_getlen(srclist) + strlen(_) > path_list_max) { |
831 |
|
anchor_prepare(srclist); |
832 |
|
count = do_src2html(alllist, count, total); |
833 |
|
strbuf_reset(srclist); |
834 |
|
strbuf_reset(alllist); |
835 |
|
} |
836 |
|
} |
837 |
|
/* |
838 |
|
* Add a path to the path list. |
839 |
|
*/ |
840 |
|
strbuf_puts0(srclist, _); |
841 |
} |
} |
842 |
count++; |
strbuf_putc(alllist, notsource); |
843 |
_ += 2; |
strbuf_puts0(alllist, _ + 2); |
844 |
p = _; |
} |
845 |
message(" [%d/%d] converting %s", count, total, p); |
if (strbuf_getlen(alllist)) { |
846 |
p = path2fid(p); |
if (strbuf_getlen(srclist)) |
847 |
snprintf(path, sizeof(path), "%s/%s/%s.%s", distpath, SRCS, p, HTML); |
anchor_prepare(srclist); |
848 |
src2html(_, path, notsource); |
do_src2html(alllist, count, total); |
849 |
} |
} |
850 |
if (pclose(ip) != 0) |
if (pclose(ip) != 0) |
851 |
die("cannot traverse directory.(%s)", command); |
die("cannot traverse directory.(%s)", command); |
852 |
strbuf_close(sb); |
strbuf_close(sb); |
853 |
|
strbuf_close(alllist); |
854 |
|
strbuf_close(srclist); |
855 |
} |
} |
856 |
/* |
/* |
857 |
* copy file. |
* copy file. |