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

Diff for /mandoc/main.c between version 1.52 and 1.53

version 1.52, 2009/10/30 05:58:37 version 1.53, 2009/10/31 06:10:57
Line 17 
Line 17 
 #include <sys/stat.h>  #include <sys/stat.h>
   
 #include <assert.h>  #include <assert.h>
 #include <err.h>  
 #include <fcntl.h>  #include <fcntl.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdint.h>  #include <stdint.h>
Line 285  ffile(struct buf *blk, struct buf *ln, 
Line 284  ffile(struct buf *blk, struct buf *ln, 
   
         curp->file = file;          curp->file = file;
         if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) {          if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) {
                 warn("%s", curp->file);                  perror(curp->file);
                 return(-1);                  return(-1);
         }          }
   
         c = fdesc(blk, ln, curp);          c = fdesc(blk, ln, curp);
   
         if (-1 == close(curp->fd))          if (-1 == close(curp->fd))
                 warn("%s", curp->file);                  perror(curp->file);
   
         return(c);          return(c);
 }  }
Line 319  fdesc(struct buf *blk, struct buf *ln, struct curparse
Line 318  fdesc(struct buf *blk, struct buf *ln, struct curparse
          */           */
   
         if (-1 == fstat(curp->fd, &st))          if (-1 == fstat(curp->fd, &st))
                 warn("%s", curp->file);                  perror(curp->file);
         else if ((size_t)st.st_blksize > sz)          else if ((size_t)st.st_blksize > sz)
                 sz = st.st_blksize;                  sz = st.st_blksize;
   
         if (sz > blk->sz) {          if (sz > blk->sz) {
                 blk->buf = realloc(blk->buf, sz);                  blk->buf = realloc(blk->buf, sz);
                 if (NULL == blk->buf) {                  if (NULL == blk->buf) {
                         warn("realloc");                          perror(NULL);
                         return(-1);                          exit(EXIT_FAILURE);
                 }                  }
                 blk->sz = sz;                  blk->sz = sz;
         }          }
Line 336  fdesc(struct buf *blk, struct buf *ln, struct curparse
Line 335  fdesc(struct buf *blk, struct buf *ln, struct curparse
   
         for (lnn = pos = comment = 0; ; ) {          for (lnn = pos = comment = 0; ; ) {
                 if (-1 == (ssz = read(curp->fd, blk->buf, sz))) {                  if (-1 == (ssz = read(curp->fd, blk->buf, sz))) {
                         warn("%s", curp->file);                          perror(curp->file);
                         return(-1);                          return(-1);
                 } else if (0 == ssz)                  } else if (0 == ssz)
                         break;                          break;
Line 348  fdesc(struct buf *blk, struct buf *ln, struct curparse
Line 347  fdesc(struct buf *blk, struct buf *ln, struct curparse
                                 ln->sz += 256; /* Step-size. */                                  ln->sz += 256; /* Step-size. */
                                 ln->buf = realloc(ln->buf, ln->sz);                                  ln->buf = realloc(ln->buf, ln->sz);
                                 if (NULL == ln->buf) {                                  if (NULL == ln->buf) {
                                         warn("realloc");                                          perror(NULL);
                                         return(-1);                                          return(EXIT_FAILURE);
                                 }                                  }
                         }                          }
   
Line 412  fdesc(struct buf *blk, struct buf *ln, struct curparse
Line 411  fdesc(struct buf *blk, struct buf *ln, struct curparse
         /* NOTE a parser may not have been assigned, yet. */          /* NOTE a parser may not have been assigned, yet. */
   
         if ( ! (man || mdoc)) {          if ( ! (man || mdoc)) {
                 (void)fprintf(stderr, "%s: not a manual\n",                  fprintf(stderr, "%s: Not a manual\n", curp->file);
                                 curp->file);  
                 return(0);                  return(0);
         }          }
   
Line 528  moptions(enum intt *tflags, char *arg)
Line 526  moptions(enum intt *tflags, char *arg)
         else if (0 == strcmp(arg, "an"))          else if (0 == strcmp(arg, "an"))
                 *tflags = INTT_MAN;                  *tflags = INTT_MAN;
         else {          else {
                 warnx("bad argument: -m%s", arg);                  fprintf(stderr, "%s: Bad argument", arg);
                 return(0);                  return(0);
         }          }
   
Line 549  toptions(enum outt *tflags, char *arg)
Line 547  toptions(enum outt *tflags, char *arg)
         else if (0 == strcmp(arg, "html"))          else if (0 == strcmp(arg, "html"))
                 *tflags = OUTT_HTML;                  *tflags = OUTT_HTML;
         else {          else {
                 warnx("bad argument: -T%s", arg);                  fprintf(stderr, "%s: Bad argument", arg);
                 return(0);                  return(0);
         }          }
   
Line 598  foptions(int *fflags, char *arg)
Line 596  foptions(int *fflags, char *arg)
                         *fflags &= ~NO_IGN_ESCAPE;                          *fflags &= ~NO_IGN_ESCAPE;
                         break;                          break;
                 default:                  default:
                         warnx("bad argument: -f%s", o);                          fprintf(stderr, "%s: Bad argument", o);
                         return(0);                          return(0);
                 }                  }
         }          }
Line 627  woptions(int *wflags, char *arg)
Line 625  woptions(int *wflags, char *arg)
                         *wflags |= WARN_WERR;                          *wflags |= WARN_WERR;
                         break;                          break;
                 default:                  default:
                         warnx("bad argument: -W%s", o);                          fprintf(stderr, "%s: Bad argument", o);
                         return(0);                          return(0);
                 }                  }
         }          }

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

CVSweb