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

Diff for /mandoc/read.c between version 1.144 and 1.149

version 1.144, 2015/10/13 22:59:54 version 1.149, 2016/07/10 13:34:30
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-2015 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010-2016 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 26 
Line 26 
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
   #if HAVE_ERR
 #include <err.h>  #include <err.h>
   #endif
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <stdarg.h>  #include <stdarg.h>
Line 215  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 217  static const char * const mandocerrs[MANDOCERR_MAX] = 
         /* related to request and macro arguments */          /* related to request and macro arguments */
         "escaped character not allowed in a name",          "escaped character not allowed in a name",
         "NOT IMPLEMENTED: Bd -file",          "NOT IMPLEMENTED: Bd -file",
           "skipping display without arguments",
         "missing list type, using -item",          "missing list type, using -item",
         "missing manual name, using \"\"",          "missing manual name, using \"\"",
         "uname(3) system call failed, using UNKNOWN",          "uname(3) system call failed, using UNKNOWN",
Line 536  rerun:
Line 539  rerun:
                         if (curp->secondary)                          if (curp->secondary)
                                 curp->secondary->sz -= pos + 1;                                  curp->secondary->sz -= pos + 1;
                         save_file = curp->file;                          save_file = curp->file;
                         if (mparse_open(curp, &fd, ln.buf + of) ==                          if ((fd = mparse_open(curp, ln.buf + of)) != -1) {
                             MANDOCLEVEL_OK) {  
                                 mparse_readfd(curp, fd, ln.buf + of);                                  mparse_readfd(curp, fd, ln.buf + of);
                                   close(fd);
                                 curp->file = save_file;                                  curp->file = save_file;
                         } else {                          } else {
                                 curp->file = save_file;                                  curp->file = save_file;
Line 770  mparse_readfd(struct mparse *curp, int fd, const char 
Line 773  mparse_readfd(struct mparse *curp, int fd, const char 
 #endif  #endif
                         free(blk.buf);                          free(blk.buf);
         }          }
   
         if (fd != STDIN_FILENO && close(fd) == -1)  
                 perror(file);  
   
         return curp->file_status;          return curp->file_status;
 }  }
   
 enum mandoclevel  int
 mparse_open(struct mparse *curp, int *fd, const char *file)  mparse_open(struct mparse *curp, const char *file)
 {  {
         char             *cp;          char             *cp;
           int               fd;
   
         curp->file = file;          curp->file = file;
         cp = strrchr(file, '.');          cp = strrchr(file, '.');
Line 788  mparse_open(struct mparse *curp, int *fd, const char *
Line 788  mparse_open(struct mparse *curp, int *fd, const char *
   
         /* First try to use the filename as it is. */          /* First try to use the filename as it is. */
   
         if ((*fd = open(file, O_RDONLY)) != -1)          if ((fd = open(file, O_RDONLY)) != -1)
                 return MANDOCLEVEL_OK;                  return fd;
   
         /*          /*
          * If that doesn't work and the filename doesn't           * If that doesn't work and the filename doesn't
Line 798  mparse_open(struct mparse *curp, int *fd, const char *
Line 798  mparse_open(struct mparse *curp, int *fd, const char *
   
         if ( ! curp->gzip) {          if ( ! curp->gzip) {
                 mandoc_asprintf(&cp, "%s.gz", file);                  mandoc_asprintf(&cp, "%s.gz", file);
                 *fd = open(file, O_RDONLY);                  fd = open(cp, O_RDONLY);
                 free(cp);                  free(cp);
                 if (*fd != -1) {                  if (fd != -1) {
                         curp->gzip = 1;                          curp->gzip = 1;
                         return MANDOCLEVEL_OK;                          return fd;
                 }                  }
         }          }
   
         /* Neither worked, give up. */          /* Neither worked, give up. */
   
         mandoc_msg(MANDOCERR_FILE, curp, 0, 0, strerror(errno));          mandoc_msg(MANDOCERR_FILE, curp, 0, 0, strerror(errno));
         return MANDOCLEVEL_ERROR;          return -1;
 }  }
   
 struct mparse *  struct mparse *

Legend:
Removed from v.1.144  
changed lines
  Added in v.1.149

CVSweb