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

Diff for /mandoc/main.c between version 1.31 and 1.35

version 1.31, 2009/06/18 10:32:00 version 1.35, 2009/07/06 09:21:24
Line 99  static int    moptions(enum intt *, char *);
Line 99  static int    moptions(enum intt *, char *);
 static  int               woptions(int *, char *);  static  int               woptions(int *, char *);
 static  int               merr(void *, int, int, const char *);  static  int               merr(void *, int, int, const char *);
 static  int               manwarn(void *, int, int, const char *);  static  int               manwarn(void *, int, int, const char *);
 static  int               mdocwarn(void *, int, int,  static  int               mdocwarn(void *, int, int, const char *);
                                 enum mdoc_warn, const char *);  
 static  int               ffile(struct buf *, struct buf *,  static  int               ffile(struct buf *, struct buf *,
                                 const char *, struct curparse *);                                  const char *, struct curparse *);
 static  int               fdesc(struct buf *, struct buf *,  static  int               fdesc(struct buf *, struct buf *,
Line 132  main(int argc, char *argv[])
Line 131  main(int argc, char *argv[])
                 switch (c) {                  switch (c) {
                 case ('f'):                  case ('f'):
                         if ( ! foptions(&curp.fflags, optarg))                          if ( ! foptions(&curp.fflags, optarg))
                                 return(0);                                  return(EXIT_FAILURE);
                         break;                          break;
                 case ('m'):                  case ('m'):
                         if ( ! moptions(&curp.inttype, optarg))                          if ( ! moptions(&curp.inttype, optarg))
                                 return(0);                                  return(EXIT_FAILURE);
                         break;                          break;
                 case ('T'):                  case ('T'):
                         if ( ! toptions(&curp.outtype, optarg))                          if ( ! toptions(&curp.outtype, optarg))
                                 return(0);                                  return(EXIT_FAILURE);
                         break;                          break;
                 case ('W'):                  case ('W'):
                         if ( ! woptions(&curp.wflags, optarg))                          if ( ! woptions(&curp.wflags, optarg))
                                 return(0);                                  return(EXIT_FAILURE);
                         break;                          break;
                 case ('V'):                  case ('V'):
                         version();                          version();
Line 232  man_init(struct curparse *curp)
Line 231  man_init(struct curparse *curp)
   
         /* Defaults from mandoc.1. */          /* Defaults from mandoc.1. */
   
         pflags = MAN_IGN_MACRO | MAN_IGN_CHARS;          pflags = MAN_IGN_MACRO | MAN_IGN_ESCAPE | MAN_IGN_CHARS;
   
         if (curp->fflags & NO_IGN_MACRO)          if (curp->fflags & NO_IGN_MACRO)
                 pflags &= ~MAN_IGN_MACRO;                  pflags &= ~MAN_IGN_MACRO;
         if (curp->fflags & NO_IGN_CHARS)          if (curp->fflags & NO_IGN_CHARS)
                 pflags &= ~MAN_IGN_CHARS;                  pflags &= ~MAN_IGN_CHARS;
           if (curp->fflags & NO_IGN_ESCAPE)
                   pflags &= ~MAN_IGN_ESCAPE;
   
         if (NULL == (man = man_alloc(curp, pflags, &mancb)))          if (NULL == (man = man_alloc(curp, pflags, &mancb)))
                 warnx("memory exhausted");                  warnx("memory exhausted");
Line 318  fdesc(struct buf *blk, struct buf *ln, struct curparse
Line 319  fdesc(struct buf *blk, struct buf *ln, struct curparse
          */           */
   
         if (-1 == fstat(curp->fd, &st))          if (-1 == fstat(curp->fd, &st))
                 warnx("%s", curp->file);                  warn("%s", 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;
   
Line 552  toptions(enum outt *tflags, char *arg)
Line 553  toptions(enum outt *tflags, char *arg)
 static int  static int
 foptions(int *fflags, char *arg)  foptions(int *fflags, char *arg)
 {  {
         char            *v;          char            *v, *o;
         char            *toks[6];          char            *toks[6];
   
         toks[0] = "ign-scope";          toks[0] = "ign-scope";
Line 562  foptions(int *fflags, char *arg)
Line 563  foptions(int *fflags, char *arg)
         toks[4] = "strict";          toks[4] = "strict";
         toks[5] = NULL;          toks[5] = NULL;
   
         while (*arg)          while (*arg) {
                   o = arg;
                 switch (getsubopt(&arg, toks, &v)) {                  switch (getsubopt(&arg, toks, &v)) {
                 case (0):                  case (0):
                         *fflags |= IGN_SCOPE;                          *fflags |= IGN_SCOPE;
Line 581  foptions(int *fflags, char *arg)
Line 583  foptions(int *fflags, char *arg)
                                    NO_IGN_MACRO | NO_IGN_CHARS;                                     NO_IGN_MACRO | NO_IGN_CHARS;
                         break;                          break;
                 default:                  default:
                         warnx("bad argument: -f%s", arg);                          warnx("bad argument: -f%s", o);
                         return(0);                          return(0);
                 }                  }
           }
   
         return(1);          return(1);
 }  }
Line 592  foptions(int *fflags, char *arg)
Line 595  foptions(int *fflags, char *arg)
 static int  static int
 woptions(int *wflags, char *arg)  woptions(int *wflags, char *arg)
 {  {
         char            *v;          char            *v, *o;
         char            *toks[5];          char            *toks[5];
   
         toks[0] = "all";          toks[0] = "all";
Line 601  woptions(int *wflags, char *arg)
Line 604  woptions(int *wflags, char *arg)
         toks[3] = "error";          toks[3] = "error";
         toks[4] = NULL;          toks[4] = NULL;
   
         while (*arg)          while (*arg) {
                   o = arg;
                 switch (getsubopt(&arg, toks, &v)) {                  switch (getsubopt(&arg, toks, &v)) {
                 case (0):                  case (0):
                         *wflags |= WARN_WALL;                          *wflags |= WARN_WALL;
Line 616  woptions(int *wflags, char *arg)
Line 620  woptions(int *wflags, char *arg)
                         *wflags |= WARN_WERR;                          *wflags |= WARN_WERR;
                         break;                          break;
                 default:                  default:
                         warnx("bad argument: -W%s", arg);                          warnx("bad argument: -W%s", o);
                         return(0);                          return(0);
                 }                  }
           }
   
         return(1);          return(1);
 }  }
Line 639  merr(void *arg, int line, int col, const char *msg)
Line 644  merr(void *arg, int line, int col, const char *msg)
   
   
 static int  static int
 mdocwarn(void *arg, int line, int col,  mdocwarn(void *arg, int line, int col, const char *msg)
                 enum mdoc_warn type, const char *msg)  
 {  {
         struct curparse *curp;          struct curparse *curp;
         char            *wtype;  
   
         curp = (struct curparse *)arg;          curp = (struct curparse *)arg;
         wtype = NULL;  
   
         switch (type) {          warnx("%s:%d: warning: %s (column %d)",
         case (WARN_COMPAT):                          curp->file, line, msg, col);
                 wtype = "compat";  
                 if (curp->wflags & WARN_WCOMPAT)  
                         break;  
                 return(1);  
         case (WARN_SYNTAX):  
                 wtype = "syntax";  
                 if (curp->wflags & WARN_WSYNTAX)  
                         break;  
                 return(1);  
         }  
   
         assert(wtype);  
         warnx("%s:%d: %s warning: %s (column %d)",  
                         curp->file, line, wtype, msg, col);  
   
         if ( ! (curp->wflags & WARN_WERR))          if ( ! (curp->wflags & WARN_WERR))
                 return(1);                  return(1);

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.35

CVSweb