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

Diff for /mandoc/read.c between version 1.193 and 1.196

version 1.193, 2017/11/10 23:32:40 version 1.196, 2018/07/28 18:34:15
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org>   * Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
Line 94  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 94  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "generic style suggestion",          "generic style suggestion",
   
         "legacy man(7) date format",          "legacy man(7) date format",
           "normalizing date format to",
         "lower case character in document title",          "lower case character in document title",
         "duplicate RCS id",          "duplicate RCS id",
         "possible typo in section name",          "possible typo in section name",
Line 106  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 107  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "no blank before trailing delimiter",          "no blank before trailing delimiter",
         "fill mode already enabled, skipping",          "fill mode already enabled, skipping",
         "fill mode already disabled, skipping",          "fill mode already disabled, skipping",
           "verbatim \"--\", maybe consider using \\(em",
         "function name without markup",          "function name without markup",
         "whitespace at end of input line",          "whitespace at end of input line",
         "bad comment style",          "bad comment style",
Line 556  read_whole_file(struct mparse *curp, const char *file,
Line 558  read_whole_file(struct mparse *curp, const char *file,
         gzFile           gz;          gzFile           gz;
         size_t           off;          size_t           off;
         ssize_t          ssz;          ssize_t          ssz;
           int              gzerrnum, retval;
   
         if (fstat(fd, &st) == -1) {          if (fstat(fd, &st) == -1) {
                 mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,                  mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,
Line 583  read_whole_file(struct mparse *curp, const char *file,
Line 586  read_whole_file(struct mparse *curp, const char *file,
         }          }
   
         if (curp->gzip) {          if (curp->gzip) {
                   /*
                    * Duplicating the file descriptor is required
                    * because we will have to call gzclose(3)
                    * to free memory used internally by zlib,
                    * but that will also close the file descriptor,
                    * which this function must not do.
                    */
                   if ((fd = dup(fd)) == -1) {
                           mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,
                               "dup: %s", strerror(errno));
                           return 0;
                   }
                 if ((gz = gzdopen(fd, "rb")) == NULL) {                  if ((gz = gzdopen(fd, "rb")) == NULL) {
                         mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,                          mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,
                             "gzdopen: %s", strerror(errno));                              "gzdopen: %s", strerror(errno));
                           close(fd);
                         return 0;                          return 0;
                 }                  }
         } else          } else
Line 598  read_whole_file(struct mparse *curp, const char *file,
Line 614  read_whole_file(struct mparse *curp, const char *file,
   
         *with_mmap = 0;          *with_mmap = 0;
         off = 0;          off = 0;
           retval = 0;
         fb->sz = 0;          fb->sz = 0;
         fb->buf = NULL;          fb->buf = NULL;
         for (;;) {          for (;;) {
Line 614  read_whole_file(struct mparse *curp, const char *file,
Line 631  read_whole_file(struct mparse *curp, const char *file,
                     read(fd, fb->buf + (int)off, fb->sz - off);                      read(fd, fb->buf + (int)off, fb->sz - off);
                 if (ssz == 0) {                  if (ssz == 0) {
                         fb->sz = off;                          fb->sz = off;
                         return 1;                          retval = 1;
                           break;
                 }                  }
                 if (ssz == -1) {                  if (ssz == -1) {
                         mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,                          if (curp->gzip)
                             "read: %s", strerror(errno));                                  (void)gzerror(gz, &gzerrnum);
                           mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0, "read: %s",
                               curp->gzip && gzerrnum != Z_ERRNO ?
                               zError(gzerrnum) : strerror(errno));
                         break;                          break;
                 }                  }
                 off += (size_t)ssz;                  off += (size_t)ssz;
         }          }
   
         free(fb->buf);          if (curp->gzip && (gzerrnum = gzclose(gz)) != Z_OK)
         fb->buf = NULL;                  mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0, "gzclose: %s",
         return 0;                      gzerrnum == Z_ERRNO ? strerror(errno) :
                       zError(gzerrnum));
           if (retval == 0) {
                   free(fb->buf);
                   fb->buf = NULL;
           }
           return retval;
 }  }
   
 static void  static void

Legend:
Removed from v.1.193  
changed lines
  Added in v.1.196

CVSweb