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

Diff for /mandoc/read.c between version 1.96 and 1.97

version 1.96, 2014/11/01 06:03:13 version 1.97, 2014/11/26 21:40:17
Line 64  struct mparse {
Line 64  struct mparse {
         int               filenc; /* encoding of the current file */          int               filenc; /* encoding of the current file */
         int               reparse_count; /* finite interp. stack */          int               reparse_count; /* finite interp. stack */
         int               line; /* line number in the file */          int               line; /* line number in the file */
           pid_t             child; /* the gunzip(1) process */
 };  };
   
 static  void      choose_parser(struct mparse *);  static  void      choose_parser(struct mparse *);
Line 823  mparse_readfd(struct mparse *curp, int fd, const char 
Line 824  mparse_readfd(struct mparse *curp, int fd, const char 
 }  }
   
 enum mandoclevel  enum mandoclevel
 mparse_open(struct mparse *curp, int *fd, const char *file,  mparse_open(struct mparse *curp, int *fd, const char *file)
         pid_t *child_pid)  
 {  {
         int               pfd[2];          int               pfd[2];
         char             *cp;          char             *cp;
Line 834  mparse_open(struct mparse *curp, int *fd, const char *
Line 834  mparse_open(struct mparse *curp, int *fd, const char *
         curp->file = file;          curp->file = file;
         if ((cp = strrchr(file, '.')) == NULL ||          if ((cp = strrchr(file, '.')) == NULL ||
             strcmp(cp + 1, "gz")) {              strcmp(cp + 1, "gz")) {
                 *child_pid = 0;                  curp->child = 0;
                 if ((*fd = open(file, O_RDONLY)) == -1) {                  if ((*fd = open(file, O_RDONLY)) == -1) {
                         err = MANDOCERR_SYSOPEN;                          err = MANDOCERR_SYSOPEN;
                         goto out;                          goto out;
Line 847  mparse_open(struct mparse *curp, int *fd, const char *
Line 847  mparse_open(struct mparse *curp, int *fd, const char *
                 goto out;                  goto out;
         }          }
   
         switch (*child_pid = fork()) {          switch (curp->child = fork()) {
         case -1:          case -1:
                 err = MANDOCERR_SYSFORK;                  err = MANDOCERR_SYSFORK;
                 close(pfd[0]);                  close(pfd[0]);
Line 871  mparse_open(struct mparse *curp, int *fd, const char *
Line 871  mparse_open(struct mparse *curp, int *fd, const char *
   
 out:  out:
         *fd = -1;          *fd = -1;
         *child_pid = 0;          curp->child = 0;
         curp->file_status = MANDOCLEVEL_SYSERR;          curp->file_status = MANDOCLEVEL_SYSERR;
         if (curp->mmsg)          if (curp->mmsg)
                 (*curp->mmsg)(err, curp->file_status, file,                  (*curp->mmsg)(err, curp->file_status, file,
Line 882  out:
Line 882  out:
 }  }
   
 enum mandoclevel  enum mandoclevel
 mparse_wait(struct mparse *curp, pid_t child_pid)  mparse_wait(struct mparse *curp)
 {  {
         int       status;          int       status;
   
         if (waitpid(child_pid, &status, 0) == -1) {          if (curp->child == 0)
                   return(MANDOCLEVEL_OK);
   
           if (waitpid(curp->child, &status, 0) == -1) {
                 mandoc_msg(MANDOCERR_SYSWAIT, curp, 0, 0,                  mandoc_msg(MANDOCERR_SYSWAIT, curp, 0, 0,
                     strerror(errno));                      strerror(errno));
                 curp->file_status = MANDOCLEVEL_SYSERR;                  curp->file_status = MANDOCLEVEL_SYSERR;

Legend:
Removed from v.1.96  
changed lines
  Added in v.1.97

CVSweb