Warning and error messages output is selectable via commandline options

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5613 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-01-10 00:08:18 +00:00
commit e684591411
6 changed files with 117 additions and 29 deletions

View file

@ -48,7 +48,7 @@ extern "C" {
extern String *ModuleName;
}
static char *usage = (char*)"\
static const char *usage1 = (const char*)"\
\nGeneral Options\n\
-c++ - Enable C++ processing\n\
-co - Check a file out of the SWIG library\n\
@ -57,6 +57,8 @@ static char *usage = (char*)"\
-E - Preprocess only, does not generate wrapper code\n\
-fcompact - Compile in compact mode\n\
-fvirtual - Compile in virtual elimination mode\n\
-Fstandard - Display error/warning messages in commonly used format\n\
-Fmicrosoft - Display error/warning messages in Microsoft format\n\
-help - This output\n\
-I<dir> - Look for SWIG files in <dir>\n\
-ignoremissing - Ignore missing include files\n\
@ -65,6 +67,9 @@ static char *usage = (char*)"\
-l<ifile> - Include SWIG library file <ifile>\n\
-M - List all dependencies \n\
-MM - List dependencies, but omit files in SWIG library\n\
";
// usage string split in two otherwise string is too big for some compilers
static const char *usage2 = (const char*)"\
-makedefault - Create default constructors/destructors (the default)\n\
-module <name> - Set module name to <name>\n\
-nocontract - Turn off contract checking \n\
@ -484,8 +489,15 @@ int SWIG_main(int argc, char *argv[], Language *l) {
} else if (strcmp(argv[i],"-dump_memory") == 0) {
memory_debug =1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-Fstandard") == 0) {
Swig_error_msg_format(EMF_STANDARD);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-Fmicrosoft") == 0) {
Swig_error_msg_format(EMF_MICROSOFT);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
fputs(usage1,stderr);
fputs(usage2,stderr);
Swig_mark_arg(i);
help = 1;
}

View file

@ -34,10 +34,16 @@ char cvsroot_error_c[] = "$Header$";
* is reenabled.
* ----------------------------------------------------------------------------- */
#if defined(_WIN32)
# define DEFAULT_ERROR_MSG_FORMAT EMF_MICROSOFT
#else
# define DEFAULT_ERROR_MSG_FORMAT EMF_STANDARD
#endif
static ErrorMessageFormat msg_format = DEFAULT_ERROR_MSG_FORMAT;
static int silence = 0; /* Silent operation */
static String *filter = 0; /* Warning filter */
static int warnall = 0;
static int nwarning = 0;
static int nwarning = 0;
/* -----------------------------------------------------------------------------
* Swig_warning()
@ -84,9 +90,25 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
}
if (warnall || wrn) {
if (wnum) {
Printf(stderr,"%s:%d: Warning(%d): ", filename, line, 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;
}
} else {
Printf(stderr,"%s:%d: Warning: ", filename, line, wnum);
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,"%s",msg);
nwarning++;
@ -111,7 +133,15 @@ Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
va_start(ap,fmt);
if (line > 0) {
Printf(stderr,"%s:%d: ", filename, line);
switch (msg_format) {
case EMF_MICROSOFT:
Printf(stderr,"%s(%d): ", filename, line);
break;
case EMF_STANDARD:
default:
Printf(stderr,"%s:%d: ", filename, line);
break;
}
} else {
Printf(stderr,"%s:EOF: ", filename);
}
@ -197,3 +227,13 @@ Swig_warn_count(void) {
return nwarning;
}
/* -----------------------------------------------------------------------------
* Swig_error_msg_format()
*
* Set the type of error/warning message display
* ----------------------------------------------------------------------------- */
void
Swig_error_msg_format(ErrorMessageFormat format) {
msg_format = format;
}

View file

@ -415,6 +415,8 @@ extern void Swig_warn(const char *filename, int line, const char *msg);
#define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg)
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
extern int Swig_error_count(void);
@ -422,6 +424,7 @@ extern void Swig_error_silent(int s);
extern void Swig_warnfilter(const String_or_char *wlist, int val);
extern void Swig_warnall(void);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
/* --- C Wrappers --- */
extern String *Swig_cparm_name(Parm *p, int i);