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

Diff for /mandoc/main.c between version 1.154 and 1.158

version 1.154, 2011/03/20 11:41:24 version 1.158, 2011/03/22 10:35:26
Line 30 
Line 30 
 #include "main.h"  #include "main.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "man.h"  #include "man.h"
 #include "roff.h"  
   
 #if !defined(__GNUC__) || (__GNUC__ < 2)  #if !defined(__GNUC__) || (__GNUC__ < 2)
 # if !defined(lint)  # if !defined(lint)
Line 54  enum outt {
Line 53  enum outt {
   
 struct  curparse {  struct  curparse {
         struct mparse    *mp;          struct mparse    *mp;
         const char       *file;         /* current file-name */  
         enum mandoclevel  wlevel;       /* ignore messages below this */          enum mandoclevel  wlevel;       /* ignore messages below this */
         int               wstop;        /* stop after a file with a warning */          int               wstop;        /* stop after a file with a warning */
         enum outt         outtype;      /* which output to use */          enum outt         outtype;      /* which output to use */
Line 75  static const char * const mandoclevels[MANDOCLEVEL_MAX
Line 73  static const char * const mandoclevels[MANDOCLEVEL_MAX
         "SYSERR"          "SYSERR"
 };  };
   
 static  const enum mandocerr    mandoclimits[MANDOCLEVEL_MAX] = {  
         MANDOCERR_OK,  
         MANDOCERR_WARNING,  
         MANDOCERR_WARNING,  
         MANDOCERR_ERROR,  
         MANDOCERR_FATAL,  
         MANDOCERR_MAX,  
         MANDOCERR_MAX  
 };  
   
 static  const char * const      mandocerrs[MANDOCERR_MAX] = {  static  const char * const      mandocerrs[MANDOCERR_MAX] = {
         "ok",          "ok",
   
Line 180  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 168  static const char * const mandocerrs[MANDOCERR_MAX] = 
   
         "generic fatal error",          "generic fatal error",
   
           "not a manual",
         "column syntax is inconsistent",          "column syntax is inconsistent",
         "NOT IMPLEMENTED: .Bd -file",          "NOT IMPLEMENTED: .Bd -file",
         "line scope broken, syntax violated",          "line scope broken, syntax violated",
Line 192  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 181  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "static buffer exhausted",          "static buffer exhausted",
 };  };
   
 static  void              evt_close(void *, const char *);  
 static  int               evt_open(void *, const char *);  
 static  int               moptions(enum mparset *, char *);  static  int               moptions(enum mparset *, char *);
 static  void              mmsg(enum mandocerr, void *,  static  void              mmsg(enum mandocerr, enum mandoclevel,
                                 int, int, const char *);                                  const char *, int, int, const char *);
 static  void              parse(struct curparse *, int,  static  void              parse(struct curparse *, int,
                                 const char *, enum mandoclevel *);                                  const char *, enum mandoclevel *);
 static  int               toptions(struct curparse *, char *);  static  int               toptions(struct curparse *, char *);
Line 253  main(int argc, char *argv[])
Line 240  main(int argc, char *argv[])
                         /* NOTREACHED */                          /* NOTREACHED */
                 }                  }
   
         curp.mp = mparse_alloc(type, evt_open, evt_close, mmsg, &curp);          curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp);
   
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
Line 303  usage(void)
Line 290  usage(void)
         exit((int)MANDOCLEVEL_BADARG);          exit((int)MANDOCLEVEL_BADARG);
 }  }
   
 static int  
 evt_open(void *arg, const char *file)  
 {  
   
         evt_close(arg, file);  
         return(1);  
 }  
   
 static void  static void
 evt_close(void *arg, const char *file)  
 {  
         struct curparse *p;  
   
         p = (struct curparse *)arg;  
         p->file = file;  
 }  
   
 static void  
 parse(struct curparse *curp, int fd,  parse(struct curparse *curp, int fd,
                 const char *file, enum mandoclevel *level)                  const char *file, enum mandoclevel *level)
 {  {
Line 501  woptions(struct curparse *curp, char *arg)
Line 471  woptions(struct curparse *curp, char *arg)
 }  }
   
 static void  static void
 mmsg(enum mandocerr t, void *arg, int ln, int col, const char *msg)  mmsg(enum mandocerr t, enum mandoclevel lvl,
                   const char *file, int line, int col, const char *msg)
 {  {
         struct curparse *cp;  
         enum mandoclevel level;  
   
         level = MANDOCLEVEL_FATAL;          fprintf(stderr, "%s:%d:%d: %s: %s",
         while (t < mandoclimits[level])                          file, line, col + 1,
                 /* LINTED */                          mandoclevels[lvl], mandocerrs[t]);
                 level--;  
   
         cp = (struct curparse *)arg;  
         if (level < cp->wlevel)  
                 return;  
   
         fprintf(stderr, "%s:%d:%d: %s: %s", cp->file, ln, col + 1,  
                         mandoclevels[level], mandocerrs[t]);  
   
         if (msg)          if (msg)
                 fprintf(stderr, ": %s", msg);                  fprintf(stderr, ": %s", msg);
   
         fputc('\n', stderr);          fputc('\n', stderr);
   
         mparse_setstatus(cp->mp, level);  
 }  }

Legend:
Removed from v.1.154  
changed lines
  Added in v.1.158

CVSweb