63 |
int match(const char *, const char *); |
int match(const char *, const char *); |
64 |
int main(int, char **); |
int main(int, char **); |
65 |
int incremental(const char *, const char *); |
int incremental(const char *, const char *); |
66 |
void updatetags(const char *, const char *, const char *, int); |
void updatetags(const char *, const char *, STRBUF *, STRBUF *, STRBUF *, int); |
67 |
void createtags(const char *, const char *, int); |
void createtags(const char *, const char *, int); |
68 |
int printconf(const char *); |
int printconf(const char *); |
69 |
void set_base_directory(const char *, const char *); |
void set_base_directory(const char *, const char *); |
681 |
STRBUF *deletelist = strbuf_open(0); |
STRBUF *deletelist = strbuf_open(0); |
682 |
int updated = 0; |
int updated = 0; |
683 |
const char *path; |
const char *path; |
684 |
|
const char *end; |
685 |
|
int db; |
686 |
|
|
687 |
if (vflag) { |
if (vflag) { |
688 |
fprintf(stderr, " Tag found in '%s'.\n", dbpath); |
fprintf(stderr, " Tag found in '%s'.\n", dbpath); |
729 |
} |
} |
730 |
} |
} |
731 |
gpath_close(); |
gpath_close(); |
732 |
if (strbuf_getlen(addlist) + strbuf_getlen(deletelist) + strbuf_getlen(updatelist)) |
if (strbuf_getlen(addlist) + strbuf_getlen(deletelist) + strbuf_getlen(updatelist)) { |
|
updated = 1; |
|
|
/* |
|
|
* execute updating. |
|
|
*/ |
|
|
signal_setup(); |
|
|
if (strbuf_getlen(updatelist) > 0) { |
|
|
const char *start = strbuf_value(updatelist); |
|
|
const char *end = start + strbuf_getlen(updatelist); |
|
|
const char *p; |
|
|
|
|
|
for (p = start; p < end; p += strlen(p) + 1) { |
|
|
updatetags(dbpath, root, p, 0); |
|
|
if (exitflag) |
|
|
exit(1); |
|
|
} |
|
|
updated = 1; |
|
|
} |
|
|
if (strbuf_getlen(addlist) > 0) { |
|
|
const char *start = strbuf_value(addlist); |
|
|
const char *end = start + strbuf_getlen(addlist); |
|
|
const char *p; |
|
|
|
|
|
for (p = start; p < end; p += strlen(p) + 1) { |
|
|
updatetags(dbpath, root, p, 1); |
|
|
if (exitflag) |
|
|
exit(1); |
|
|
} |
|
733 |
updated = 1; |
updated = 1; |
734 |
} |
/* |
735 |
if (strbuf_getlen(deletelist) > 0) { |
* execute updating. |
736 |
const char *start = strbuf_value(deletelist); |
*/ |
737 |
const char *end = start + strbuf_getlen(deletelist); |
signal_setup(); |
|
const char *p; |
|
738 |
|
|
739 |
for (p = start; p < end; p += strlen(p) + 1) { |
for (db = GTAGS; db < GTAGLIM; db++) { |
740 |
updatetags(dbpath, root, p, 2); |
/* |
741 |
|
* GTAGS needed at least. |
742 |
|
*/ |
743 |
|
if ((db == GRTAGS || db == GSYMS) |
744 |
|
&& !test("f", makepath(dbpath, dbname(db), NULL))) |
745 |
|
continue; |
746 |
|
if (vflag) |
747 |
|
fprintf(stderr, "[%s] Updating '%s'.\n", now(), dbname(db)); |
748 |
|
updatetags(dbpath, root, addlist, updatelist, deletelist, db); |
749 |
if (exitflag) |
if (exitflag) |
750 |
exit(1); |
exit(1); |
751 |
} |
} |
752 |
|
|
753 |
gpath_open(dbpath, 2, 0); |
gpath_open(dbpath, 2, 0); |
754 |
for (p = start; p < end; p += strlen(p) + 1) { |
path = strbuf_value(deletelist); |
755 |
|
end = path + strbuf_getlen(deletelist); |
756 |
|
while (path < end) { |
757 |
|
gpath_delete(path); |
758 |
if (exitflag) |
if (exitflag) |
759 |
break; |
break; |
760 |
gpath_delete(p); |
path += strlen(path) + 1; |
761 |
} |
} |
762 |
gpath_close(); |
gpath_close(); |
763 |
updated = 1; |
if (exitflag) |
764 |
} |
exit(1); |
765 |
if (exitflag) |
|
|
exit(1); |
|
|
if (updated) { |
|
|
int db; |
|
766 |
/* |
/* |
767 |
* Update modification time of tag files |
* Update modification time of tag files |
768 |
* because they may have no definitions. |
* because they may have no definitions. |
789 |
/* |
/* |
790 |
* updatetags: update tag file. |
* updatetags: update tag file. |
791 |
* |
* |
792 |
* i) dbpath directory in which tag file exist |
* i) dbpath directory in which tag file exist |
793 |
* i) root root directory of source tree |
* i) root root directory of source tree |
794 |
* i) path path which should be updated |
* i) addlist \0 separated list of added files |
795 |
* i) type 0:update, 1:add, 2:delete |
* i) updatelist \0 separated list of modified files |
796 |
|
* i) deletelist \0 separated list of deleted files |
797 |
|
* i) db GTAGS, GRTAGS, GSYMS |
798 |
*/ |
*/ |
799 |
void |
void |
800 |
updatetags(dbpath, root, path, type) |
updatetags(dbpath, root, addlist, updatelist, deletelist, db) |
801 |
const char *dbpath; |
const char *dbpath; |
802 |
const char *root; |
const char *root; |
803 |
const char *path; |
STRBUF *addlist; |
804 |
int type; |
STRBUF *updatelist; |
805 |
|
STRBUF *deletelist; |
806 |
|
int db; |
807 |
{ |
{ |
808 |
GTOP *gtop; |
GTOP *gtop; |
809 |
|
const char *path; |
810 |
|
const char *comline; |
811 |
|
const char *end1, *end2; |
812 |
STRBUF *sb = strbuf_open(0); |
STRBUF *sb = strbuf_open(0); |
813 |
int db; |
int gflags; |
|
const char *msg = NULL; |
|
814 |
|
|
815 |
switch (type) { |
/* |
816 |
case 0: msg = "Updating"; break; |
* GTAGS needed to make GRTAGS. |
817 |
case 1: msg = "Adding"; break; |
*/ |
818 |
case 2: msg = "Deleting"; break; |
if (db == GRTAGS && !test("f", makepath(dbpath, dbname(GTAGS), NULL))) |
819 |
} |
die("GTAGS needed to create GRTAGS."); |
|
if (vflag) |
|
|
fprintf(stderr, " %s tags of %s ...", msg, path + 2); |
|
|
for (db = GTAGS; db < GTAGLIM; db++) { |
|
|
int gflags = 0; |
|
820 |
|
|
821 |
if (exitflag) |
/* |
822 |
|
* get tag command. |
823 |
|
*/ |
824 |
|
if (!getconfs(dbname(db), sb)) |
825 |
|
die("cannot get tag command. (%s)", dbname(db)); |
826 |
|
comline = strbuf_value(sb); |
827 |
|
|
828 |
|
gtop = gtags_open(dbpath, root, db, GTAGS_MODIFY, 0); |
829 |
|
|
830 |
|
path = strbuf_value(deletelist); |
831 |
|
end1 = path + strbuf_getlen(deletelist); |
832 |
|
end2 = strbuf_value(updatelist) + strbuf_getlen(updatelist); |
833 |
|
for (;;) { |
834 |
|
if (path == end1) |
835 |
|
path = strbuf_value(updatelist); |
836 |
|
if (path == end2) |
837 |
break; |
break; |
|
/* |
|
|
* GTAGS needed at least. |
|
|
*/ |
|
|
if ((db == GRTAGS || db == GSYMS) && !test("f", makepath(dbpath, dbname(db), NULL))) |
|
|
continue; |
|
|
/* |
|
|
* GTAGS needed to make GRTAGS. |
|
|
*/ |
|
|
if (db == GRTAGS && !test("f", makepath(dbpath, dbname(GTAGS), NULL))) |
|
|
die("GTAGS needed to create GRTAGS."); |
|
838 |
if (vflag) |
if (vflag) |
839 |
fprintf(stderr, "%s", dbname(db)); |
fprintf(stderr, " deleting tags of %s\n", path); |
840 |
/* |
gtags_delete(gtop, path); |
841 |
* get tag command. |
if (exitflag) |
842 |
*/ |
break; |
843 |
strbuf_reset(sb); |
path += strlen(path) + 1; |
844 |
if (!getconfs(dbname(db), sb)) |
} |
845 |
die("cannot get tag command. (%s)", dbname(db)); |
|
846 |
gtop = gtags_open(dbpath, root, db, GTAGS_MODIFY, 0); |
gflags = 0; |
847 |
if (type != 1) |
if (extractmethod) |
848 |
gtags_delete(gtop, path); |
gflags |= GTAGS_EXTRACTMETHOD; |
849 |
|
if (debug) |
850 |
|
gflags |= GTAGS_DEBUG; |
851 |
|
path = strbuf_value(addlist); |
852 |
|
end1 = path + strbuf_getlen(addlist); |
853 |
|
end2 = strbuf_value(updatelist) + strbuf_getlen(updatelist); |
854 |
|
for (;;) { |
855 |
|
if (path == end1) |
856 |
|
path = strbuf_value(updatelist); |
857 |
|
if (path == end2) |
858 |
|
break; |
859 |
if (vflag) |
if (vflag) |
860 |
fprintf(stderr, ".."); |
fprintf(stderr, " adding tags of %s\n", path); |
861 |
if (type != 2) { |
gtags_add(gtop, comline, path, gflags); |
862 |
if (extractmethod) |
if (exitflag) |
863 |
gflags |= GTAGS_EXTRACTMETHOD; |
break; |
864 |
if (debug) |
path += strlen(path) + 1; |
|
gflags |= GTAGS_DEBUG; |
|
|
gtags_add(gtop, strbuf_value(sb), path, gflags); |
|
|
} |
|
|
gtags_close(gtop); |
|
865 |
} |
} |
866 |
|
|
867 |
|
gtags_close(gtop); |
868 |
strbuf_close(sb); |
strbuf_close(sb); |
|
if (exitflag) |
|
|
return; |
|
|
if (vflag) |
|
|
fprintf(stderr, " Done.\n"); |
|
869 |
} |
} |
870 |
/* |
/* |
871 |
* createtags: create tags file |
* createtags: create tags file |