Mercurial > octave-nkf
changeset 19444:95c533ed464b
use warning IDs for all warnings in liboctave
* CSparse.cc, MatrixType.cc, Sparse.cc, dSparse.cc, dbleQR.cc,
eigs-base.cc, lo-specfun.cc, cmd-hist.cc, data-conv.cc, kpse.cc,
lo-regexp.cc, oct-locbuf.cc, oct-shlib.cc, sparse-util.cc:
Use current_liboctave_warning_with_id_handler and provide warning IDs
for all warnings in liboctave code.
* unwinddemo.cc: Also preserve and restore warning_wit_id_handler.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 18 Dec 2014 10:50:09 -0500 |
parents | cfe56baccb0c |
children | 78e424d31596 |
files | examples/code/unwinddemo.cc liboctave/array/CSparse.cc liboctave/array/MatrixType.cc liboctave/array/Sparse.cc liboctave/array/dSparse.cc liboctave/numeric/dbleQR.cc liboctave/numeric/eigs-base.cc liboctave/numeric/lo-specfun.cc liboctave/util/cmd-hist.cc liboctave/util/data-conv.cc liboctave/util/kpse.cc liboctave/util/lo-regexp.cc liboctave/util/oct-locbuf.cc liboctave/util/oct-shlib.cc liboctave/util/sparse-util.cc |
diffstat | 15 files changed, 163 insertions(+), 130 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/code/unwinddemo.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/examples/code/unwinddemo.cc Thu Dec 18 10:50:09 2014 -0500 @@ -7,6 +7,12 @@ // Do nothing!! } +void +my_err_with_id_handler (const char *id, const char *fmt, ...) +{ + // Do nothing!! +} + DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo") { octave_value retval; @@ -24,11 +30,18 @@ // Declare unwind_protect frame which lasts as long as // the variable frame has scope. unwind_protect frame; - frame.protect_var (current_liboctave_warning_handler); + frame.add_fcn (set_liboctave_warning_handler, + current_liboctave_warning_handler); + + frame.add_fcn (set_liboctave_warning_with_id_handler, + current_liboctave_warning_with_id_handler); set_liboctave_warning_handler (my_err_handler); + set_liboctave_warning_with_id_handler (my_err_with_id_handler); + retval = octave_value (quotient (a, b)); } } + return retval; }
--- a/liboctave/array/CSparse.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/array/CSparse.cc Thu Dec 18 10:50:09 2014 -0500 @@ -5725,8 +5725,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full; @@ -5982,8 +5982,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full; @@ -6255,8 +6255,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full; @@ -6491,8 +6491,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full;
--- a/liboctave/array/MatrixType.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/array/MatrixType.cc Thu Dec 18 10:50:09 2014 -0500 @@ -38,6 +38,27 @@ #include "oct-spparms.h" #include "oct-locbuf.h" +static void +warn_cached (void) +{ + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "using cached matrix type"); +} + +static void +warn_invalid (void) +{ + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "invalid matrix type"); +} + +static void +warn_calculating_sparse_type (void) +{ + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "calculating sparse matrix type"); +} + // FIXME: There is a large code duplication here MatrixType::MatrixType (void) @@ -221,8 +242,7 @@ octave_idx_type nnz = a.nnz (); if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Calculating Sparse Matrix Type"); + warn_calculating_sparse_type (); sp_bandden = octave_sparse_params::get_bandden (); bool maybe_hermitian = false; @@ -540,8 +560,7 @@ octave_idx_type nnz = a.nnz (); if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Calculating Sparse Matrix Type"); + warn_calculating_sparse_type (); sp_bandden = octave_sparse_params::get_bandden (); bool maybe_hermitian = false; @@ -861,7 +880,7 @@ || t == MatrixType::Rectangular) typ = t; else - (*current_liboctave_warning_handler) ("Invalid matrix type"); + warn_invalid (); } MatrixType::MatrixType (const matrix_type t, const octave_idx_type np, @@ -881,7 +900,7 @@ perm[i] = p[i]; } else - (*current_liboctave_warning_handler) ("Invalid matrix type"); + warn_invalid (); } MatrixType::MatrixType (const matrix_type t, const octave_idx_type ku, @@ -898,7 +917,7 @@ lower_band = kl; } else - (*current_liboctave_warning_handler) ("Invalid sparse matrix type"); + warn_invalid (); } MatrixType::~MatrixType (void) @@ -948,16 +967,15 @@ { if (!quiet && octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } if (typ != MatrixType::Unknown && octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Invalidating Matrix Type"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "invalidating matrix type"); typ = MatrixType::Unknown; @@ -971,8 +989,7 @@ && (full || sp_bandden == octave_sparse_params::get_bandden ())) { if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } @@ -1004,8 +1021,7 @@ && (full || sp_bandden == octave_sparse_params::get_bandden ())) { if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } @@ -1036,8 +1052,7 @@ if (typ != MatrixType::Unknown) { if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } @@ -1063,8 +1078,7 @@ if (typ != MatrixType::Unknown) { if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } @@ -1090,8 +1104,7 @@ if (typ != MatrixType::Unknown) { if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } @@ -1117,8 +1130,7 @@ if (typ != MatrixType::Unknown) { if (octave_sparse_params::get_key ("spumoni") != 0.) - (*current_liboctave_warning_handler) - ("Using Cached Matrix Type"); + warn_cached (); return typ; } @@ -1144,49 +1156,52 @@ if (octave_sparse_params::get_key ("spumoni") != 0.) { if (typ == MatrixType::Unknown) - (*current_liboctave_warning_handler) - ("Unknown Matrix Type"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "unknown matrix type"); else if (typ == MatrixType::Diagonal) - (*current_liboctave_warning_handler) - ("Diagonal Sparse Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "diagonal sparse matrix"); else if (typ == MatrixType::Permuted_Diagonal) - (*current_liboctave_warning_handler) - ("Permuted Diagonal Sparse Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "permuted diagonal sparse matrix"); else if (typ == MatrixType::Upper) - (*current_liboctave_warning_handler) - ("Upper Triangular Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "upper triangular matrix"); else if (typ == MatrixType::Lower) - (*current_liboctave_warning_handler) - ("Lower Triangular Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "lower triangular matrix"); else if (typ == MatrixType::Permuted_Upper) - (*current_liboctave_warning_handler) - ("Permuted Upper Triangular Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "permuted upper triangular matrix"); else if (typ == MatrixType::Permuted_Lower) - (*current_liboctave_warning_handler) - ("Permuted Lower Triangular Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "permuted lower triangular Matrix"); else if (typ == MatrixType::Banded) - (*current_liboctave_warning_handler) - ("Banded Sparse Matrix %d-1-%d (Density %f)", lower_band, - upper_band, bandden); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", + "banded sparse matrix %d-1-%d (density %f)", + lower_band, upper_band, bandden); else if (typ == MatrixType::Banded_Hermitian) - (*current_liboctave_warning_handler) - ("Banded Hermitian/Symmetric Sparse Matrix %d-1-%d (Density %f)", + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", + "banded hermitian/symmetric sparse matrix %d-1-%d (density %f)", lower_band, upper_band, bandden); else if (typ == MatrixType::Hermitian) - (*current_liboctave_warning_handler) - ("Hermitian/Symmetric Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "hermitian/symmetric matrix"); else if (typ == MatrixType::Tridiagonal) - (*current_liboctave_warning_handler) - ("Tridiagonal Sparse Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "tridiagonal sparse matrix"); else if (typ == MatrixType::Tridiagonal_Hermitian) - (*current_liboctave_warning_handler) - ("Hermitian/Symmetric Tridiagonal Sparse Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", + "hermitian/symmetric tridiagonal sparse matrix"); else if (typ == MatrixType::Rectangular) - (*current_liboctave_warning_handler) - ("Rectangular/Singular Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "rectangular/singular matrix"); else if (typ == MatrixType::Full) - (*current_liboctave_warning_handler) - ("Full Matrix"); + (*current_liboctave_warning_with_id_handler) + ("Octave:matrix-type-info", "full matrix"); } }
--- a/liboctave/array/Sparse.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/array/Sparse.cc Thu Dec 18 10:50:09 2014 -0500 @@ -819,8 +819,9 @@ if (dims2.length () > 2) { - (*current_liboctave_warning_handler) - ("reshape: sparse reshape to N-d array smashes dims"); + (*current_liboctave_warning_with_id_handler) + ("Octave:reshape-smashes-dims", + "reshape: sparse reshape to N-d array smashes dims"); for (octave_idx_type i = 2; i < dims2.length (); i++) dims2(1) *= dims2(i);
--- a/liboctave/array/dSparse.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/array/dSparse.cc Thu Dec 18 10:50:09 2014 -0500 @@ -5920,8 +5920,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full; @@ -6149,8 +6149,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full; @@ -6394,8 +6394,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full; @@ -6642,8 +6642,8 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } #else - (*current_liboctave_warning_handler) - ("CHOLMOD not installed"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", "CHOLMOD not installed"); mattype.mark_as_unsymmetric (); typ = MatrixType::Full;
--- a/liboctave/numeric/dbleQR.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/numeric/dbleQR.cc Thu Dec 18 10:50:09 2014 -0500 @@ -703,11 +703,13 @@ static bool warned = false; if (! warned) { - (*current_liboctave_warning_handler) - ("In this version of Octave, QR & Cholesky updating routines\n" - "simply update the matrix and recalculate factorizations.\n" - "To use fast algorithms, link Octave with the qrupdate library.\n" - "See <http://sourceforge.net/projects/qrupdate>.\n"); + (*current_liboctave_warning_with_id_handler) + ("Octave:missing-dependency", + "In this version of Octave, QR & Cholesky updating routines " + "simply update the matrix and recalculate factorizations. " + "To use fast algorithms, link Octave with the qrupdate library. " + "See <http://sourceforge.net/projects/qrupdate>."); + warned = true; } }
--- a/liboctave/numeric/eigs-base.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/numeric/eigs-base.cc Thu Dec 18 10:50:09 2014 -0500 @@ -207,6 +207,15 @@ #endif +static void +warn_convergence (void) +{ + (*current_liboctave_warning_with_id_handler) + ("Octave:convergence", + "eigs: 'A - sigma*B' is singular, indicating sigma is exactly " + "an eigenvalue so convergence is not guaranteed"); +} + template <class M, class SM> static octave_idx_type lusolve (const SM& L, const SM& U, M& m) @@ -508,12 +517,7 @@ volatile double rcond_plus_one = rcond + 1.0; if (rcond_plus_one == 1.0 || xisnan (rcond)) - { - (*current_liboctave_warning_handler) - ("eigs: 'A - sigma*B' is singular, indicating sigma is exactly"); - (*current_liboctave_warning_handler) - (" an eigenvalue. Convergence is not guaranteed"); - } + warn_convergence (); return true; } @@ -585,12 +589,7 @@ volatile double rcond_plus_one = rcond + 1.0; if (rcond_plus_one == 1.0 || xisnan (rcond)) - { - (*current_liboctave_warning_handler) - ("eigs: 'A - sigma*B' is singular, indicating sigma is exactly"); - (*current_liboctave_warning_handler) - (" an eigenvalue. Convergence is not guaranteed"); - } + warn_convergence (); return true; } @@ -682,12 +681,7 @@ volatile double rcond_plus_one = rcond + 1.0; if (rcond_plus_one == 1.0 || xisnan (rcond)) - { - (*current_liboctave_warning_handler) - ("eigs: 'A - sigma*B' is singular, indicating sigma is exactly"); - (*current_liboctave_warning_handler) - (" an eigenvalue. Convergence is not guaranteed"); - } + warn_convergence (); return true; } @@ -759,12 +753,7 @@ volatile double rcond_plus_one = rcond + 1.0; if (rcond_plus_one == 1.0 || xisnan (rcond)) - { - (*current_liboctave_warning_handler) - ("eigs: 'A - sigma*B' is singular, indicating sigma is exactly"); - (*current_liboctave_warning_handler) - (" an eigenvalue. Convergence is not guaranteed"); - } + warn_convergence (); return true; }
--- a/liboctave/numeric/lo-specfun.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/numeric/lo-specfun.cc Thu Dec 18 10:50:09 2014 -0500 @@ -3636,9 +3636,11 @@ if (m < 0 || m > 1) { - (*current_liboctave_warning_handler) - ("ellipj: expecting 0 <= M <= 1"); + (*current_liboctave_warning_with_id_handler) + ("Octave:ellipj-invalid-m", "ellipj: expecting 0 <= M <= 1"); + sn = cn = dn = lo_ieee_nan_value (); + return; }
--- a/liboctave/util/cmd-hist.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/cmd-hist.cc Thu Dec 18 10:50:09 2014 -0500 @@ -145,8 +145,9 @@ else if (tmp == "ignorespace") history_control |= HC_IGNSPACE; else - (*current_liboctave_warning_handler) - ("unknown histcontrol directive %s", tmp.c_str ()); + (*current_liboctave_warning_with_id_handler) + ("Octave:history-control", + "unknown histcontrol directive %s", tmp.c_str ()); if (end != std::string::npos) beg = end + 1; @@ -779,8 +780,9 @@ void command_history::do_process_histcontrol (const std::string&) { - (*current_liboctave_warning_handler) - ("readline is not linked, so history control is not available"); + (*current_liboctave_warning_with_id_handler) + ("Octave:history-control", + "readline is not linked, so history control is not available"); } void
--- a/liboctave/util/data-conv.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/data-conv.cc Thu Dec 18 10:50:09 2014 -0500 @@ -411,8 +411,9 @@ { s1 = s.substr (1, pos-1); - (*current_liboctave_warning_handler) - ("warning: ignoring leading * in fread precision"); + (*current_liboctave_warning_with_id_handler) + ("Octave:fread-precision-syntax", + "warning: ignoring leading * in fread precision"); } else s1 = s.substr (0, pos);
--- a/liboctave/util/kpse.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/kpse.cc Thu Dec 18 10:50:09 2014 -0500 @@ -1549,8 +1549,9 @@ /* What if there isn't a matching close brace? */ if (! c) { - (*current_liboctave_warning_handler) - ("%s: Unmatched {", text.c_str ()); + (*current_liboctave_warning_with_id_handler) + ("Octave:pathsearch-syntax", + "%s: Unmatched {", text.c_str ()); result = string_vector (text); } @@ -2545,8 +2546,9 @@ { if (expanding_p (var)) { - (*current_liboctave_warning_handler) - ("kpathsea: variable '%s' references itself (eventually)", + (*current_liboctave_warning_with_id_handler) + ("Octave:pathsearch-syntax", + "kpathsea: variable '%s' references itself (eventually)", var.c_str ()); } else @@ -2623,8 +2625,9 @@ if (var_end == src_len) { - (*current_liboctave_warning_handler) - ("%s: No matching } for ${", src.c_str ()); + (*current_liboctave_warning_with_id_handler) + ("Octave:pathsearch-syntax", + "%s: No matching } for ${", src.c_str ()); i = var_end - 1; /* will incr to eos at top of loop */ } else @@ -2636,8 +2639,9 @@ else { /* $<something-else>: error. */ - (*current_liboctave_warning_handler) - ("%s: Unrecognized variable construct '$%c'", + (*current_liboctave_warning_with_id_handler) + ("Octave:pathsearch-syntax", + "%s: Unrecognized variable construct '$%c'", src.c_str (), src[i]); /* Just ignore those chars and keep going. */
--- a/liboctave/util/lo-regexp.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/lo-regexp.cc Thu Dec 18 10:50:09 2014 -0500 @@ -179,8 +179,9 @@ if (!lookbehind_warned) { lookbehind_warned = true; - (*current_liboctave_warning_handler) - ("%s: arbitrary length lookbehind patterns are only supported up to length %d", + (*current_liboctave_warning_with_id_handler) + ("Octave:regexp-lookbehind-limit", + "%s: arbitrary length lookbehind patterns are only supported up to length %d", who.c_str (), MAXLOOKBEHIND); } @@ -282,8 +283,9 @@ { // Try harder; start with default value for MATCH_LIMIT // and increase it. - (*current_liboctave_warning_handler) - ("your pattern caused PCRE to hit its MATCH_LIMIT; trying harder now, but this will be slow"); + (*current_liboctave_warning_with_id_handler) + ("Octave:regexp-match-limit", + "your pattern caused PCRE to hit its MATCH_LIMIT; trying harder now, but this will be slow"); pcre_extra pe;
--- a/liboctave/util/oct-locbuf.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/oct-locbuf.cc Thu Dec 18 10:50:09 2014 -0500 @@ -140,8 +140,12 @@ } else { - (*current_liboctave_warning_handler) - ("octave_chunk_buffer::clear: %d active allocations remain!", + // FIXME: Doesn't this situation represent a programming error of + // some kind? If so, maybe this should be a fatal error? + + (*current_liboctave_warning_with_id_handler) + ("Octave:local-buffer-inconsistency", + "octave_chunk_buffer::clear: %d active allocations remain!", active); } }
--- a/liboctave/util/oct-shlib.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/oct-shlib.cc Thu Dec 18 10:50:09 2014 -0500 @@ -87,8 +87,9 @@ { tm_loaded = fs.mtime (); - (*current_liboctave_warning_handler) - ("library %s not reloaded due to existing references", file.c_str ()); + (*current_liboctave_warning_with_id_handler) + ("Octave:library-reload", + "library %s not reloaded due to existing references", file.c_str ()); } }
--- a/liboctave/util/sparse-util.cc Thu Dec 18 07:57:58 2014 -0500 +++ b/liboctave/util/sparse-util.cc Thu Dec 18 10:50:09 2014 -0500 @@ -48,12 +48,9 @@ // Ignore CHOLMOD_NOT_POSDEF, since we handle that in Fchol as an // error or exit status. if (status != CHOLMOD_NOT_POSDEF) - { - (*current_liboctave_warning_handler)("warning %i, at line %i in file %s", - status, line, file); - - (*current_liboctave_warning_handler)(message); - } + (*current_liboctave_warning_with_id_handler) + ("Octave:cholmod-message", "warning %i, at line %i in file %s: %s", + status, line, file, message); } int