/[global]/global/gtags/gtags.c
ViewVC logotype

Diff of /global/gtags/gtags.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.163 by shigio, Wed Nov 9 03:47:31 2005 UTC revision 1.164 by shigio, Thu Nov 10 01:03:20 2005 UTC
# Line 560  incremental(const char *dbpath, const ch Line 560  incremental(const char *dbpath, const ch
560          STRBUF *addlist = strbuf_open(0);          STRBUF *addlist = strbuf_open(0);
561          STRBUF *deletelist = strbuf_open(0);          STRBUF *deletelist = strbuf_open(0);
562          STRBUF *addlist_other = strbuf_open(0);          STRBUF *addlist_other = strbuf_open(0);
563          IDSET *deleteset;          IDSET *deleteset, *findset;
564          int updated = 0;          int updated = 0;
565          const char *path;          const char *path;
566          int i, limit;          int i, limit;
# Line 579  incremental(const char *dbpath, const ch Line 579  incremental(const char *dbpath, const ch
579    
580          if (gpath_open(dbpath, 0) < 0)          if (gpath_open(dbpath, 0) < 0)
581                  die("GPATH not found.");                  die("GPATH not found.");
582            /*
583             * deleteset:
584             *      The list of the path name which should be deleted from GPATH.
585             * findset:
586             *      The list of the path name which exists in the current project.
587             *      A project is limited by the --file option.
588             */
589          deleteset = idset_open(gpath_nextkey());          deleteset = idset_open(gpath_nextkey());
590            findset = idset_open(gpath_nextkey());
591          /*          /*
592           * make add list and update list.           * make add list and delete list for update.
593           */           */
594          if (file_list)          if (file_list)
595                  find_open_filelist(file_list, root);                  find_open_filelist(file_list, root);
# Line 590  incremental(const char *dbpath, const ch Line 598  incremental(const char *dbpath, const ch
598          total = 0;          total = 0;
599          while ((path = find_read()) != NULL) {          while ((path = find_read()) != NULL) {
600                  const char *fid;                  const char *fid;
601                    int n_fid = 0;
602                  int other = 0;                  int other = 0;
603    
604                  /* a blank at the head of path means 'NOT SOURCE'. */                  /* a blank at the head of path means 'NOT SOURCE'. */
# Line 601  incremental(const char *dbpath, const ch Line 610  incremental(const char *dbpath, const ch
610                  if (stat(path, &statp) < 0)                  if (stat(path, &statp) < 0)
611                          die("stat failed '%s'.", path);                          die("stat failed '%s'.", path);
612                  fid = gpath_path2fid(path, NULL);                  fid = gpath_path2fid(path, NULL);
613                    if (fid) {
614                            n_fid = atoi(fid);
615                            idset_add(findset, n_fid);
616                    }
617                  if (other) {                  if (other) {
618                          if (fid == NULL)                          if (fid == NULL)
619                                  strbuf_puts0(addlist_other, path);                                  strbuf_puts0(addlist_other, path);
# Line 611  incremental(const char *dbpath, const ch Line 624  incremental(const char *dbpath, const ch
624                          } else if (gtags_mtime < statp.st_mtime) {                          } else if (gtags_mtime < statp.st_mtime) {
625                                  strbuf_puts0(addlist, path);                                  strbuf_puts0(addlist, path);
626                                  total++;                                  total++;
627                                  idset_add(deleteset, atoi(fid));                                  idset_add(deleteset, n_fid);
628                          }                          }
629                  }                  }
630          }          }
# Line 625  incremental(const char *dbpath, const ch Line 638  incremental(const char *dbpath, const ch
638                  int other;                  int other;
639    
640                  snprintf(fid, sizeof(fid), "%d", i);                  snprintf(fid, sizeof(fid), "%d", i);
641                    /*
642                     * This is a hole of GPATH. The hole increases if the deletion
643                     * and the addition are repeated.
644                     */
645                  if ((path = gpath_fid2path(fid, &other)) == NULL)                  if ((path = gpath_fid2path(fid, &other)) == NULL)
646                          continue;                          continue;
647                    /*
648                     * The file which does not exist in the findset is treated
649                     * assuming that it does not exist in the file system.
650                     */
651                  if (other) {                  if (other) {
652                          if (!test("f", path) || test("b", path))                          if (!idset_contains(findset, i) || !test("f", path) || test("b", path))
653                                  strbuf_puts0(deletelist, path);                                  strbuf_puts0(deletelist, path);
654                  } else {                  } else {
655                          if (!test("f", path)) {                          if (!idset_contains(findset, i) || !test("f", path)) {
656                                  strbuf_puts0(deletelist, path);                                  strbuf_puts0(deletelist, path);
657                                  idset_add(deleteset, i);                                  idset_add(deleteset, i);
658                          }                          }
# Line 704  incremental(const char *dbpath, const ch Line 725  incremental(const char *dbpath, const ch
725          strbuf_close(deletelist);          strbuf_close(deletelist);
726          strbuf_close(addlist_other);          strbuf_close(addlist_other);
727          idset_close(deleteset);          idset_close(deleteset);
728            idset_close(findset);
729    
730          return updated;          return updated;
731  }  }

Legend:
Removed from v.1.163  
changed lines
  Added in v.1.164

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26