From: <wsf...@us...> - 2009-12-24 16:51:52
|
Revision: 11800 http://swig.svn.sourceforge.net/swig/?rev=11800&view=rev Author: wsfulton Date: 2009-12-24 16:51:45 +0000 (Thu, 24 Dec 2009) Log Message: ----------- Add Swig_diagnostic() for displaying file and line number messages to stdout Modified Paths: -------------- trunk/Source/Swig/error.c trunk/Source/Swig/swig.h Modified: trunk/Source/Swig/error.c =================================================================== --- trunk/Source/Swig/error.c 2009-12-24 15:53:01 UTC (rev 11799) +++ trunk/Source/Swig/error.c 2009-12-24 16:51:45 UTC (rev 11800) @@ -49,13 +49,15 @@ static char wrn_nnum_fmt[64]; static char err_line_fmt[64]; static char err_eof_fmt[64]; +static char diag_line_fmt[64]; +static char diag_eof_fmt[64]; static String *format_filename(const_String_or_char_ptr filename); /* ----------------------------------------------------------------------------- * Swig_warning() * - * Issue a warning message + * Issue a warning message on stderr. * ----------------------------------------------------------------------------- */ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) { @@ -118,7 +120,7 @@ /* ----------------------------------------------------------------------------- * Swig_error() * - * Issue an error message + * Issue an error message on stderr. * ----------------------------------------------------------------------------- */ void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) { @@ -258,6 +260,8 @@ 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); + sprintf(diag_line_fmt, "%s: ", fmt_line); + sprintf(diag_eof_fmt, "%s: ", fmt_eof); msg_format = format; init_fmt = 1; @@ -275,3 +279,29 @@ #endif return formatted_filename; } + +/* ----------------------------------------------------------------------------- + * Swig_diagnostic() + * + * Issue a diagnostic message on stdout. + * ----------------------------------------------------------------------------- */ + +void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...) { + va_list ap; + String *formatted_filename = NULL; + + if (!init_fmt) + Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); + + va_start(ap, fmt); + formatted_filename = format_filename(filename); + if (line > 0) { + Printf(stdout, diag_line_fmt, formatted_filename, line); + } else { + Printf(stdout, diag_eof_fmt, formatted_filename); + } + vPrintf(stdout, fmt, ap); + va_end(ap); + Delete(formatted_filename); +} + Modified: trunk/Source/Swig/swig.h =================================================================== --- trunk/Source/Swig/swig.h 2009-12-24 15:53:01 UTC (rev 11799) +++ trunk/Source/Swig/swig.h 2009-12-24 16:51:45 UTC (rev 11800) @@ -319,6 +319,7 @@ extern void Swig_warnall(void); extern int Swig_warn_count(void); extern void Swig_error_msg_format(ErrorMessageFormat format); + extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...); /* --- C Wrappers --- */ extern String *Swig_cparm_name(Parm *p, int i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |