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

Diff for /mandoc/mandoc_msg.c between version 1.1 and 1.8

version 1.1, 2018/12/14 01:18:26 version 1.8, 2019/07/14 18:16:13
Line 1 
Line 1 
 /*      $OpenBSD$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 15 
Line 15 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #include "config.h"
   
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 27  static const enum mandocerr lowest_type[MANDOCLEVEL_MA
Line 29  static const enum mandocerr lowest_type[MANDOCLEVEL_MA
         MANDOCERR_WARNING,          MANDOCERR_WARNING,
         MANDOCERR_ERROR,          MANDOCERR_ERROR,
         MANDOCERR_UNSUPP,          MANDOCERR_UNSUPP,
         MANDOCERR_MAX,          MANDOCERR_BADARG,
         MANDOCERR_MAX          MANDOCERR_SYSERR
 };  };
   
 static  const char *const level_name[MANDOCLEVEL_MAX] = {  static  const char *const level_name[MANDOCLEVEL_MAX] = {
Line 167  static const char *const type_message[MANDOCERR_MAX] =
Line 169  static const char *const type_message[MANDOCERR_MAX] =
         "tab in filled text",          "tab in filled text",
         "new sentence, new line",          "new sentence, new line",
         "invalid escape sequence",          "invalid escape sequence",
           "undefined escape, printing literally",
         "undefined string, using \"\"",          "undefined string, using \"\"",
   
         /* related to tables */          /* related to tables */
Line 190  static const char *const type_message[MANDOCERR_MAX] =
Line 193  static const char *const type_message[MANDOCERR_MAX] =
         "data block open at end of tbl",          "data block open at end of tbl",
   
         /* related to document structure and macros */          /* related to document structure and macros */
         NULL,  
         "duplicate prologue macro",          "duplicate prologue macro",
         "skipping late title macro",          "skipping late title macro",
         "input stack limit exceeded, infinite loop?",          "input stack limit exceeded, infinite loop?",
Line 228  static const char *const type_message[MANDOCERR_MAX] =
Line 230  static const char *const type_message[MANDOCERR_MAX] =
         "unsupported feature",          "unsupported feature",
         "input too large",          "input too large",
         "unsupported control character",          "unsupported control character",
           "unsupported escape sequence",
         "unsupported roff request",          "unsupported roff request",
         "nested .while loops",          "nested .while loops",
         "end of scope with open .while loop",          "end of scope with open .while loop",
Line 236  static const char *const type_message[MANDOCERR_MAX] =
Line 239  static const char *const type_message[MANDOCERR_MAX] =
         "eqn delim option in tbl",          "eqn delim option in tbl",
         "unsupported tbl layout modifier",          "unsupported tbl layout modifier",
         "ignoring macro in table",          "ignoring macro in table",
   
           /* bad command line arguments */
           NULL,
           "bad command line argument",
           "duplicate command line argument",
           "option has a superfluous value",
           "missing option value",
           "bad option value",
           "duplicate option value",
           "no such tag",
   
           /* system errors */
           NULL,
           "dup",
           "exec",
           "fdopen",
           "fflush",
           "fork",
           "fstat",
           "getline",
           "glob",
           "gzclose",
           "gzdopen",
           "mkstemp",
           "open",
           "pledge",
           "read",
           "wait",
           "write",
 };  };
   
 static  FILE            *fileptr = stderr;  static  FILE            *fileptr = NULL;
 static  const char      *filename = NULL;  static  const char      *filename = NULL;
 static  enum mandocerr   min_type = MANDOCERR_MAX;  static  enum mandocerr   min_type = MANDOCERR_BADARG;
 static  enum mandoclevel rc = MANDOCLEVEL_OK;  static  enum mandoclevel rc = MANDOCLEVEL_OK;
   
   
Line 288  mandoc_msg_setrc(enum mandoclevel level)
Line 320  mandoc_msg_setrc(enum mandoclevel level)
 }  }
   
 void  void
 mandoc_vmsg(enum mandocerr t, void *dummy, int line, int col,  mandoc_msg(enum mandocerr t, int line, int col, const char *fmt, ...)
     const char *fmt, ...)  
 {  {
         va_list                  ap;          va_list                  ap;
         enum mandoclevel         level;          enum mandoclevel         level;
   
         if (t < min_type && t != MANDOCERR_FILE)          if (t < min_type)
                 return;                  return;
   
         level = MANDOCLEVEL_UNSUPP;          level = MANDOCLEVEL_SYSERR;
         while (t < lowest_type[level])          while (t < lowest_type[level])
                 level--;                  level--;
         mandoc_msg_setrc(level);          mandoc_msg_setrc(level);
Line 326  mandoc_vmsg(enum mandocerr t, void *dummy, int line, i
Line 357  mandoc_vmsg(enum mandocerr t, void *dummy, int line, i
 }  }
   
 void  void
 mandoc_msg(enum mandocerr t, void *dummy, int line, int col, const char *msg)  mandoc_msg_summary(void)
 {  {
         if (msg == NULL)          if (fileptr != NULL && rc != MANDOCLEVEL_OK)
                 mandoc_vmsg(t, dummy, line, col, NULL);                  fprintf(fileptr,
         else                      "%s: see above the output for %s messages\n",
                 mandoc_vmsg(t, dummy, line, col, "%s", msg);                      getprogname(), level_name[rc]);
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

CVSweb