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

Diff of /global/htags/htags.c

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

revision 1.72 by h-iwamoto, Mon Oct 24 15:28:07 2005 UTC revision 1.73 by shigio, Tue Oct 25 01:54:31 2005 UTC
# Line 735  makehtaccess(const char *file) Line 735  makehtaccess(const char *file)
735          fclose(op);          fclose(op);
736  }  }
737  /*  /*
  * Wrapper of src2html()  
  */  
 static int  
 do_src2html(STRBUF *path_list, int count, int total)  
 {  
         int notsource;  
         char path[MAXPATHLEN];  
         const char *_ = strbuf_value(path_list);  
         const char *end = _ + strbuf_getlen(path_list);  
         const char *p;  
   
         while (_ < end) {  
                 notsource = *_++;  
                 count++;  
                 message(" [%d/%d] converting %s", count, total, _);  
                 p = path2fid(_);  
                 snprintf(path, sizeof(path), "%s/%s/%s.%s", distpath, SRCS, p, HTML);  
                 src2html(_, path, notsource);  
                 _ += strlen(_) + 1;  
         }  
         return count;  
 }  
 /*  
738   * makehtml: make html files   * makehtml: make html files
739   *   *
740   *      i)      total   number of files.   *      i)      total   number of files.
# Line 765  do_src2html(STRBUF *path_list, int count Line 742  do_src2html(STRBUF *path_list, int count
742  static void  static void
743  makehtml(int total)  makehtml(int total)
744  {  {
         FILE *ip;  
         const char *_;  
         int count = 0;  
745          char command[MAXFILLEN];          char command[MAXFILLEN];
746            FILE *ip, *source_stream, *anchor_stream;
747            const char *path;
748            int count = 0;
749          STRBUF *sb = strbuf_open(0);          STRBUF *sb = strbuf_open(0);
         STRBUF *alllist = strbuf_open(0);  
         STRBUF *srclist = strbuf_open(0);  
         int path_list_max;  
750    
751          /*          /*
752           * Calculate the limit of path list.           * Create two same streams. The two have each independent file pointer.
753             *      source_stream: for src2html()
754             *      anchor_stream: for anchor_load().
755           */           */
         path_list_max = exec_line_limit(strlen("global -fnr"));  
756          if (other_files && !dynamic)          if (other_files && !dynamic)
757                  snprintf(command, sizeof(command), "%s --other | gnusort -t / -k 2", findcom);                  snprintf(command, sizeof(command), "%s --other | gnusort -t / -k 2", findcom);
758          else          else
# Line 785  makehtml(int total) Line 760  makehtml(int total)
760          ip = popen(command, "r");          ip = popen(command, "r");
761          if (!ip)          if (!ip)
762                  die("cannot execute command '%s'.", command);                  die("cannot execute command '%s'.", command);
763          while ((_ = strbuf_fgets(sb, ip, STRBUF_NOCRLF)) != NULL) {          source_stream = tmpfile();
764            anchor_stream = tmpfile();
765            while (strbuf_fgets(sb, ip, 0) != NULL) {
766                    fputs(strbuf_value(sb), source_stream);
767                    fputs(strbuf_value(sb), anchor_stream);
768            }
769            if (pclose(ip) != 0)
770                    die("cannot traverse directory.(%s)", command);
771            rewind(source_stream);
772            /*
773             * Prepare anchor stream for anchor_load().
774             */
775            anchor_prepare(anchor_stream);
776            /*
777             * For each path in the source stream, convert the path into HTML file.
778             */
779            while ((path = strbuf_fgets(sb, source_stream, STRBUF_NOCRLF)) != NULL) {
780                    char html[MAXPATHLEN];
781                  int notsource = 0;                  int notsource = 0;
782    
783                  if (*_ == ' ') {                  if (*path == ' ') {
784                          if (!other_files)                          if (!other_files)
785                                  continue;                                  continue;
786                          _++;                          path++;
787                          if (test("b", _)) {                          if (test("b", path)) {
788                                  if (wflag)                                  if (wflag)
789                                          warning("'%s' is binary file. (skipped)", _);                                          warning("'%s' is binary file. (skipped)", path + 2);
790                                  continue;                                  continue;
791                          }                          }
792                          notsource = 1;                          notsource = 1;
793                  } else {                  } else {
794                          /*                          /*
795                           * Execute parser when path name collects enough.                           * load tags belonging to the path.
796                           * Though the path_list is \0 separated list of string,                           * The path must be start "./".
                          * we can think its length equals to the length of  
                          * argument string because each \0 can be replaced  
                          * with a blank.  
797                           */                           */
798                          if (strbuf_getlen(srclist)) {                          anchor_load(path);
                                 if (strbuf_getlen(srclist) + strlen(_) > path_list_max) {  
                                         anchor_prepare(srclist);  
                                         count = do_src2html(alllist, count, total);  
                                         strbuf_reset(srclist);  
                                         strbuf_reset(alllist);  
                                 }  
                         }  
                         /*  
                          * Add a path to the path list.  
                          */  
                         strbuf_puts0(srclist, _);  
799                  }                  }
800                  strbuf_putc(alllist, notsource);                  count++;
801                  strbuf_puts0(alllist, _ + 2);                  path += 2;              /* remove './' at the head */
802          }                  message(" [%d/%d] converting %s", count, total, path);
803          if (strbuf_getlen(alllist)) {                  snprintf(html, sizeof(html), "%s/%s/%s.%s", distpath, SRCS, path2fid(path), HTML);
804                  if (strbuf_getlen(srclist))                  src2html(path, html, notsource);
                         anchor_prepare(srclist);  
                 do_src2html(alllist, count, total);  
805          }          }
         if (pclose(ip) != 0)  
                 die("cannot traverse directory.(%s)", command);  
806          strbuf_close(sb);          strbuf_close(sb);
         strbuf_close(alllist);  
         strbuf_close(srclist);  
807  }  }
808  /*  /*
809   * copy file.   * copy file.

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.73

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