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

Diff for /mandoc/main.c between version 1.93 and 1.94

version 1.93, 2010/06/29 14:53:14 version 1.94, 2010/06/30 20:32:15
Line 99  struct curparse {
Line 99  struct curparse {
   
 static  const char * const      mandocerrs[MANDOCERR_MAX] = {  static  const char * const      mandocerrs[MANDOCERR_MAX] = {
         "ok",          "ok",
   
           "generic warning",
   
         "text should be uppercase",          "text should be uppercase",
         "sections out of conventional order",          "sections out of conventional order",
         "section name repeats",          "section name repeats",
Line 118  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 121  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "section not in conventional manual section",          "section not in conventional manual section",
         "end of line whitespace",          "end of line whitespace",
         "scope open on exit",          "scope open on exit",
   
           "generic error",
   
         "NAME section must come first",          "NAME section must come first",
         "bad Boolean value",          "bad Boolean value",
         "child violates parent syntax",          "child violates parent syntax",
Line 149  static const char * const mandocerrs[MANDOCERR_MAX] = 
Line 155  static const char * const mandocerrs[MANDOCERR_MAX] = 
         "missing display type",          "missing display type",
         "line argument(s) will be lost",          "line argument(s) will be lost",
         "body argument(s) will be lost",          "body argument(s) will be lost",
   
           "generic fatal error",
   
         "column syntax is inconsistent",          "column syntax is inconsistent",
         "missing font type",          "missing font type",
         "displays may not be nested",          "displays may not be nested",
Line 182  static void    version(void) __attribute__((noreturn))
Line 191  static void    version(void) __attribute__((noreturn))
 static  int               woptions(int *, char *);  static  int               woptions(int *, char *);
   
 static  const char       *progname;  static  const char       *progname;
 static  int               with_error;  static  int               with_fatal;
 static  int               with_warning;  static  int               with_error;
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
Line 246  main(int argc, char *argv[])
Line 255  main(int argc, char *argv[])
         while (*argv) {          while (*argv) {
                 ffile(*argv, &curp);                  ffile(*argv, &curp);
   
                 if (with_error && !(curp.fflags & FL_IGN_ERRORS))                  if (with_fatal && !(curp.fflags & FL_IGN_ERRORS))
                         break;                          break;
                 ++argv;                  ++argv;
         }          }
Line 260  main(int argc, char *argv[])
Line 269  main(int argc, char *argv[])
         if (curp.roff)          if (curp.roff)
                 roff_free(curp.roff);                  roff_free(curp.roff);
   
         return((with_warning || with_error) ?          return((with_fatal || with_error) ?
                         EXIT_FAILURE :  EXIT_SUCCESS);                          EXIT_FAILURE :  EXIT_SUCCESS);
 }  }
   
Line 338  ffile(const char *file, struct curparse *curp)
Line 347  ffile(const char *file, struct curparse *curp)
         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))) {
                 perror(curp->file);                  perror(curp->file);
                 with_error = 1;                  with_fatal = 1;
                 return;                  return;
         }          }
   
Line 379  read_whole_file(struct curparse *curp, struct buf *fb,
Line 388  read_whole_file(struct curparse *curp, struct buf *fb,
   
         if (-1 == fstat(curp->fd, &st)) {          if (-1 == fstat(curp->fd, &st)) {
                 perror(curp->file);                  perror(curp->file);
                 with_error = 1;                  with_fatal = 1;
                 return(0);                  return(0);
         }          }
   
Line 394  read_whole_file(struct curparse *curp, struct buf *fb,
Line 403  read_whole_file(struct curparse *curp, struct buf *fb,
                 if (st.st_size >= (1U << 31)) {                  if (st.st_size >= (1U << 31)) {
                         fprintf(stderr, "%s: input too large\n",                          fprintf(stderr, "%s: input too large\n",
                                         curp->file);                                          curp->file);
                         with_error = 1;                          with_fatal = 1;
                         return(0);                          return(0);
                 }                  }
                 *with_mmap = 1;                  *with_mmap = 1;
Line 438  read_whole_file(struct curparse *curp, struct buf *fb,
Line 447  read_whole_file(struct curparse *curp, struct buf *fb,
   
         free(fb->buf);          free(fb->buf);
         fb->buf = NULL;          fb->buf = NULL;
         with_error = 1;          with_fatal = 1;
         return(0);          return(0);
 }  }
   
Line 654  fdesc(struct curparse *curp)
Line 663  fdesc(struct curparse *curp)
         return;          return;
   
  bailout:   bailout:
         with_error = 1;          with_fatal = 1;
         goto cleanup;          goto cleanup;
 }  }
   
Line 839  static int
Line 848  static int
 mmsg(enum mandocerr t, void *arg, int ln, int col, const char *msg)  mmsg(enum mandocerr t, void *arg, int ln, int col, const char *msg)
 {  {
         struct curparse *cp;          struct curparse *cp;
           const char *level;
           int rc;
   
         cp = (struct curparse *)arg;          cp = (struct curparse *)arg;
           level = NULL;
           rc = 1;
   
         if (t <= MANDOCERR_ERROR) {          if (t >= MANDOCERR_FATAL) {
                 if ( ! (cp->wflags & WARN_WALL))                  with_fatal = 1;
                   level = "FATAL";
                   rc = 0;
           } else {
                   if ( ! (WARN_WALL & cp->wflags))
                         return(1);                          return(1);
                 with_warning = 1;                  if (t >= MANDOCERR_ERROR) {
         } else                          with_error = 1;
                 with_error = 1;                          level = "ERROR";
                   }
                   if (WARN_WERR & cp->wflags) {
                           with_fatal = 1;
                           rc = 0;
                   }
           }
   
         fprintf(stderr, "%s:%d:%d: %s", cp->file,          fprintf(stderr, "%s:%d:%d:", cp->file, ln, col + 1);
                         ln, col + 1, mandocerrs[t]);          if (level)
                   fprintf(stderr, " %s:", level);
           fprintf(stderr, " %s", mandocerrs[t]);
         if (msg)          if (msg)
                 fprintf(stderr, ": %s", msg);                  fprintf(stderr, ": %s", msg);
   
         fputc('\n', stderr);          fputc('\n', stderr);
   
         /* This is superfluous, but whatever. */          return(rc);
         if (t > MANDOCERR_ERROR)  
                 return(0);  
         if (cp->wflags & WARN_WERR) {  
                 with_error = 1;  
                 return(0);  
         }  
         return(1);  
 }  }

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.94

CVSweb