798 |
int db; |
int db; |
799 |
{ |
{ |
800 |
GTOP *gtop; |
GTOP *gtop; |
801 |
const char *comline; |
STRBUF *comline = strbuf_open(0); |
|
const char *end; |
|
|
STRBUF *sb = strbuf_open(0); |
|
802 |
int gflags; |
int gflags; |
|
STATIC_STRBUF(path_list); |
|
803 |
int path_list_max; |
int path_list_max; |
|
int savec; |
|
|
int pathlen; |
|
804 |
|
|
805 |
/* |
/* |
806 |
* GTAGS needed to make GRTAGS. |
* GTAGS needed to make GRTAGS. |
811 |
/* |
/* |
812 |
* get tag command. |
* get tag command. |
813 |
*/ |
*/ |
814 |
if (!getconfs(dbname(db), sb)) |
if (!getconfs(dbname(db), comline)) |
815 |
die("cannot get tag command. (%s)", dbname(db)); |
die("cannot get tag command. (%s)", dbname(db)); |
|
comline = strbuf_value(sb); |
|
|
|
|
816 |
/* |
/* |
817 |
* determine the maximum length of the list of paths. |
* determine the maximum length of the list of paths. |
818 |
*/ |
*/ |
826 |
if (path_list_max > 20 * 1024) |
if (path_list_max > 20 * 1024) |
827 |
path_list_max = 20 * 1024; |
path_list_max = 20 * 1024; |
828 |
path_list_max -= env_size(); |
path_list_max -= env_size(); |
829 |
path_list_max -= strbuf_getlen(sb); |
path_list_max -= strbuf_getlen(comline); |
830 |
path_list_max -= 40; |
path_list_max -= 40; |
831 |
if (path_list_max < 0) |
if (path_list_max < 0) |
832 |
path_list_max = 0; |
path_list_max = 0; |
834 |
#else |
#else |
835 |
path_list_max = 0; |
path_list_max = 0; |
836 |
#endif |
#endif |
|
|
|
837 |
gtop = gtags_open(dbpath, root, db, GTAGS_MODIFY, 0); |
gtop = gtags_open(dbpath, root, db, GTAGS_MODIFY, 0); |
|
|
|
838 |
if (vflag) { |
if (vflag) { |
839 |
char fid[32]; |
char fid[32]; |
840 |
const char *path; |
const char *path; |
852 |
} |
} |
853 |
if (deleteset->max > 0) |
if (deleteset->max > 0) |
854 |
gtags_delete(gtop, deleteset); |
gtags_delete(gtop, deleteset); |
|
|
|
855 |
gflags = 0; |
gflags = 0; |
856 |
if (extractmethod) |
if (extractmethod) |
857 |
gflags |= GTAGS_EXTRACTMETHOD; |
gflags |= GTAGS_EXTRACTMETHOD; |
858 |
if (debug) |
if (debug) |
859 |
gflags |= GTAGS_DEBUG; |
gflags |= GTAGS_DEBUG; |
860 |
path_list->sbuf = path_list->curp = strbuf_value(addlist); |
/* |
861 |
end = path_list->curp + strbuf_getlen(addlist); |
* If the --noxargs option is not specified, we pass the parser |
862 |
while (path_list->curp < end) { |
* the source file as a lot as possible to decrease the invoking |
863 |
if (vflag) |
* frequency of the parser. |
864 |
fprintf(stderr, " adding tags of %s\n", path_list->curp + 2); |
*/ |
865 |
pathlen = strlen(path_list->curp); |
{ |
866 |
if (strbuf_getlen(path_list) |
STRBUF *path_list = strbuf_open(0); |
867 |
&& strbuf_getlen(path_list) + pathlen > path_list_max) { |
const char *path = strbuf_value(addlist); |
868 |
savec = *path_list->curp; |
const char *end = path + strbuf_getlen(addlist); |
869 |
gtags_add(gtop, comline, path_list, gflags); |
|
870 |
*path_list->curp = savec; |
while (path < end) { |
871 |
path_list->sbuf = path_list->curp; |
int pathlen = strlen(path); |
872 |
|
|
873 |
|
if (vflag) |
874 |
|
fprintf(stderr, " adding tags of %s\n", path + 2); |
875 |
|
/* |
876 |
|
* Execute parser when path name collects enough. |
877 |
|
* Though the path_list is \0 separated list of path, |
878 |
|
* we can think its length equals to the length of |
879 |
|
* argument string because each \0 can be replaced |
880 |
|
* with a blank. |
881 |
|
*/ |
882 |
|
if (strbuf_getlen(path_list)) { |
883 |
|
if (path_list_max == 0 || strbuf_getlen(path_list) + pathlen > path_list_max) { |
884 |
|
gtags_add(gtop, strbuf_value(comline), path_list, gflags); |
885 |
|
strbuf_reset(path_list); |
886 |
|
} |
887 |
|
} |
888 |
|
if (exitflag) |
889 |
|
break; |
890 |
|
/* |
891 |
|
* Add a path to the path list. |
892 |
|
*/ |
893 |
|
strbuf_puts0(path_list, path); |
894 |
|
path += pathlen + 1; |
895 |
} |
} |
896 |
if (exitflag) |
if (strbuf_getlen(path_list)) |
897 |
break; |
gtags_add(gtop, strbuf_value(comline), path_list, gflags); |
898 |
path_list->curp += pathlen + 1; |
strbuf_close(path_list); |
899 |
} |
} |
|
if (strbuf_getlen(path_list)) |
|
|
gtags_add(gtop, comline, path_list, gflags); |
|
900 |
|
|
901 |
gtags_close(gtop); |
gtags_close(gtop); |
902 |
strbuf_close(sb); |
strbuf_close(comline); |
903 |
} |
} |
904 |
/* |
/* |
905 |
* createtags: create tags file |
* createtags: create tags file |
917 |
const char *path; |
const char *path; |
918 |
GTOP *gtop; |
GTOP *gtop; |
919 |
int flags, gflags; |
int flags, gflags; |
920 |
const char *comline; |
STRBUF *comline = strbuf_open(0); |
|
STRBUF *sb = strbuf_open(0); |
|
921 |
int count = 0; |
int count = 0; |
922 |
STRBUF *path_list = strbuf_open(MAXPATHLEN); |
STRBUF *path_list = strbuf_open(MAXPATHLEN); |
923 |
int path_list_max; |
int path_list_max; |
925 |
/* |
/* |
926 |
* get tag command. |
* get tag command. |
927 |
*/ |
*/ |
928 |
if (!getconfs(dbname(db), sb)) |
if (!getconfs(dbname(db), comline)) |
929 |
die("cannot get tag command. (%s)", dbname(db)); |
die("cannot get tag command. (%s)", dbname(db)); |
|
comline = strbuf_value(sb); |
|
930 |
/* |
/* |
931 |
* GTAGS needed to make GRTAGS. |
* GTAGS needed to make GRTAGS. |
932 |
*/ |
*/ |
946 |
if (path_list_max > 20 * 1024) |
if (path_list_max > 20 * 1024) |
947 |
path_list_max = 20 * 1024; |
path_list_max = 20 * 1024; |
948 |
path_list_max -= env_size(); |
path_list_max -= env_size(); |
949 |
path_list_max -= strbuf_getlen(sb); |
path_list_max -= strbuf_getlen(comline); |
950 |
path_list_max -= 40; |
path_list_max -= 40; |
951 |
if (path_list_max < 0) |
if (path_list_max < 0) |
952 |
path_list_max = 0; |
path_list_max = 0; |
970 |
flags |= GTAGS_COMPACT; |
flags |= GTAGS_COMPACT; |
971 |
} |
} |
972 |
if (vflag > 1) |
if (vflag > 1) |
973 |
fprintf(stderr, " using tag command '%s <path>'.\n", comline); |
fprintf(stderr, " using tag command '%s <path>'.\n", strbuf_value(comline)); |
974 |
gtop = gtags_open(dbpath, root, db, GTAGS_CREATE, flags); |
gtop = gtags_open(dbpath, root, db, GTAGS_CREATE, flags); |
975 |
gflags = 0; |
gflags = 0; |
976 |
if (extractmethod) |
if (extractmethod) |
977 |
gflags |= GTAGS_EXTRACTMETHOD; |
gflags |= GTAGS_EXTRACTMETHOD; |
978 |
if (debug) |
if (debug) |
979 |
gflags |= GTAGS_DEBUG; |
gflags |= GTAGS_DEBUG; |
980 |
|
/* |
981 |
|
* If the --noxargs option is not specified, we pass the parser |
982 |
|
* the source file as a lot as possible to decrease the invoking |
983 |
|
* frequency of the parser. |
984 |
|
*/ |
985 |
for (find_open(NULL); (path = find_read()) != NULL; ) { |
for (find_open(NULL); (path = find_read()) != NULL; ) { |
986 |
int skip = 0; |
int skip = 0; |
987 |
|
|
1011 |
} |
} |
1012 |
if (skip) |
if (skip) |
1013 |
continue; |
continue; |
1014 |
if (strbuf_getlen(path_list) |
/* |
1015 |
&& strbuf_getlen(path_list) + strlen(path) > path_list_max) { |
* Execute parser when path name collects enough. |
1016 |
gtags_add(gtop, comline, path_list, gflags); |
* Though the path_list is \0 separated list of string, |
1017 |
strbuf_reset(path_list); |
* we can think its length equals to the length of |
1018 |
|
* argument string because each \0 can be replaced |
1019 |
|
* with a blank. |
1020 |
|
*/ |
1021 |
|
if (strbuf_getlen(path_list)) { |
1022 |
|
if (path_list_max == 0 || strbuf_getlen(path_list) + strlen(path) > path_list_max) { |
1023 |
|
gtags_add(gtop, strbuf_value(comline), path_list, gflags); |
1024 |
|
strbuf_reset(path_list); |
1025 |
|
} |
1026 |
} |
} |
1027 |
|
/* |
1028 |
|
* Add a path to path_list. |
1029 |
|
*/ |
1030 |
strbuf_puts0(path_list, path); |
strbuf_puts0(path_list, path); |
1031 |
} |
} |
1032 |
if (strbuf_getlen(path_list)) |
if (strbuf_getlen(path_list)) |
1033 |
gtags_add(gtop, comline, path_list, gflags); |
gtags_add(gtop, strbuf_value(comline), path_list, gflags); |
1034 |
total = count; /* save total count */ |
total = count; /* save total count */ |
1035 |
find_close(); |
find_close(); |
1036 |
gtags_close(gtop); |
gtags_close(gtop); |
1037 |
strbuf_close(sb); |
strbuf_close(comline); |
1038 |
strbuf_close(path_list); |
strbuf_close(path_list); |
1039 |
} |
} |
1040 |
/* |
/* |