annotate libinterp/corefcn/error.cc @ 17787:175b392e91fe

Use GNU style coding conventions for code in libinterp/ * libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc, libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc, libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc, libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h, libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h, libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc, libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc, libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc, libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc, libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h, libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc, libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc, libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h, libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/input.h, libinterp/corefcn/inv.cc, libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc, libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h, libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc, libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc, libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc, libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc, libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc, libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h, libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h, libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h, libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h, libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h, libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h, libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc, libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h, libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc, libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h, libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc, libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc, libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc, libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc, libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc, libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc, libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc, libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h, libinterp/octave-value/ov-base-scalar.cc, libinterp/octave-value/ov-base-scalar.h, libinterp/octave-value/ov-base-sparse.cc, libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc, libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc, libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc, libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc, libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc, libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h, libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h, libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h, libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h, libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h, libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-handle.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h, libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h, libinterp/octave-value/ov-flt-complex.cc, libinterp/octave-value/ov-flt-complex.h, libinterp/octave-value/ov-flt-cx-diag.cc, libinterp/octave-value/ov-flt-cx-diag.h, libinterp/octave-value/ov-flt-cx-mat.cc, libinterp/octave-value/ov-flt-cx-mat.h, libinterp/octave-value/ov-flt-re-diag.cc, libinterp/octave-value/ov-flt-re-diag.h, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc, libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc, libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h, libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h, libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h, libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc, libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc, libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc, libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc, libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc, libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h, libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc, libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h, libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc, libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc, libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc, libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc, libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc, libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc, libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc, libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc, libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc, libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc, libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc, libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc, libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc, libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc, libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc, libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc, libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc, libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc, libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc, libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc, libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc, libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc, libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc, libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc, libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc, libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc, libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc, libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc, libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc, libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc, libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc, libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc, libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc, libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc, libinterp/operators/ops.h, libinterp/parse-tree/lex.h, libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc, libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc, libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h, libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc, libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h, libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc, libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h, libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc, libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc, libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h, libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc, libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc, libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h, libinterp/parse-tree/token.h, libinterp/version.cc: Use GNU style coding conventions for code in libinterp/
author Rik <rik@octave.org>
date Mon, 28 Oct 2013 19:51:46 -0700
parents d63878346099
children 25e87795f437 d96747f74b1e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17281
diff changeset
3 Copyright (C) 1993-2013 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 189
diff changeset
23 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1165
diff changeset
24 #include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
27 #include <cstdarg>
1633
4a4440aa1262 [project @ 1995-11-14 23:01:31 by jwe]
jwe
parents: 1489
diff changeset
28 #include <cstring>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
29
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
30 #include <iostream>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
31 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
32 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
33
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
34 #include "defun.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
35 #include "error.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
36 #include "input.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
37 #include "pager.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
38 #include "oct-obj.h"
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
39 #include "oct-map.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
40 #include "utils.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2200
diff changeset
41 #include "ov.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
42 #include "ov-usr-fcn.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
43 #include "pt-pr-code.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
44 #include "pt-stmt.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
45 #include "toplev.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
46 #include "unwind-prot.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2200
diff changeset
47 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
48
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
49 // TRUE means that Octave will try to beep obnoxiously before printing
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
50 // error messages.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
51 static bool Vbeep_on_error = false;
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
52
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
53 // TRUE means that Octave will try to enter the debugger when an error
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
54 // is encountered. This will also inhibit printing of the normal
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
55 // traceback message (you will only see the top-level error message).
7353
516ddd88e45a [project @ 2008-01-07 19:32:40 by jwe]
jwe
parents: 7336
diff changeset
56 bool Vdebug_on_error = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
57
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
58 // TRUE means that Octave will try to enter the debugger when a warning
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
59 // is encountered.
7353
516ddd88e45a [project @ 2008-01-07 19:32:40 by jwe]
jwe
parents: 7336
diff changeset
60 bool Vdebug_on_warning = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
61
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
62 // TRUE means that Octave will try to display a stack trace when a
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
63 // warning is encountered.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
64 static bool Vbacktrace_on_warning = false;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
65
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
66 // TRUE means that Octave will print a verbose warning. Currently unused.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
67 static bool Vverbose_warning;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
68
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
69 // TRUE means that Octave will print no warnings, but lastwarn will be
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
70 //updated
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
71 static bool Vquiet_warning = false;
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
72
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
73 // A structure containing (most of) the current state of warnings.
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
74 static octave_map warning_options;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
75
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
76 // The text of the last error message.
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
77 static std::string Vlast_error_message;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
78
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
79 // The text of the last warning message.
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
80 static std::string Vlast_warning_message;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
81
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
82 // The last warning message id.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
83 static std::string Vlast_warning_id;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
84
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
85 // The last error message id.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
86 static std::string Vlast_error_id;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
87
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
88 // The last file in which an error occured
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
89 static octave_map Vlast_error_stack;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
90
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 103
diff changeset
91 // Current error state.
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
92 //
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
93 // Valid values:
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
94 //
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
95 // -2: an error has occurred, but don't print any messages.
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
96 // -1: an error has occurred, we are printing a traceback
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
97 // 0: no error
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
98 // 1: an error has occurred
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
99 //
672
066e1551639c [project @ 1994-09-07 21:10:32 by jwe]
jwe
parents: 610
diff changeset
100 int error_state = 0;
066e1551639c [project @ 1994-09-07 21:10:32 by jwe]
jwe
parents: 610
diff changeset
101
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3402
diff changeset
102 // Current warning state.
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
103 //
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
104 // Valid values:
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
105 //
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
106 // 0: no warning
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
107 // 1: a warning has occurred
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
108 //
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3402
diff changeset
109 int warning_state = 0;
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3402
diff changeset
110
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
111 // Tell the error handler whether to print messages, or just store
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
112 // them for later. Used for handling errors in eval() and
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
113 // the 'unwind_protect' statement.
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4452
diff changeset
114 int buffer_error_messages = 0;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
115
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
116 // TRUE means error messages are turned off.
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
117 bool discard_error_messages = false;
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
118
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
119 // TRUE means warning messages are turned off.
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
120 bool discard_warning_messages = false;
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
121
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
122 void
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
123 reset_error_handler (void)
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
124 {
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
125 error_state = 0;
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
126 warning_state = 0;
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4452
diff changeset
127 buffer_error_messages = 0;
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
128 discard_error_messages = false;
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
129 }
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
130
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
131 static void
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
132 initialize_warning_options (const std::string& state)
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
133 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
134 octave_scalar_map initw;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
135
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
136 initw.setfield ("identifier", "all");
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
137 initw.setfield ("state", state);
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
138
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
139 warning_options = initw;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
140 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
141
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
142 static octave_map
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
143 initialize_last_error_stack (void)
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
144 {
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
145 return octave_call_stack::empty_backtrace ();
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
146 }
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
147
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
148 // Warning messages are never buffered.
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
149
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
150 static void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
151 vwarning (const char *name, const char *id, const char *fmt, va_list args)
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
152 {
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
153 if (discard_warning_messages)
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
154 return;
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
155
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
156 flush_octave_stdout ();
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
157
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
158 std::ostringstream output_buf;
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
159
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
160 if (name)
3761
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
161 output_buf << name << ": ";
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
162
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
163 octave_vformat (output_buf, fmt, args);
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
164
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
165 output_buf << std::endl;
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
166
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
167 // FIXME: we really want to capture the message before it has all the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
168 // formatting goop attached to it. We probably also want just the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
169 // message, not the traceback information.
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
170
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
171 std::string msg_string = output_buf.str ();
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
172
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
173 if (! warning_state)
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
174 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
175 // This is the first warning in a possible series.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
176
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
177 Vlast_warning_id = id;
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
178 Vlast_warning_message = msg_string;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
179 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
180
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
181 if (! Vquiet_warning)
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
182 {
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
183 octave_diary << msg_string;
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
184
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
185 std::cerr << msg_string;
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
186 }
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
187 }
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
188
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
189 static void
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
190 verror (bool save_last_error, std::ostream& os,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
191 const char *name, const char *id, const char *fmt, va_list args,
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
192 bool with_cfn = false)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
193 {
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
194 if (discard_error_messages)
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
195 return;
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
196
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
197 if (! buffer_error_messages)
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
198 flush_octave_stdout ();
914
6a10b90623ea [project @ 1994-11-10 21:53:10 by jwe]
jwe
parents: 905
diff changeset
199
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
200 // FIXME: we really want to capture the message before it has all the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
201 // formatting goop attached to it. We probably also want just the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
202 // message, not the traceback information.
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
203
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
204 std::ostringstream output_buf;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
205
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
206 octave_vformat (output_buf, fmt, args);
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
207
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
208 std::string base_msg = output_buf.str ();
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
209
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
210 bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
211
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
212 std::string msg_string;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
213
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
214 if (to_beep_or_not_to_beep_p)
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
215 msg_string = "\a";
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
216
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
217 if (name)
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
218 msg_string += std::string (name) + ": ";
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
219
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
220 // If with_fcn is specified, we'll attempt to prefix the message with the name
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
221 // of the current executing function. But we'll do so only if:
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
222 // 1. the name is not empty (anonymous function)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
223 // 2. it is not already there (including the following colon)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
224 if (with_cfn)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
225 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
226 octave_function *curfcn = octave_call_stack::current ();
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
227 if (curfcn)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
228 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
229 std::string cfn = curfcn->name ();
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
230 if (! cfn.empty ())
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
231 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
232 cfn += ':';
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
233 if (cfn.length () > base_msg.length ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
234 || base_msg.compare (0, cfn.length (), cfn) != 0)
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
235 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
236 msg_string += cfn + ' ';
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
237 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
238 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
239 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
240 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
241
7880
7609a985a052 verror fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
242 msg_string += base_msg + "\n";
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
243
4731
176fcf62c464 [project @ 2004-02-02 20:27:15 by jwe]
jwe
parents: 4719
diff changeset
244 if (! error_state && save_last_error)
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
245 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
246 // This is the first error in a possible series.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
247
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
248 Vlast_error_id = id;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
249 Vlast_error_message = base_msg;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
250
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
251 octave_user_code *fcn = octave_call_stack::caller_user_code ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
252
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
253 if (fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
254 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
255 octave_idx_type curr_frame = -1;
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
256
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
257 Vlast_error_stack = octave_call_stack::backtrace (0, curr_frame);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
258 }
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
259 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
260 Vlast_error_stack = initialize_last_error_stack ();
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
261 }
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
262
13987
2c0765c14e4f eliminate unused error message buffer
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
263 if (! buffer_error_messages)
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
264 {
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
265 octave_diary << msg_string;
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
266 os << msg_string;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
267 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
268 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
269
1266
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
270 // Note that we don't actually print any message if the error string
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
271 // is just "" or "\n". This allows error ("") and error ("\n") to
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
272 // just set the error state.
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
273
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
274 static void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
275 error_1 (std::ostream& os, const char *name, const char *id,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
276 const char *fmt, va_list args, bool with_cfn = false)
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
277 {
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
278 if (error_state != -2)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
279 {
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
280 if (fmt)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
281 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
282 if (*fmt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
283 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
284 size_t len = strlen (fmt);
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
285
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
286 if (len > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
287 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
288 if (fmt[len - 1] == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
289 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
290 if (len > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
291 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
292 char *tmp_fmt = strsave (fmt);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
293 tmp_fmt[len - 1] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
294 verror (true, os, name, id, tmp_fmt, args, with_cfn);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
295 delete [] tmp_fmt;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
296 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
297
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
298 error_state = -2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
299 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
300 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
301 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
302 verror (true, os, name, id, fmt, args, with_cfn);
1423
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
303
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
304 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
305 error_state = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
306 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
307 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
308 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
309 }
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
310 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
311 panic ("error_1: invalid format");
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
312 }
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
313 }
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
314
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
315 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
316 vmessage (const char *name, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
317 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
318 verror (false, std::cerr, name, "", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
319 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
320
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
321 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
322 message (const char *name, const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
323 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
324 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
325 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
326 vmessage (name, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
327 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
328 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
329
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
330 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
331 vmessage_with_id (const char *name, const char *id, const char *fmt,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
332 va_list args)
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
333 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
334 verror (false, std::cerr, name, id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
335 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
336
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
337 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
338 message_with_id (const char *name, const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
339 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
340 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
341 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
342 vmessage_with_id (name, id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
343 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
344 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
345
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
346 void
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
347 usage_1 (const char *id, const char *fmt, va_list args)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
348 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
349 verror (true, std::cerr, "usage", id, fmt, args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
350 error_state = -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
351 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
352
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
353 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
354 vusage (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
355 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
356 usage_1 ("", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
357 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
358
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
359 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
360 usage (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
361 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
362 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
363 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
364 vusage (fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
365 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
366 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
367
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
368 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
369 vusage_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
370 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
371 usage_1 (id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
372 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
373
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
374 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
375 usage_with_id (const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
376 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
377 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
378 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
379 vusage_with_id (id, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
380 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
381 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
382
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
383 static void
3719
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
384 pr_where_2 (const char *fmt, va_list args)
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
385 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
386 if (fmt)
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
387 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
388 if (*fmt)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
389 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
390 size_t len = strlen (fmt);
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
391
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
392 if (len > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
393 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
394 if (fmt[len - 1] == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
395 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
396 if (len > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
397 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
398 char *tmp_fmt = strsave (fmt);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
399 tmp_fmt[len - 1] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
400 verror (false, std::cerr, 0, "", tmp_fmt, args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
401 delete [] tmp_fmt;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
402 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
403 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
404 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
405 verror (false, std::cerr, 0, "", fmt, args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
406 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
407 }
3719
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
408 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
409 else
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
410 panic ("pr_where_2: invalid format");
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
411 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
412
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
413 static void
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
414 pr_where_1 (const char *fmt, ...)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
415 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
416 va_list args;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
417 va_start (args, fmt);
3719
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
418 pr_where_2 (fmt, args);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
419 va_end (args);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
420 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
421
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
422 static void
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
423 pr_where (const char *who)
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
424 {
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
425 octave_idx_type curr_frame = -1;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
426
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
427 octave_map stk = octave_call_stack::backtrace (0, curr_frame);
4976
bfcd251499b2 [project @ 2004-09-08 19:31:31 by jwe]
jwe
parents: 4748
diff changeset
428
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
429 octave_idx_type nframes_to_display = stk.numel ();
4976
bfcd251499b2 [project @ 2004-09-08 19:31:31 by jwe]
jwe
parents: 4748
diff changeset
430
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
431 if (nframes_to_display > 0)
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
432 {
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
433 pr_where_1 ("%s: called from\n", who);
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
434
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
435 Cell names = stk.contents ("name");
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
436 Cell lines = stk.contents ("line");
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
437 Cell columns = stk.contents ("column");
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
438
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
439 for (octave_idx_type i = 0; i < nframes_to_display; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
440 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
441 octave_value name = names(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
442 octave_value line = lines(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
443 octave_value column = columns(i);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
444
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
445 std::string nm = name.string_value ();
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7353
diff changeset
446
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
447 pr_where_1 (" %s at line %d column %d\n", nm.c_str (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
448 line.int_value (), column.int_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
449 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
450 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
451 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
452
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
453 static void
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
454 error_2 (const char *id, const char *fmt, va_list args, bool with_cfn = false)
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
455 {
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
456 int init_state = error_state;
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
457
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
458 error_1 (std::cerr, "error", id, fmt, args, with_cfn);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
459
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
460 if ((interactive || forced_interactive)
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
461 && Vdebug_on_error && init_state == 0
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7552
diff changeset
462 && octave_call_stack::caller_user_code ())
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
463 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
464 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
465 frame.protect_var (Vdebug_on_error);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
466 Vdebug_on_error = false;
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
467
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
468 error_state = 0;
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
469
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
470 pr_where ("error");
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
471
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
472 do_keyboard (octave_value_list ());
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
473 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
474 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
475
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
476 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
477 verror (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
478 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
479 error_2 ("", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
480 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
481
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
482 void
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
483 error (const char *fmt, ...)
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
484 {
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
485 va_list args;
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
486 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
487 verror (fmt, args);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
488 va_end (args);
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
489 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
490
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
491 void
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
492 verror_with_cfn (const char *fmt, va_list args)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
493 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
494 error_2 ("", fmt, args, true);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
495 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
496
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
497 void
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
498 error_with_cfn (const char *fmt, ...)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
499 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
500 va_list args;
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
501 va_start (args, fmt);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
502 verror_with_cfn (fmt, args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
503 va_end (args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
504 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
505
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
506 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
507 verror_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
508 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
509 error_2 (id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
510 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
511
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
512 void
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
513 error_with_id (const char *id, const char *fmt, ...)
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
514 {
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
515 va_list args;
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
516 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
517 verror_with_id (id, fmt, args);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
518 va_end (args);
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
519 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
520
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
521 void
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
522 verror_with_id_cfn (const char *id, const char *fmt, va_list args)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
523 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
524 error_2 (id, fmt, args, true);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
525 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
526
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
527 void
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
528 error_with_id_cfn (const char *id, const char *fmt, ...)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
529 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
530 va_list args;
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
531 va_start (args, fmt);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
532 verror_with_id_cfn (id, fmt, args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
533 va_end (args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
534 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
535
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
536 static int
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
537 check_state (const std::string& state)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
538 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
539 // -1: not found
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
540 // 0: found, "off"
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
541 // 1: found, "on"
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
542 // 2: found, "error"
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
543
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
544 if (state == "off")
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
545 return 0;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
546 else if (state == "on")
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
547 return 1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
548 else if (state == "error")
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
549 return 2;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
550 else
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
551 return -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
552 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
553
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
554 // For given warning ID, return 0 if warnings are disabled, 1 if
14042
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
555 // enabled, and 2 if the given ID should be an error instead of a
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
556 // warning.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
557
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
558 int
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
559 warning_enabled (const std::string& id)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
560 {
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
561 int retval = 0;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
562
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
563 int all_state = -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
564 int id_state = -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
565
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
566 octave_idx_type nel = warning_options.numel ();
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
568 if (nel > 0)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
569 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
570 Cell identifier = warning_options.contents ("identifier");
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
571 Cell state = warning_options.contents ("state");
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
572
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
573 bool all_found = false;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
574 bool id_found = false;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
575
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
576 for (octave_idx_type i = 0; i < nel; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
577 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
578 octave_value ov = identifier(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
579 std::string ovs = ov.string_value ();
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
580
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
581 if (! all_found && ovs == "all")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
582 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
583 all_state = check_state (state(i).string_value ());
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
584
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
585 if (all_state >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
586 all_found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
587 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
588
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
589 if (! id_found && ovs == id)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
590 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
591 id_state = check_state (state(i).string_value ());
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
592
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
593 if (id_state >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
594 id_found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
595 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
596
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
597 if (all_found && id_found)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
598 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
599 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
600 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
601
14042
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
602 // If "all" is not present, assume warnings are enabled.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
603 if (all_state == -1)
14042
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
604 all_state = 1;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
605
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
606 if (all_state == 0)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
607 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
608 if (id_state >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
609 retval = id_state;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
610 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
611 else if (all_state == 1)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
612 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
613 if (id_state == 0 || id_state == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
614 retval = id_state;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
615 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
616 retval = all_state;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
617 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
618 else if (all_state == 2)
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
619 {
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
620 if (id_state == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
621 retval= id_state;
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
622 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
623 retval = all_state;
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
624 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
625
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
626 return retval;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
627 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
628
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
629 static void
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
630 warning_1 (const char *id, const char *fmt, va_list args)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
631 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
632 int warn_opt = warning_enabled (id);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
633
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
634 if (warn_opt == 2)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
635 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
636 // Handle this warning as an error.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
637
5998
e1eb3a91e494 [project @ 2006-09-26 12:40:52 by jwe]
jwe
parents: 5904
diff changeset
638 error_2 (id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
639 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
640 else if (warn_opt == 1)
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
641 {
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
642 vwarning ("warning", id, fmt, args);
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
643
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
644 if (! symbol_table::at_top_level ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
645 && Vbacktrace_on_warning
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
646 && ! warning_state
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
647 && ! discard_warning_messages)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
648 pr_where ("warning");
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
649
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
650 warning_state = 1;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
651
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
652 if ((interactive || forced_interactive)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
653 && Vdebug_on_warning
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
654 && octave_call_stack::caller_user_code ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
655 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
656 unwind_protect frame;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
657 frame.protect_var (Vdebug_on_warning);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
658 Vdebug_on_warning = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
659
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
660 do_keyboard (octave_value_list ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
661 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
662 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
663 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
664
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
665 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
666 vwarning (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
667 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
668 warning_1 ("", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
669 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
670
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
671 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
672 warning (const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
673 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
674 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
675 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
676 vwarning (fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
677 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
678 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
679
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
680 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
681 vwarning_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
682 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
683 warning_1 (id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
684 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
685
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
686 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
687 warning_with_id (const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
688 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
689 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
690 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
691 vwarning_with_id (id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
692 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
693 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
694
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
695 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
696 vparse_error (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
697 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
698 error_1 (std::cerr, 0, "", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
699 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
700
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
701 void
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
702 parse_error (const char *fmt, ...)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
703 {
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
704 va_list args;
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
705 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
706 vparse_error (fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
707 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
708 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
709
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
710 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
711 vparse_error_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
712 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
713 error_1 (std::cerr, 0, id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
714 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
715
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
716 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
717 parse_error_with_id (const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
718 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
719 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
720 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
721 vparse_error_with_id (id, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
722 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
723 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
724
189
de0e58f9b064 [project @ 1993-10-28 08:52:15 by jwe]
jwe
parents: 169
diff changeset
725 void
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
726 rethrow_error (const char *id, const char *fmt, ...)
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
727 {
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
728 va_list args;
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
729 va_start (args, fmt);
6640
379244420c72 [project @ 2007-05-21 19:50:45 by jwe]
jwe
parents: 6483
diff changeset
730 error_1 (std::cerr, 0, id, fmt, args);
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
731 va_end (args);
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
732 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
733
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
734 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
735 panic (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
736 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
737 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
738 va_start (args, fmt);
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4452
diff changeset
739 buffer_error_messages = 0;
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
740 discard_error_messages = false;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
741 verror (false, std::cerr, "panic", "", fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
742 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
743 abort ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
744 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
745
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
746 static void
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
747 defun_usage_message_1 (const char *fmt, ...)
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
748 {
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
749 va_list args;
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
750 va_start (args, fmt);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
751 error_1 (octave_stdout, 0, "", fmt, args);
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
752 va_end (args);
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
753 }
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
754
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
755 void
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
756 defun_usage_message (const std::string& msg)
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
757 {
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
758 defun_usage_message_1 ("%s", msg.c_str ());
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
759 }
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
760
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
761 typedef void (*error_fun)(const char *, const char *, ...);
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
762
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
763 extern octave_value_list Fsprintf (const octave_value_list&, int);
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
764
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
765 static std::string
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
766 handle_message (error_fun f, const char *id, const char *msg,
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
767 const octave_value_list& args, bool have_fmt)
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
768 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
769 std::string retval;
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
770
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
771 std::string tstr;
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
772
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
773 int nargin = args.length ();
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
774
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
775 if (nargin > 0)
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
776 {
3066
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
777 octave_value arg;
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
778
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
779 if (have_fmt)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
780 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
781 octave_value_list tmp = Fsprintf (args, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
782 arg = tmp(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
783 }
3066
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
784 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
785 arg = args(0);
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
786
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
787 if (arg.is_defined ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
788 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
789 if (arg.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
790 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
791 tstr = arg.string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
792 msg = tstr.c_str ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
793
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
794 if (! msg)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
795 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
796 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
797 else if (arg.is_empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
798 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
799 }
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
800 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
801
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
802 // Ugh.
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
803
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
804 size_t len = strlen (msg);
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
805
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
806 if (len > 0)
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
807 {
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
808 if (msg[len - 1] == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
809 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
810 if (len > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
811 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
812 char *tmp_msg = strsave (msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
813 tmp_msg[len - 1] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
814 f (id, "%s\n", tmp_msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
815 retval = tmp_msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
816 delete [] tmp_msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
817 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
818 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
819 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
820 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
821 f (id, "%s", msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
822 retval = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
823 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
824 }
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
825
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
826 return retval;
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
827 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
828
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
829 DEFUN (rethrow, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
830 "-*- texinfo -*-\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
831 @deftypefn {Built-in Function} {} rethrow (@var{err})\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
832 Reissue a previous error as defined by @var{err}. @var{err} is a structure\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
833 that must contain at least the @qcode{\"message\"} and @qcode{\"identifier\"}\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
834 fields. @var{err} can also contain a field @qcode{\"stack\"} that gives\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
835 information on the assumed location of the error. Typically @var{err} is\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
836 returned from @code{lasterror}.\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
837 @seealso{lasterror, lasterr, error}\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
838 @end deftypefn")
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
839 {
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
840 octave_value retval;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
841 int nargin = args.length ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
842
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
843 if (nargin != 1)
6959
47f4f4e88166 [project @ 2007-10-04 20:43:32 by jwe]
jwe
parents: 6671
diff changeset
844 print_usage ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
845 else
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
846 {
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
847 const octave_scalar_map err = args(0).scalar_map_value ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
848
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
849 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
850 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
851 if (err.contains ("message") && err.contains ("identifier"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
852 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
853 std::string msg = err.contents ("message").string_value ();
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
854 std::string id = err.contents ("identifier").string_value ();
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
855 int len = msg.length ();
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
856
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
857 std::string file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
858 std::string nm;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
859 int l = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
860 int c = -1;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
861
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
862 octave_map err_stack = initialize_last_error_stack ();
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
863
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
864 if (err.contains ("stack"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
865 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
866 err_stack = err.contents ("stack").map_value ();
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
867
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
868 if (err_stack.numel () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
869 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
870 if (err_stack.contains ("file"))
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
871 file = err_stack.contents ("file")(0).string_value ();
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
872
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
873 if (err_stack.contains ("name"))
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
874 nm = err_stack.contents ("name")(0).string_value ();
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
875
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
876 if (err_stack.contains ("line"))
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
877 l = err_stack.contents ("line")(0).nint_value ();
6640
379244420c72 [project @ 2007-05-21 19:50:45 by jwe]
jwe
parents: 6483
diff changeset
878
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
879 if (err_stack.contains ("column"))
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
880 c = err_stack.contents ("column")(0).nint_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
881 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
882 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
883
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
884 // Ugh.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
885 char *tmp_msg = strsave (msg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
886 if (tmp_msg[len-1] == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
887 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
888 if (len > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
889 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
890 tmp_msg[len - 1] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
891 rethrow_error (id.c_str (), "%s\n", tmp_msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
892 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
893 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
894 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
895 rethrow_error (id.c_str (), "%s", tmp_msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
896 delete [] tmp_msg;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
897
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
898 // FIXME: is this the right thing to do for Vlast_error_stack?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
899 // Should it be saved and restored with unwind_protect?
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
900
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
901 Vlast_error_stack = err_stack;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
902
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
903 if (err.contains ("stack"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
904 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
905 if (file.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
906 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
907 if (nm.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
908 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
909 if (l > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
910 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
911 if (c > 0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
912 pr_where_1 ("error: near line %d, column %d",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
913 l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
914 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
915 pr_where_1 ("error: near line %d", l);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
916 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
917 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
918 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
919 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
920 if (l > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
921 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
922 if (c > 0)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
923 pr_where_1 ("error: called from '%s' near line %d, column %d",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
924 nm.c_str (), l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
925 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
926 pr_where_1 ("error: called from '%d' near line %d",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
927 nm.c_str (), l);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
928 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
929 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
930 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
931 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
932 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
933 if (nm.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
934 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
935 if (l > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
936 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
937 if (c > 0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
938 pr_where_1 ("error: in file %s near line %d, column %d",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
939 file.c_str (), l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
940 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
941 pr_where_1 ("error: in file %s near line %d",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
942 file.c_str (), l);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
943 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
944 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
945 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
946 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
947 if (l > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
948 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
949 if (c > 0)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
950 pr_where_1 ("error: called from '%s' in file %s near line %d, column %d",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
951 nm.c_str (), file.c_str (), l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
952 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
953 pr_where_1 ("error: called from '%d' in file %s near line %d",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
954 nm.c_str (), file.c_str (), l);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
955 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
956 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
957 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
958 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
959 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
960 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
961 error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
962 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
963 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
964 return retval;
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
965 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
966
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
967 // Determine whether the first argument to error or warning function
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
968 // should be handled as the message identifier or as the format string.
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
969
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
970 static bool
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
971 maybe_extract_message_id (const std::string& caller,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
972 const octave_value_list& args,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
973 octave_value_list& nargs,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
974 std::string& id)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
975 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
976 nargs = args;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
977 id = std::string ();
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
978
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
979 int nargin = args.length ();
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
980
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
981 bool have_fmt = nargin > 1;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
982
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
983 if (nargin > 0)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
984 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
985 std::string arg1 = args(0).string_value ();
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
986
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
987 if (! error_state)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
988 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
989 // For compatibility with Matlab, an identifier must contain
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
990 // ':', but not at the beginning or the end, and it must not
14559
90c51d8797cc also require that warning and error message identifiers do not contain whitespace
John W. Eaton <jwe@octave.org>
parents: 14558
diff changeset
991 // contain '%' (even if it is not a valid conversion
90c51d8797cc also require that warning and error message identifiers do not contain whitespace
John W. Eaton <jwe@octave.org>
parents: 14558
diff changeset
992 // operator) or whitespace.
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
993
14559
90c51d8797cc also require that warning and error message identifiers do not contain whitespace
John W. Eaton <jwe@octave.org>
parents: 14558
diff changeset
994 if (arg1.find_first_of ("% \f\n\r\t\v") == std::string::npos
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
995 && arg1.find (':') != std::string::npos
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
996 && arg1[0] != ':'
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
997 && arg1[arg1.length ()-1] != ':')
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
998 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
999 if (nargin > 1)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1000 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1001 id = arg1;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1002
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1003 nargs.resize (nargin-1);
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1004
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1005 for (int i = 1; i < nargin; i++)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1006 nargs(i-1) = args(i);
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1007 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1008 else
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1009 nargs(0) = "call to " + caller
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1010 + " with message identifier requires message";
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1011 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1012 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1013 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1014
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1015 return have_fmt;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1016 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1017
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
1018 DEFUN (error, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1019 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1020 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1021 @deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1022 Format the optional arguments under the control of the template string\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1023 @var{template} using the same rules as the @code{printf} family of\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1024 functions (@pxref{Formatted Output}) and print the resulting message\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1025 on the @code{stderr} stream. The message is prefixed by the character\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1026 string @samp{error: }.\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1027 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1028 Calling @code{error} also sets Octave's internal error state such that\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1029 control will return to the top level without evaluating any more\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1030 commands. This is useful for aborting from functions or scripts.\n\
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1031 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1032 If the error message does not end with a new line character, Octave will\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1033 print a traceback of all the function calls leading to the error. For\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1034 example, given the following function definitions:\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1035 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1036 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1037 @group\n\
6671
9042b00fc45e [project @ 2007-05-30 06:33:29 by jwe]
jwe
parents: 6653
diff changeset
1038 function f () g (); end\n\
9042b00fc45e [project @ 2007-05-30 06:33:29 by jwe]
jwe
parents: 6653
diff changeset
1039 function g () h (); end\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1040 function h () nargin == 1 || error (\"nargin != 1\"); end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1041 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1042 @end example\n\
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1043 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1044 @noindent\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1045 calling the function @code{f} will result in a list of messages that\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1046 can help you to quickly locate the exact location of the error:\n\
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1047 \n\
9153
5247e89688e1 Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents: 9039
diff changeset
1048 @example\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1049 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1050 f ()\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1051 error: nargin != 1\n\
8015
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1052 error: called from:\n\
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1053 error: error at line -1, column -1\n\
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1054 error: h at line 1, column 27\n\
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1055 error: g at line 1, column 15\n\
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1056 error: f at line 1, column 15\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1057 @end group\n\
9153
5247e89688e1 Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents: 9039
diff changeset
1058 @end example\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1059 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1060 If the error message ends in a new line character, Octave will print the\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1061 message but will not display any traceback messages as it returns\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1062 control to the top level. For example, modifying the error message\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1063 in the previous example to end in a new line causes Octave to only print\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1064 a single message:\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1065 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1066 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1067 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1068 function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1069 f ()\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1070 error: nargin != 1\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1071 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1072 @end example\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1073 \n\
16770
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1074 A null string (\"\") input to @code{error} will be ignored and the code\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1075 will continue running as if the statement were a NOP@. This is for\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1076 compatibility with @sc{matlab}. It also makes it possible to write code such\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1077 as\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1078 \n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1079 @example\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1080 @group\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1081 err_msg = \"\";\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1082 if (CONDITION 1)\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1083 err_msg = \"CONDITION 1 found\";\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1084 elseif (CONDITION2)\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1085 err_msg = \"CONDITION 2 found\";\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1086 @dots{}\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1087 endif\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1088 error (err_msg);\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1089 @end group\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1090 @end example\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1091 \n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1092 @noindent\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1093 which will only stop execution if an error has been found.\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1094 \n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1095 Implementation Note: For compatibility with @sc{matlab}, escape\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1096 sequences (e.g., @qcode{\"\\n\"} => newline) are processed in @var{template}\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1097 regardless of whether @var{template} has been defined within single quotes\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1098 as long as there are two or more input arguments.\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1099 Use a second backslash to stop interpolation of the escape sequence (e.g.,\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1100 \"\\\\n\") or use the @code{regexptranslate} function.\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1101 @seealso{warning, lasterror}\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1102 @end deftypefn")
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1103 {
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1104 octave_value retval;
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1105
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1106 int nargin = args.length ();
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1107
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1108 octave_value_list nargs = args;
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1109
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1110 std::string id;
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1111
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1112 if (nargin == 0)
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1113 print_usage ();
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1114 else
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1115 {
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1116 bool have_fmt = false;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1117
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1118 if (nargin == 1 && args(0).is_map ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1119 {
13709
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1120 // empty struct is not an error. return and resume calling function.
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1121 if (args(0).is_empty ())
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1122 return retval;
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1123
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1124 octave_value_list tmp;
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1125
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1126 octave_scalar_map m = args(0).scalar_map_value ();
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1127
12705
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1128 // empty struct is not an error. return and resume calling function.
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1129 if (m.nfields () == 0)
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1130 return retval;
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1131
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1132 if (m.contains ("message"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1133 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1134 octave_value c = m.getfield ("message");
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1135
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1136 if (c.is_string ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1137 nargs(0) = c.string_value ();
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1138 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1139
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1140 if (m.contains ("identifier"))
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1141 {
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1142 octave_value c = m.getfield ("identifier");
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1143
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1144 if (c.is_string ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1145 id = c.string_value ();
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1146 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1147
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1148 // FIXME: also need to handle "stack" field in error structure,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1149 // but that will require some more significant surgery on
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1150 // handle_message, error_with_id, etc.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1151 }
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1152 else
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1153 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1154 have_fmt = maybe_extract_message_id ("error", args, nargs, id);
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1155
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1156 if (error_state)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1157 return retval;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1158 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1159
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1160 handle_message (error_with_id, id.c_str (), "unspecified error",
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1161 nargs, have_fmt);
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1162 }
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1163
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1164 return retval;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1165 }
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1166
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1167 static octave_scalar_map
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1168 warning_query (const std::string& id_arg)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1169 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1170 octave_scalar_map retval;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1171
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1172 std::string id = id_arg;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1173
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1174 if (id == "last")
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1175 id = Vlast_warning_id;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1176
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1177 Cell ident = warning_options.contents ("identifier");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1178 Cell state = warning_options.contents ("state");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1179
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1180 octave_idx_type nel = ident.numel ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1181
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1182 bool found = false;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1183
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1184 std::string val;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1185
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1186 for (octave_idx_type i = 0; i < nel; i++)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1187 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1188 if (ident(i).string_value () == id)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1189 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1190 val = state(i).string_value ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1191 found = true;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1192 break;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1193 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1194 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1195
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1196 if (! found)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1197 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1198 for (octave_idx_type i = 0; i < nel; i++)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1199 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1200 if (ident(i).string_value () == "all")
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1201 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1202 val = state(i).string_value ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1203 found = true;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1204 break;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1205 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1206 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1207 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1208
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1209 if (found)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1210 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1211 retval.assign ("identifier", id);
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1212 retval.assign ("state", val);
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1213 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1214 else
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1215 error ("warning: unable to find default warning state!");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1216
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1217 return retval;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1218 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1219
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
1220 DEFUN (warning, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1221 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1222 @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1223 @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\
14072
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1224 @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1225 @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1226 @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1227 @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1228 @deftypefnx {Built-in Function} {} warning (@var{state}, @var{id}, \"local\")\n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1229 Format the optional arguments under the control of the template string\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1230 @var{template} using the same rules as the @code{printf} family of\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1231 functions (@pxref{Formatted Output}) and print the resulting message\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1232 on the @code{stderr} stream. The message is prefixed by the character\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1233 string @samp{warning: }.\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1234 You should use this function when you want to notify the user\n\
3600
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3585
diff changeset
1235 of an unusual condition, but only when it makes sense for your program\n\
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3585
diff changeset
1236 to go on.\n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1237 \n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1238 The optional message identifier allows users to enable or disable\n\
15524
15628a84a4fa Document form of warning IDs is NAMESPACE:WARNING-NAME (bug #37559)
Rik <rik@octave.org>
parents: 15466
diff changeset
1239 warnings tagged by @var{id}. A message identifier is of the form\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1240 \"NAMESPACE:WARNING-NAME\". Octave's own warnings use the @qcode{\"Octave\"}\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1241 namespace (@pxref{XREFwarning_ids}). The special identifier @qcode{\"all\"}\n\
15524
15628a84a4fa Document form of warning IDs is NAMESPACE:WARNING-NAME (bug #37559)
Rik <rik@octave.org>
parents: 15466
diff changeset
1242 may be used to set the state of all warnings.\n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1243 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1244 If the first argument is @qcode{\"on\"} or @qcode{\"off\"},\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1245 set the state of a particular warning using the identifier @var{id}. If the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1246 first argument is @qcode{\"query\"}, query the state of this warning\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1247 instead. If the identifier is omitted, a value of @qcode{\"all\"} is\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1248 assumed. If you set the state of a warning to @qcode{\"error\"}, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1249 warning named by @var{id} is handled as if it were an error instead. So,\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1250 for example, the following handles all warnings as errors:\n\
14072
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1251 \n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1252 @example\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1253 @group\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1254 warning (\"error\");\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1255 @end group\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1256 @end example\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1257 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1258 If the state is @qcode{\"on\"}, @qcode{\"off\"}, or @qcode{\"error\"}\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1259 and the third argument is @qcode{\"local\"}, then the warning state\n\
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1260 will be set temporarily, until the end of the current function.\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1261 Changes to warning states that are set locally affect the current\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1262 function and all functions called from the current scope. The\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1263 previous warning state is restored on return from the current\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1264 function. The @qcode{\"local\"} option is ignored if used in the top-level\n\
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1265 workspace.\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1266 \n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1267 Implementation Note: For compatibility with @sc{matlab}, escape\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1268 sequences (e.g., @qcode{\"\\n\"} => newline) are processed in @var{template}\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1269 regardless of whether @var{template} has been defined within single quotes\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1270 as long as there are two or more input arguments.\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1271 Use a second backslash to stop interpolation of the escape sequence (e.g.,\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1272 \"\\\\n\") or use the @code{regexptranslate} function.\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1273 @seealso{warning_ids, lastwarn, error}\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1274 @end deftypefn")
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1275 {
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1276 octave_value retval;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1277
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1278 int nargin = args.length ();
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1279 int argc = nargin + 1;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1280
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1281 bool done = false;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1282
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1283 if (argc > 1 && args.all_strings_p ())
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1284 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1285 string_vector argv = args.make_argv ("warning");
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1286
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1287 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1288 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1289 std::string arg1 = argv(1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1290 std::string arg2 = "all";
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1291
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1292 if (argc >= 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1293 arg2 = argv(2);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1294
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1295 if (arg1 == "on" || arg1 == "off" || arg1 == "error")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1296 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1297 octave_map old_warning_options = warning_options;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1298
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1299 if (argc == 4 && argv(3) == "local"
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1300 && ! symbol_table::at_top_level ())
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1301 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1302 symbol_table::scope_id scope
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1303 = octave_call_stack::current_scope ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1304
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1305 symbol_table::context_id context
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1306 = octave_call_stack::current_context ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1307
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1308 octave_scalar_map val = warning_query (arg2);
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1309
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1310 octave_value curr_state = val.contents ("state");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1311
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1312 // FIXME: this might be better with a dictionary object.
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1313
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1314 octave_value curr_warning_states
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1315 = symbol_table::varval (".saved_warning_states.",
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1316 scope, context);
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1317
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1318 octave_map m;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1319
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1320 if (curr_warning_states.is_defined ())
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1321 m = curr_warning_states.map_value ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1322 else
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1323 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1324 string_vector fields (2);
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1325
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1326 fields(0) = "identifier";
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1327 fields(1) = "state";
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1328
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1329 m = octave_map (dim_vector (0, 1), fields);
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1330 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1331
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1332 if (error_state)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1333 panic_impossible ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1334
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1335 Cell ids = m.contents ("identifier");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1336 Cell states = m.contents ("state");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1337
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1338 octave_idx_type nel = states.numel ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1339 bool found = false;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1340 octave_idx_type i;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1341 for (i = 0; i < nel; i++)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1342 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1343 std::string id = ids(i).string_value ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1344
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1345 if (error_state)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1346 panic_impossible ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1347
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1348 if (id == arg2)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1349 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1350 states(i) = curr_state;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1351 found = true;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1352 break;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1353 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1354 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1355
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1356 if (! found)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1357 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1358 m.resize (dim_vector (nel+1, 1));
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1359
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1360 ids.resize (dim_vector (nel+1, 1));
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1361 states.resize (dim_vector (nel+1, 1));
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1362
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1363 ids(nel) = arg2;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1364 states(nel) = curr_state;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1365 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1366
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1367 m.contents ("identifier") = ids;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1368 m.contents ("state") = states;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1369
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 15624
diff changeset
1370 symbol_table::assign
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 15624
diff changeset
1371 (".saved_warning_states.", m, scope, context);
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1372
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1373 // Now ignore the "local" argument and continue to
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1374 // handle the current setting.
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1375 argc--;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1376 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1377
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1378 if (arg2 == "all")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1379 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1380 octave_map tmp;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1381
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1382 Cell id (1, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1383 Cell st (1, 1);
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1384
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1385 id(0) = arg2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1386 st(0) = arg1;
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1387
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1388 // Since internal Octave functions are not
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1389 // compatible, turning all warnings into errors
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1390 // should leave the state of
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1391 // Octave:matlab-incompatible alone.
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1392
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1393 if (arg1 == "error"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1394 && warning_options.contains ("identifier"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1395 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1396 octave_idx_type n = 1;
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
1397
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1398 Cell tid = warning_options.contents ("identifier");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1399 Cell tst = warning_options.contents ("state");
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1400
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1401 for (octave_idx_type i = 0; i < tid.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1403 octave_value vid = tid(i);
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1404
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1405 if (vid.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1406 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1407 std::string key = vid.string_value ();
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1408
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1409 if (key == "Octave:matlab-incompatible"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1410 || key == "Octave:single-quote-string")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1411 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1412 id.resize (dim_vector (1, n+1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1413 st.resize (dim_vector (1, n+1));
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1414
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1415 id(n) = tid(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1416 st(n) = tst(i);
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
1417
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1418 n++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1419 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1420 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1421 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1422 }
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1423
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1424 tmp.assign ("identifier", id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1425 tmp.assign ("state", st);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1426
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1427 warning_options = tmp;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1428
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1429 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1430 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1431 else if (arg2 == "backtrace")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1432 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1433 if (arg1 != "error")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1434 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1435 Vbacktrace_on_warning = (arg1 == "on");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1436 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1437 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1438 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1439 else if (arg2 == "debug")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1440 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1441 if (arg1 != "error")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1442 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1443 Vdebug_on_warning = (arg1 == "on");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1444 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1445 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1446 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1447 else if (arg2 == "verbose")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1448 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1449 if (arg1 != "error")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1450 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1451 Vverbose_warning = (arg1 == "on");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1452 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1453 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1454 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1455 else if (arg2 == "quiet")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1456 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1457 if (arg1 != "error")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1458 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1459 Vquiet_warning = (arg1 == "on");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1460 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1461 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1462 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1463 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1464 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1465 if (arg2 == "last")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1466 arg2 = Vlast_warning_id;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1467
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1468 if (arg2 == "all")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1469 initialize_warning_options (arg1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1470 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1471 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1472 Cell ident = warning_options.contents ("identifier");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1473 Cell state = warning_options.contents ("state");
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1474
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1475 octave_idx_type nel = ident.numel ();
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1476
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1477 bool found = false;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1478
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1479 for (octave_idx_type i = 0; i < nel; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1480 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1481 if (ident(i).string_value () == arg2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1482 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1483 // FIXME: if state for "all" is same as arg1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1484 // we can simply remove the item
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1485 // from the list.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1486
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1487 state(i) = arg1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1488 warning_options.assign ("state", state);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1489 found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1490 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1491 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1492 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1493
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1494 if (! found)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1495 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1496 // FIXME: if state for "all" is same as arg1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1497 // we don't need to do anything.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1498
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1499 ident.resize (dim_vector (1, nel+1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1500 state.resize (dim_vector (1, nel+1));
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1501
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1502 ident(nel) = arg2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1503 state(nel) = arg1;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1504
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1505 warning_options.clear ();
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1506
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1507 warning_options.assign ("identifier", ident);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1508 warning_options.assign ("state", state);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1509 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1510 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1511
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1512 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1513 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1514
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1515 if (done && nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1516 retval = old_warning_options;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1517 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1518 else if (arg1 == "query")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1519 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1520 if (arg2 == "all")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1521 retval = warning_options;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1522 else if (arg2 == "backtrace" || arg2 == "debug"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1523 || arg2 == "verbose" || arg2 == "quiet")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1524 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1525 octave_scalar_map tmp;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1526 tmp.assign ("identifier", arg2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1527 if (arg2 == "backtrace")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1528 tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1529 else if (arg2 == "debug")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1530 tmp.assign ("state", Vdebug_on_warning ? "on" : "off");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1531 else if (arg2 == "verbose")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1532 tmp.assign ("state", Vverbose_warning ? "on" : "off");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1533 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1534 tmp.assign ("state", Vquiet_warning ? "on" : "off");
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
1535
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1536 retval = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1537 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1538 else
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1539 retval = warning_query (arg2);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1540
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1541 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1542 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1543 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1544 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1545 else if (argc == 1)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1546 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1547 retval = warning_options;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1548
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1549 done = true;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1550 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1551 else if (argc == 2)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1552 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1553 octave_value arg = args(0);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1554
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1555 octave_map old_warning_options = warning_options;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1556
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1557 if (arg.is_map ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1558 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1559 octave_map m = arg.map_value ();
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1560
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1561 if (m.contains ("identifier") && m.contains ("state"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1562 warning_options = m;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1563 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1564 error ("warning: expecting structure with fields 'identifier' and 'state'");
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1565
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1566 done = true;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1567
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1568 if (nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1569 retval = old_warning_options;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1570 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1571 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1572
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1573 if (! (error_state || done))
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1574 {
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1575 octave_value_list nargs = args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1576
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1577 std::string id;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1578
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1579 bool have_fmt = maybe_extract_message_id ("warning", args, nargs, id);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1580
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1581 if (error_state)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1582 return retval;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1583
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1584 std::string prev_msg = Vlast_warning_message;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1585
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1586 std::string curr_msg = handle_message (warning_with_id, id.c_str (),
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1587 "unspecified warning", nargs,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1588 have_fmt);
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1589
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1590 if (nargout > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1591 retval = prev_msg;
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1592 }
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1593
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1594 return retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1595 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1596
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1597 octave_value_list
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1598 set_warning_state (const std::string& id, const std::string& state)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1599 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1600 octave_value_list args;
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1601
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1602 args(1) = id;
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1603 args(0) = state;
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1604
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1605 return Fwarning (args, 1);
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1606 }
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1607
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1608 octave_value_list
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1609 set_warning_state (const octave_value_list& args)
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1610 {
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1611 return Fwarning (args, 1);
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1612 }
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1613
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1614 void
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1615 disable_warning (const std::string& id)
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1616 {
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1617 set_warning_state (id, "off");
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1618 }
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1619
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1620 void
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1621 initialize_default_warning_state (void)
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1622 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1623 initialize_warning_options ("on");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1624
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1625 // Most people will want to have the following disabled.
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1626
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1627 disable_warning ("Octave:array-to-scalar");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1628 disable_warning ("Octave:array-to-vector");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1629 disable_warning ("Octave:imag-to-real");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1630 disable_warning ("Octave:matlab-incompatible");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1631 disable_warning ("Octave:missing-semicolon");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1632 disable_warning ("Octave:neg-dim-as-zero");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1633 disable_warning ("Octave:resize-on-range-error");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1634 disable_warning ("Octave:separator-insert");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1635 disable_warning ("Octave:single-quote-string");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1636 disable_warning ("Octave:str-to-num");
13841
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1637 disable_warning ("Octave:mixed-string-concat");
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1638 disable_warning ("Octave:variable-switch-label");
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1639
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1640 // This should be an error unless we are in maximum braindamage mode.
13841
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1641 // FIXME: Not quite right. This sets the error state even for braindamage
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1642 // mode. Also, this error is not triggered in normal mode because another
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1643 // error handler catches it first and gives:
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1644 // error: subscript indices must be either positive integers or logicals
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1645 set_warning_state ("Octave:noninteger-range-as-index", "error");
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1646
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1647 }
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1648
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1649 DEFUN (lasterror, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1650 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
1651 @deftypefn {Built-in Function} {@var{lasterr} =} lasterror ()\n\
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
1652 @deftypefnx {Built-in Function} {} lasterror (@var{err})\n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1653 @deftypefnx {Built-in Function} {} lasterror (\"reset\")\n\
14093
050bc580cb60 doc: Various docstring improvements before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 14072
diff changeset
1654 Query or set the last error message structure. When called without\n\
050bc580cb60 doc: Various docstring improvements before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 14072
diff changeset
1655 arguments, return a structure containing the last error message and other\n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1656 information related to this error. The elements of the structure are:\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1657 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1658 @table @code\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1659 @item message\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1660 The text of the last error message\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1661 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1662 @item identifier\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1663 The message identifier of this error message\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1664 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1665 @item stack\n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1666 A structure containing information on where the message occurred. This may\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1667 be an empty structure if the information cannot\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1668 be obtained. The fields of the structure are:\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1669 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1670 @table @code\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1671 @item file\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1672 The name of the file where the error occurred\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1673 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1674 @item name\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6959
diff changeset
1675 The name of function in which the error occurred\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1676 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1677 @item line\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6959
diff changeset
1678 The line number at which the error occurred\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1679 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1680 @item column\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1681 An optional field with the column number at which the error occurred\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1682 @end table\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1683 @end table\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1684 \n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1685 The last error structure may be set by passing a scalar structure, @var{err},\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1686 as input. Any fields of @var{err} that match those above are set while any\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1687 unspecified fields are initialized with default values.\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1688 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1689 If @code{lasterror} is called with the argument @qcode{\"reset\"}, all\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1690 fields are set to their default values.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1691 @seealso{lasterr, error, lastwarn}\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1692 @end deftypefn")
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1693 {
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1694 octave_value retval;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1695 int nargin = args.length ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1696
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
1697 unwind_protect frame;
7976
736124a4fa3d lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents: 7882
diff changeset
1698
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
1699 frame.protect_var (error_state);
7976
736124a4fa3d lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents: 7882
diff changeset
1700 error_state = 0;
736124a4fa3d lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents: 7882
diff changeset
1701
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1702 if (nargin < 2)
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1703 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1704 octave_scalar_map err;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1705
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1706 err.assign ("message", Vlast_error_message);
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1707 err.assign ("identifier", Vlast_error_id);
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1708
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1709 err.assign ("stack", octave_value (Vlast_error_stack));
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1710
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1711 if (nargin == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1712 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1713 if (args(0).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1714 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1715 if (args(0).string_value () == "reset")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1716 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1717 Vlast_error_message = std::string ();
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1718 Vlast_error_id = std::string ();
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1719
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1720 Vlast_error_stack = initialize_last_error_stack ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1721 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1722 else
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1723 error ("lasterror: unrecognized string argument");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1724 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1725 else if (args(0).is_map ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1726 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1727 octave_scalar_map new_err = args(0).scalar_map_value ();
16492
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1728 octave_scalar_map new_err_stack;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1729 std::string new_error_message;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1730 std::string new_error_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1731 std::string new_error_file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1732 std::string new_error_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1733 int new_error_line = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1734 int new_error_column = -1;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1735
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1736 if (! error_state && new_err.contains ("message"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1737 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1738 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1739 new_err.getfield ("message").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1740 new_error_message = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1741 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1742
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1743 if (! error_state && new_err.contains ("identifier"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1744 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1745 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1746 new_err.getfield ("identifier").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1747 new_error_id = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1748 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1749
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1750 if (! error_state && new_err.contains ("stack"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1751 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1752 new_err_stack =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1753 new_err.getfield ("stack").scalar_map_value ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1754
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1755 if (! error_state && new_err_stack.contains ("file"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1756 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1757 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1758 new_err_stack.getfield ("file").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1759 new_error_file = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1760 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1761
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1762 if (! error_state && new_err_stack.contains ("name"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1763 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1764 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1765 new_err_stack.getfield ("name").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1766 new_error_name = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1767 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1768
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1769 if (! error_state && new_err_stack.contains ("line"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1770 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1771 const int tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1772 new_err_stack.getfield ("line").nint_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1773 new_error_line = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1774 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1775
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1776 if (! error_state && new_err_stack.contains ("column"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1777 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1778 const int tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1779 new_err_stack.getfield ("column").nint_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1780 new_error_column = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1781 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1782 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1783
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1784 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1785 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1786 Vlast_error_message = new_error_message;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1787 Vlast_error_id = new_error_id;
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1788
16492
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1789 if (new_err.contains ("stack"))
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1790 {
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1791 new_err_stack.setfield ("file", new_error_file);
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1792 new_err_stack.setfield ("name", new_error_name);
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1793 new_err_stack.setfield ("line", new_error_line);
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1794 new_err_stack.setfield ("column", new_error_column);
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1795 Vlast_error_stack = new_err_stack;
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1796 }
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1797 else
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1798 {
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1799 // No stack field. Fill it in with backtrace info.
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1800 octave_idx_type curr_frame = -1;
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1801
16492
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1802 Vlast_error_stack
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1803 = octave_call_stack::backtrace (0, curr_frame);
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1804 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1805 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1806 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1807 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1808 error ("lasterror: argument must be a structure or a string");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1809 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1810
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
1811 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1812 retval = err;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1813 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1814 else
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1815 print_usage ();
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1816
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1817 return retval;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1818 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1819
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1820 DEFUN (lasterr, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1821 "-*- texinfo -*-\n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1822 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr ()\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1823 @deftypefnx {Built-in Function} {} lasterr (@var{msg})\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1824 @deftypefnx {Built-in Function} {} lasterr (@var{msg}, @var{msgid})\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1825 Query or set the last error message. When called without input arguments,\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1826 return the last error message and message identifier. With one\n\
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1827 argument, set the last error message to @var{msg}. With two arguments,\n\
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1828 also set the last message identifier.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1829 @seealso{lasterror, error, lastwarn}\n\
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1830 @end deftypefn")
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1831 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1832 octave_value_list retval;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1833
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
1834 unwind_protect frame;
7976
736124a4fa3d lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents: 7882
diff changeset
1835
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
1836 frame.protect_var (error_state);
7976
736124a4fa3d lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents: 7882
diff changeset
1837 error_state = 0;
736124a4fa3d lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents: 7882
diff changeset
1838
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1839 int argc = args.length () + 1;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1840
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1841 if (argc < 4)
5335
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1842 {
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1843 string_vector argv = args.make_argv ("lasterr");
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1844
5335
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1845 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1846 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1847 std::string prev_error_id = Vlast_error_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1848 std::string prev_error_message = Vlast_error_message;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1849
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1850 if (argc > 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1851 Vlast_error_id = argv(2);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1852
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1853 if (argc > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1854 Vlast_error_message = argv(1);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1855
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1856 if (argc == 1 || nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1857 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1858 retval(1) = prev_error_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1859 retval(0) = prev_error_message;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1860 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1861 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1862 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1863 error ("lasterr: expecting arguments to be character strings");
5335
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1864 }
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1865 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1866 print_usage ();
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1867
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1868 return retval;
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1869 }
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1870
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1871 DEFUN (lastwarn, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1872 "-*- texinfo -*-\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1873 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn ()\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1874 @deftypefnx {Built-in Function} {} lastwarn (@var{msg})\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1875 @deftypefnx {Built-in Function} {} lastwarn (@var{msg}, @var{msgid})\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1876 Query or set the last warning message. When called without input arguments,\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1877 return the last warning message and message identifier. With one\n\
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1878 argument, set the last warning message to @var{msg}. With two arguments,\n\
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1879 also set the last message identifier.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1880 @seealso{warning, lasterror, lasterr}\n\
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1881 @end deftypefn")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1882 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1883 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1884
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1885 int argc = args.length () + 1;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1886
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1887 if (argc < 4)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1888 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1889 string_vector argv = args.make_argv ("lastwarn");
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1890
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1891 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1892 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1893 std::string prev_warning_id = Vlast_warning_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1894 std::string prev_warning_message = Vlast_warning_message;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1895
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1896 if (argc > 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1897 Vlast_warning_id = argv(2);
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1898
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1899 if (argc > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1900 Vlast_warning_message = argv(1);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1901
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1902 if (argc == 1 || nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1903 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1904 warning_state = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1905 retval(1) = prev_warning_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1906 retval(0) = prev_warning_message;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1907 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1908 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1909 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1910 error ("lastwarn: expecting arguments to be character strings");
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1911 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1912 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1913 print_usage ();
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1914
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1915 return retval;
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1916 }
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1917
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
1918 DEFUN (usage, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1919 "-*- texinfo -*-\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1920 @deftypefn {Built-in Function} {} usage (@var{msg})\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1921 Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1922 set Octave's internal error state such that control will return to the\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1923 top level without evaluating any more commands. This is useful for\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1924 aborting from functions.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1925 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1926 After @code{usage} is evaluated, Octave will print a traceback of all\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1927 the function calls leading to the usage message.\n\
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
1928 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1929 You should use this function for reporting problems errors that result\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1930 from an improper call to a function, such as calling a function with an\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1931 incorrect number of arguments, or with arguments of the wrong type. For\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1932 example, most functions distributed with Octave begin with code like\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1933 this\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1934 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1935 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1936 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1937 if (nargin != 2)\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1938 usage (\"foo (a, b)\");\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1939 endif\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1940 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1941 @end example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1942 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1943 @noindent\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1944 to check for the proper number of arguments.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1945 @end deftypefn")
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
1946 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1947 octave_value_list retval;
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1948 handle_message (usage_with_id, "", "unknown", args, true);
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1949 return retval;
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
1950 }
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
1951
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1952 DEFUN (beep_on_error, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1953 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1954 @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1955 @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
1956 @deftypefnx {Built-in Function} {} beep_on_error (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1957 Query or set the internal variable that controls whether Octave will try\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1958 to ring the terminal bell before printing an error message.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
1959 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1960 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1961 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1962 The original variable value is restored when exiting the function.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1963 @end deftypefn")
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
1964 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1965 return SET_INTERNAL_VARIABLE (beep_on_error);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
1966 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
1967
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1968 DEFUN (debug_on_error, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1969 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1970 @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1971 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
1972 @deftypefnx {Built-in Function} {} debug_on_error (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1973 Query or set the internal variable that controls whether Octave will try\n\
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
1974 to enter the debugger when an error is encountered. This will also\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
1975 inhibit printing of the normal traceback message (you will only see\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1976 the top-level error message).\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
1977 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1978 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1979 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1980 The original variable value is restored when exiting the function.\n\
15573
63d024333bee doc: Add seealso links between debug_on_XXX functions (bug #37576)
Rik <rik@octave.org>
parents: 15524
diff changeset
1981 @seealso{debug_on_warning, debug_on_interrupt}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1982 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1983 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1984 return SET_INTERNAL_VARIABLE (debug_on_error);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1985 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
1986
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1987 DEFUN (debug_on_warning, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1988 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1989 @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1990 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
1991 @deftypefnx {Built-in Function} {} debug_on_warning (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1992 Query or set the internal variable that controls whether Octave will try\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1993 to enter the debugger when a warning is encountered.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
1994 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1995 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1996 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1997 The original variable value is restored when exiting the function.\n\
15573
63d024333bee doc: Add seealso links between debug_on_XXX functions (bug #37576)
Rik <rik@octave.org>
parents: 15524
diff changeset
1998 @seealso{debug_on_error, debug_on_interrupt}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1999 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2000 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2001 return SET_INTERNAL_VARIABLE (debug_on_warning);
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
2002 }
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
2003
7977
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2004 std::string
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2005 last_error_message (void)
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2006 {
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2007 return Vlast_error_message;
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2008 }
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2009
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2010 std::string
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2011 last_error_id (void)
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2012 {
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2013 return Vlast_error_id;
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2014 }
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2015
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2016 std::string
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2017 last_warning_message (void)
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2018 {
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2019 return Vlast_warning_message;
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2020 }
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2021
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2022 std::string
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2023 last_warning_id (void)
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2024 {
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2025 return Vlast_warning_id;
065c28e1c368 Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents: 7976
diff changeset
2026 }
11029
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2027
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2028 void
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2029 interpreter_try (unwind_protect& frame)
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2030 {
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2031 frame.protect_var (error_state);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2032 frame.protect_var (buffer_error_messages);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2033 frame.protect_var (Vdebug_on_error);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2034 frame.protect_var (Vdebug_on_warning);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2035
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2036 buffer_error_messages++;
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2037 Vdebug_on_error = false;
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2038 Vdebug_on_warning = false;
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2039 }
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2040
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2041