Mercurial > hg > octave-nkf
diff src/mex.cc @ 6338:ec88b4ab6d10
[project @ 2007-02-22 07:07:19 by jwe]
author | jwe |
---|---|
date | Thu, 22 Feb 2007 07:07:20 +0000 |
parents | debb662eab07 |
children | e40a46a100b6 |
line wrap: on
line diff
--- a/src/mex.cc +++ b/src/mex.cc @@ -3124,10 +3124,19 @@ } void -mexErrMsgIdAndTxt (const char *id, const char *s) +mexErrMsgIdAndTxt (const char *id, const char *fmt, ...) { - if (s && strlen (s) > 0) - error_with_id (id, "%s: %s", mexFunctionName (), s); + if (fmt && strlen (fmt) > 0) + { + const char *fname = mexFunctionName (); + size_t len = strlen (fname) + 2 + strlen (fmt) + 1; + OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); + sprintf (tmpfmt, "%s: %s", fname, fmt); + va_list args; + va_start (args, fmt); + verror_with_id (id, tmpfmt, args); + va_end (args); + } else // Just set the error state; don't print msg. error (""); @@ -3142,9 +3151,22 @@ } void -mexWarnMsgIdAndTxt (const char *id, const char *s) +mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...) { - warning_with_id (id, "%s", s); + // FIXME -- is this right? What does Matlab do if fmt is NULL or + // an empty string? + + if (fmt && strlen (fmt) > 0) + { + const char *fname = mexFunctionName (); + size_t len = strlen (fname) + 2 + strlen (fmt) + 1; + OCTAVE_LOCAL_BUFFER (char, tmpfmt, len); + sprintf (tmpfmt, "%s: %s", fname, fmt); + va_list args; + va_start (args, fmt); + vwarning_with_id (id, tmpfmt, args); + va_end (args); + } } void