/[global]/global/htags/fileindex.c
ViewVC logotype

Diff of /global/htags/fileindex.c

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

revision 1.48 by shigio, Thu Oct 27 06:33:35 2005 UTC revision 1.49 by shigio, Mon Nov 7 12:17:49 2005 UTC
# Line 584  extract_lastname(const char *image, int Line 584  extract_lastname(const char *image, int
584  int  int
585  makefileindex(const char *file, STRBUF *files)  makefileindex(const char *file, STRBUF *files)
586  {  {
587          FILE *FIND, *FILEMAP, *FILES, *STDOUT, *op = NULL;          FILE *FILEMAP, *FILES, *STDOUT, *op = NULL;
588          char *_;          GFIND *gp;
589            const char *_;
590          int count = 0;          int count = 0;
591          const char *indexlink = (Fflag) ? "../files" : "../mains";          const char *indexlink = (Fflag) ? "../files" : "../mains";
592          STRBUF *sb = strbuf_open(0);          STRBUF *sb = strbuf_open(0);
# Line 602  makefileindex(const char *file, STRBUF * Line 603  makefileindex(const char *file, STRBUF *
603          int flags = REG_EXTENDED;          int flags = REG_EXTENDED;
604          regex_t is_include_file;          regex_t is_include_file;
605    
         if (other_files)  
                 snprintf(command, sizeof(command), "gtags --find --other | %s -t / -k 2", POSIX_SORT);  
         else  
                 snprintf(command, sizeof(command), "gtags --find");  
606          if (w32)          if (w32)
607                  flags |= REG_ICASE;                  flags |= REG_ICASE;
608          strbuf_reset(sb);          strbuf_reset(sb);
# Line 629  makefileindex(const char *file, STRBUF * Line 626  makefileindex(const char *file, STRBUF *
626          /*          /*
627           * preparations.           * preparations.
628           */           */
         if ((FIND = popen(command, "r")) == NULL)  
                 die("cannot fork.");  
629          if ((FILES = fopen(makepath(distpath, file, NULL), "w")) == NULL)          if ((FILES = fopen(makepath(distpath, file, NULL), "w")) == NULL)
630                  die("cannot open file '%s'.", file);                  die("cannot open file '%s'.", file);
631    
# Line 650  makefileindex(const char *file, STRBUF * Line 645  makefileindex(const char *file, STRBUF *
645                  if (!(FILEMAP = fopen(makepath(distpath, "FILEMAP", NULL), "w")))                  if (!(FILEMAP = fopen(makepath(distpath, "FILEMAP", NULL), "w")))
646                          die("cannot open '%s'.", makepath(distpath, "FILEMAP", NULL));                          die("cannot open '%s'.", makepath(distpath, "FILEMAP", NULL));
647          }          }
648          while ((_ = strbuf_fgets(input, FIND, STRBUF_NOCRLF)) != NULL) {          gp = gfind_open(dbpath, NULL, other_files);
649            while ((_ = gfind_read(gp)) != NULL) {
650                  char fname[MAXPATHLEN];                  char fname[MAXPATHLEN];
                 int notsource = 0;  
651    
652                  /* It seems like README or ChangeLog. */                  /* It seems like README or ChangeLog. */
653                  if (*_ == ' ') {                  if (gp->type == GPATH_OTHER && !other_files)
654                          if (!other_files)                          continue;
                                 continue;  
                         _++;  
                         if (test("b", _))  
                                 continue;  
                         notsource = 1;  
                 }  
655                  _ += 2;                 /* remove './' */                  _ += 2;                 /* remove './' */
656                  count++;                  count++;
657                  message(" [%d] adding %s", count, _);                  message(" [%d] adding %s", count, _);
# Line 795  makefileindex(const char *file, STRBUF * Line 784  makefileindex(const char *file, STRBUF *
784                          char tmp[1024];                          char tmp[1024];
785                          const char *file, *suffix = NULL, *dir = NULL;                          const char *file, *suffix = NULL, *dir = NULL;
786    
787                          if (notsource && dynamic) {                          if (gp->type == GPATH_OTHER && dynamic) {
788                                  if (!(*action == '/' || count_stack(dirstack) == 0))                                  if (!(*action == '/' || count_stack(dirstack) == 0))
789                                          dir = "..";                                          dir = "..";
790                                  snprintf(tmp, sizeof(tmp), "%s?pattern=%s%stype=source",                                  snprintf(tmp, sizeof(tmp), "%s?pattern=%s%stype=source",
# Line 844  makefileindex(const char *file, STRBUF * Line 833  makefileindex(const char *file, STRBUF *
833                  else                  else
834                          fputs(strbuf_value(sb), STDOUT);                          fputs(strbuf_value(sb), STDOUT);
835          }          }
836            gfind_close(gp);
837          if (map_file)          if (map_file)
838                  fclose(FILEMAP);                  fclose(FILEMAP);
         if (pclose(FIND) != 0)  
                 die("cannot traverse directory.(%s)", command);  
839          while (count_stack(dirstack) > 0) {          while (count_stack(dirstack) > 0) {
840                  const char *parent, *suffix;                  const char *parent, *suffix;
841    

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

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