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

Diff for /mandoc/read.c between version 1.147 and 1.148

version 1.147, 2016/01/08 02:13:39 version 1.148, 2016/01/08 02:53:13
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 539  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);                                  close(fd);
                                 curp->file = save_file;                                  curp->file = save_file;
Line 777  mparse_readfd(struct mparse *curp, int fd, const char 
Line 776  mparse_readfd(struct mparse *curp, int fd, const char 
         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(file, 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.147  
changed lines
  Added in v.1.148

CVSweb