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

Diff for /mandoc/mandocdb.c between version 1.240 and 1.241

version 1.240, 2017/01/27 01:09:14 version 1.241, 2017/01/27 01:14:47
Line 1254  static void
Line 1254  static void
 parse_cat(struct mpage *mpage, int fd)  parse_cat(struct mpage *mpage, int fd)
 {  {
         FILE            *stream;          FILE            *stream;
         char            *line, *p, *title;          struct mlink    *mlink;
           char            *line, *p, *title, *sec;
         size_t           linesz, plen, titlesz;          size_t           linesz, plen, titlesz;
         ssize_t          len;          ssize_t          len;
         int              offs;          int              offs;
   
         stream = (-1 == fd) ?          mlink = mpage->mlinks;
             fopen(mpage->mlinks->file, "r") :          stream = fd == -1 ? fopen(mlink->file, "r") : fdopen(fd, "r");
             fdopen(fd, "r");          if (stream == NULL) {
         if (NULL == stream) {                  if (fd != -1)
                 if (-1 != fd)  
                         close(fd);                          close(fd);
                 if (warnings)                  if (warnings)
                         say(mpage->mlinks->file, "&fopen");                          say(mlink->file, "&fopen");
                 return;                  return;
         }          }
   
         line = NULL;          line = NULL;
         linesz = 0;          linesz = 0;
   
         /* Skip to first blank line. */          /* Parse the section number from the header line. */
   
         while (getline(&line, &linesz, stream) != -1)          while (getline(&line, &linesz, stream) != -1) {
                 if (*line == '\n')                  if (*line == '\n')
                           continue;
                   if ((sec = strchr(line, '(')) == NULL)
                         break;                          break;
                   if ((p = strchr(++sec, ')')) == NULL)
                           break;
                   free(mpage->sec);
                   mpage->sec = mandoc_strndup(sec, p - sec);
                   if (warnings && *mlink->dsec != '\0' &&
                       strcasecmp(mpage->sec, mlink->dsec))
                           say(mlink->file,
                               "Section \"%s\" manual in %s directory",
                               mpage->sec, mlink->dsec);
                   break;
           }
   
           /* Skip to first blank line. */
   
           while (line == NULL || *line != '\n')
                   if (getline(&line, &linesz, stream) == -1)
                           break;
   
         /*          /*
          * Assume the first line that is not indented           * Assume the first line that is not indented
          * is the first section header.  Skip to it.           * is the first section header.  Skip to it.
Line 1322  parse_cat(struct mpage *mpage, int fd)
Line 1341  parse_cat(struct mpage *mpage, int fd)
   
         if (NULL == title || '\0' == *title) {          if (NULL == title || '\0' == *title) {
                 if (warnings)                  if (warnings)
                         say(mpage->mlinks->file,                          say(mlink->file, "Cannot find NAME section");
                             "Cannot find NAME section");  
                 fclose(stream);                  fclose(stream);
                 free(title);                  free(title);
                 return;                  return;
Line 1342  parse_cat(struct mpage *mpage, int fd)
Line 1360  parse_cat(struct mpage *mpage, int fd)
                         /* Skip to next word. */ ;                          /* Skip to next word. */ ;
         } else {          } else {
                 if (warnings)                  if (warnings)
                         say(mpage->mlinks->file,                          say(mlink->file, "No dash in title line");
                             "No dash in title line");  
                 p = title;                  p = title;
         }          }
   

Legend:
Removed from v.1.240  
changed lines
  Added in v.1.241

CVSweb