- Normalize the 'Swig_error' calls and formats, before some
of the strings start like "Error. XXX", others like "XXX". The format is now defined in 'error.c:Swig_error_msg_format()'. - Normalize the multiline error/warning messages to correctly use -Fformat definition. - Centralize the error/warning format definitions in 'error.c:Swig_error_msg_format()'. - Fix a minor error in cpp.c, that after finding an error, still was emitting a redefined macro, producing duplicated error/warning messages in parser.y. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5635 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
74d6f1eb43
commit
bd9aa0c7c9
8 changed files with 65 additions and 41 deletions
|
|
@ -45,6 +45,12 @@ static String *filter = 0; /* Warning filter */
|
|||
static int warnall = 0;
|
||||
static int nwarning = 0;
|
||||
|
||||
static int init_fmt = 0;
|
||||
static char wrn_wnum_fmt[64];
|
||||
static char wrn_nnum_fmt[64];
|
||||
static char err_line_fmt[64];
|
||||
static char err_eof_fmt[64];
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_warning()
|
||||
*
|
||||
|
|
@ -58,6 +64,7 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
|||
int wrn = 1;
|
||||
va_list ap;
|
||||
if (silence) return;
|
||||
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||
|
||||
va_start(ap,fmt);
|
||||
|
||||
|
|
@ -90,25 +97,9 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
|||
}
|
||||
if (warnall || wrn) {
|
||||
if (wnum) {
|
||||
switch (msg_format) {
|
||||
case EMF_MICROSOFT:
|
||||
Printf(stderr,"%s(%d): Warning(%d): ", filename, line, wnum);
|
||||
break;
|
||||
case EMF_STANDARD:
|
||||
default:
|
||||
Printf(stderr,"%s:%d: Warning(%d): ", filename, line, wnum);
|
||||
break;
|
||||
}
|
||||
Printf(stderr, wrn_wnum_fmt, filename, line, wnum);
|
||||
} else {
|
||||
switch (msg_format) {
|
||||
case EMF_MICROSOFT:
|
||||
Printf(stderr,"%s(%d): Warning: ", filename, line);
|
||||
break;
|
||||
case EMF_STANDARD:
|
||||
default:
|
||||
Printf(stderr,"%s:%d: Warning: ", filename, line);
|
||||
break;
|
||||
}
|
||||
Printf(stderr, wrn_nnum_fmt, filename, line);
|
||||
}
|
||||
Printf(stderr,"%s",msg);
|
||||
nwarning++;
|
||||
|
|
@ -130,20 +121,13 @@ Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
|
|||
va_list ap;
|
||||
|
||||
if (silence) return;
|
||||
|
||||
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||
|
||||
va_start(ap,fmt);
|
||||
if (line > 0) {
|
||||
switch (msg_format) {
|
||||
case EMF_MICROSOFT:
|
||||
Printf(stderr,"%s(%d): ", filename, line);
|
||||
break;
|
||||
case EMF_STANDARD:
|
||||
default:
|
||||
Printf(stderr,"%s:%d: ", filename, line);
|
||||
break;
|
||||
}
|
||||
Printf(stderr, err_line_fmt, filename, line);
|
||||
} else {
|
||||
Printf(stderr,"%s:EOF: ", filename);
|
||||
Printf(stderr, err_eof_fmt, filename);
|
||||
}
|
||||
vPrintf(stderr,fmt,ap);
|
||||
va_end(ap);
|
||||
|
|
@ -235,5 +219,28 @@ Swig_warn_count(void) {
|
|||
|
||||
void
|
||||
Swig_error_msg_format(ErrorMessageFormat format) {
|
||||
const char* error = "Error";
|
||||
const char* warning = "Warning";
|
||||
|
||||
const char* fmt_eof = "%s:EOF";
|
||||
|
||||
/* here 'format' could be directly a string instead of an enum, but
|
||||
by now a switch is used to translated into one. */
|
||||
const char* fmt_line = 0;
|
||||
switch (format) {
|
||||
case EMF_MICROSOFT:
|
||||
fmt_line = "%s(%d)";
|
||||
break;
|
||||
case EMF_STANDARD:
|
||||
default:
|
||||
fmt_line = "%s:%d";
|
||||
}
|
||||
|
||||
sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning);
|
||||
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
|
||||
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
|
||||
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
|
||||
|
||||
msg_format = format;
|
||||
init_fmt = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue