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

Diff for /mandoc/mandocdb.c between version 1.208 and 1.209

version 1.208, 2015/11/07 14:22:29 version 1.209, 2015/11/07 17:58:55
Line 1291  parse_cat(struct mpage *mpage, int fd)
Line 1291  parse_cat(struct mpage *mpage, int fd)
 {  {
         FILE            *stream;          FILE            *stream;
         char            *line, *p, *title;          char            *line, *p, *title;
         size_t           len, plen, titlesz;          size_t           linesz, plen, titlesz;
           ssize_t          len;
           int              offs;
   
         stream = (-1 == fd) ?          stream = (-1 == fd) ?
             fopen(mpage->mlinks->file, "r") :              fopen(mpage->mlinks->file, "r") :
Line 1304  parse_cat(struct mpage *mpage, int fd)
Line 1306  parse_cat(struct mpage *mpage, int fd)
                 return;                  return;
         }          }
   
           line = NULL;
           linesz = 0;
   
         /* Skip to first blank line. */          /* Skip to first blank line. */
   
         while (NULL != (line = fgetln(stream, &len)))          while (getline(&line, &linesz, stream) != -1)
                 if ('\n' == *line)                  if (*line == '\n')
                         break;                          break;
   
         /*          /*
Line 1315  parse_cat(struct mpage *mpage, int fd)
Line 1320  parse_cat(struct mpage *mpage, int fd)
          * is the first section header.  Skip to it.           * is the first section header.  Skip to it.
          */           */
   
         while (NULL != (line = fgetln(stream, &len)))          while (getline(&line, &linesz, stream) != -1)
                 if ('\n' != *line && ' ' != *line)                  if (*line != '\n' && *line != ' ')
                         break;                          break;
   
         /*          /*
Line 1329  parse_cat(struct mpage *mpage, int fd)
Line 1334  parse_cat(struct mpage *mpage, int fd)
         titlesz = 0;          titlesz = 0;
         title = NULL;          title = NULL;
   
         while (NULL != (line = fgetln(stream, &len))) {          while ((len = getline(&line, &linesz, stream)) != -1) {
                 if (' ' != *line || '\n' != line[len - 1])                  if (*line != ' ')
                         break;                          break;
                 while (len > 0 && isspace((unsigned char)*line)) {                  offs = 0;
                         line++;                  while (isspace((unsigned char)line[offs]))
                         len--;                          offs++;
                 }                  if (line[offs] == '\0')
                 if (1 == len)  
                         continue;                          continue;
                 title = mandoc_realloc(title, titlesz + len);                  title = mandoc_realloc(title, titlesz + len - offs);
                 memcpy(title + titlesz, line, len);                  memcpy(title + titlesz, line + offs, len - offs);
                 titlesz += len;                  titlesz += len - offs;
                 title[titlesz - 1] = ' ';                  title[titlesz - 1] = ' ';
         }          }
           free(line);
   
         /*          /*
          * If no page content can be found, or the input line           * If no page content can be found, or the input line
Line 1360  parse_cat(struct mpage *mpage, int fd)
Line 1365  parse_cat(struct mpage *mpage, int fd)
                 return;                  return;
         }          }
   
         title = mandoc_realloc(title, titlesz + 1);          title[titlesz - 1] = '\0';
         title[titlesz] = '\0';  
   
         /*          /*
          * Skip to the first dash.           * Skip to the first dash.

Legend:
Removed from v.1.208  
changed lines
  Added in v.1.209

CVSweb