[BACK]Return to cgi.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/cgi.c between version 1.114 and 1.115

version 1.114, 2015/11/05 20:55:41 version 1.115, 2015/11/07 17:58:55
Line 704  static void
Line 704  static void
 catman(const struct req *req, const char *file)  catman(const struct req *req, const char *file)
 {  {
         FILE            *f;          FILE            *f;
         size_t           len;  
         int              i;  
         char            *p;          char            *p;
           size_t           sz;
           ssize_t          len;
           int              i;
         int              italic, bold;          int              italic, bold;
   
         if (NULL == (f = fopen(file, "r"))) {          if ((f = fopen(file, "r")) == NULL) {
                 puts("<P>You specified an invalid manual file.</P>");                  puts("<P>You specified an invalid manual file.</P>");
                 return;                  return;
         }          }
Line 717  catman(const struct req *req, const char *file)
Line 718  catman(const struct req *req, const char *file)
         puts("<DIV CLASS=\"catman\">\n"          puts("<DIV CLASS=\"catman\">\n"
              "<PRE>");               "<PRE>");
   
         while (NULL != (p = fgetln(f, &len))) {          p = NULL;
           sz = 0;
   
           while ((len = getline(&p, &sz, f)) != -1) {
                 bold = italic = 0;                  bold = italic = 0;
                 for (i = 0; i < (int)len - 1; i++) {                  for (i = 0; i < len - 1; i++) {
                         /*                          /*
                          * This means that the catpage is out of state.                           * This means that the catpage is out of state.
                          * Ignore it and keep going (although the                           * Ignore it and keep going (although the
Line 744  catman(const struct req *req, const char *file)
Line 748  catman(const struct req *req, const char *file)
                                 italic = bold = 0;                                  italic = bold = 0;
                                 html_putchar(p[i]);                                  html_putchar(p[i]);
                                 continue;                                  continue;
                         } else if (i + 2 >= (int)len)                          } else if (i + 2 >= len)
                                 continue;                                  continue;
   
                         /* Italic mode. */                          /* Italic mode. */
Line 820  catman(const struct req *req, const char *file)
Line 824  catman(const struct req *req, const char *file)
                 if (bold)                  if (bold)
                         printf("</B>");                          printf("</B>");
   
                 if (i == (int)len - 1 && '\n' != p[i])                  if (i == len - 1 && p[i] != '\n')
                         html_putchar(p[i]);                          html_putchar(p[i]);
   
                 putchar('\n');                  putchar('\n');
         }          }
           free(p);
   
         puts("</PRE>\n"          puts("</PRE>\n"
              "</DIV>");               "</DIV>");
Line 1134  pathgen(struct req *req)
Line 1139  pathgen(struct req *req)
         FILE    *fp;          FILE    *fp;
         char    *dp;          char    *dp;
         size_t   dpsz;          size_t   dpsz;
           ssize_t  len;
   
         if (NULL == (fp = fopen("manpath.conf", "r"))) {          if (NULL == (fp = fopen("manpath.conf", "r"))) {
                 fprintf(stderr, "%s/manpath.conf: %s\n",                  fprintf(stderr, "%s/manpath.conf: %s\n",
Line 1142  pathgen(struct req *req)
Line 1148  pathgen(struct req *req)
                 exit(EXIT_FAILURE);                  exit(EXIT_FAILURE);
         }          }
   
         while (NULL != (dp = fgetln(fp, &dpsz))) {          dp = NULL;
                 if ('\n' == dp[dpsz - 1])          dpsz = 0;
                         dpsz--;  
           while ((len = getline(&dp, &dpsz, fp)) != -1) {
                   if (dp[len - 1] == '\n')
                           dp[--len] = '\0';
                 req->p = mandoc_realloc(req->p,                  req->p = mandoc_realloc(req->p,
                     (req->psz + 1) * sizeof(char *));                      (req->psz + 1) * sizeof(char *));
                 dp = mandoc_strndup(dp, dpsz);  
                 if ( ! validate_urifrag(dp)) {                  if ( ! validate_urifrag(dp)) {
                         fprintf(stderr, "%s/manpath.conf contains "                          fprintf(stderr, "%s/manpath.conf contains "
                             "unsafe path \"%s\"\n", MAN_DIR, dp);                              "unsafe path \"%s\"\n", MAN_DIR, dp);
Line 1161  pathgen(struct req *req)
Line 1169  pathgen(struct req *req)
                         exit(EXIT_FAILURE);                          exit(EXIT_FAILURE);
                 }                  }
                 req->p[req->psz++] = dp;                  req->p[req->psz++] = dp;
                   dp = NULL;
                   dpsz = 0;
         }          }
           free(dp);
   
         if ( req->p == NULL ) {          if ( req->p == NULL ) {
                 fprintf(stderr, "%s/manpath.conf is empty\n", MAN_DIR);                  fprintf(stderr, "%s/manpath.conf is empty\n", MAN_DIR);

Legend:
Removed from v.1.114  
changed lines
  Added in v.1.115

CVSweb