GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
error.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cstdarg>
31 #include <cstdlib>
32 #include <cstring>
33 
34 #include <algorithm>
35 #include <iomanip>
36 #include <iostream>
37 #include <sstream>
38 #include <string>
39 
40 #include "quit.h"
41 
42 #include "bp-table.h"
43 #include "builtin-defun-decls.h"
44 #include "defun.h"
45 #include "error.h"
46 #include "event-manager.h"
47 #include "input.h"
48 #include "interpreter-private.h"
49 #include "interpreter.h"
50 #include "oct-map.h"
51 #include "octave.h"
52 #include "ov-usr-fcn.h"
53 #include "ov.h"
54 #include "ovl.h"
55 #include "pager.h"
56 #include "pt-eval.h"
57 #include "unwind-prot.h"
58 #include "utils.h"
59 #include "variables.h"
60 
61 static std::string
62 format_message (const char *fmt, va_list args)
63 {
64  if (! fmt)
65  return "";
66 
67  std::ostringstream output_buf;
68 
69  octave::vformat (output_buf, fmt, args);
70 
71  return output_buf.str ();
72 }
73 
74 OCTAVE_NORETURN
75 static void
76 error_1 (octave::execution_exception& ee, const char *id, const char *fmt,
77  va_list args)
78 {
79  octave::error_system& es = octave::__get_error_system__ ();
80 
81  es.error_1 (ee, id, fmt, args);
82 }
83 
84 OCTAVE_NORETURN
85 static void
86 error_1 (const char *id, const char *fmt, va_list args)
87 {
88  octave::error_system& es = octave::__get_error_system__ ();
89 
90  es.error_1 (id, fmt, args);
91 }
92 
93 static int
94 check_state (const std::string& state)
95 {
96  // -1: not found
97  // 0: found, "off"
98  // 1: found, "on"
99  // 2: found, "error"
100 
101  if (state == "off")
102  return 0;
103  else if (state == "on")
104  return 1;
105  else if (state == "error")
106  return 2;
107  else
108  return -1;
109 }
110 
111 static void
112 vwarning (const char *id, const char *fmt, va_list args)
113 {
114  octave::error_system& es = octave::__get_error_system__ ();
115 
116  es.vwarning (id, fmt, args);
117 }
118 
119 static void
120 defun_usage_message (const char *fmt, ...)
121 {
122  va_list args;
123  va_start (args, fmt);
124  error_1 ("", fmt, args);
125  va_end (args);
126 }
127 
128 typedef void (*error_fcn)(const char *, const char *, ...);
129 
130 static std::string
131 handle_message (error_fcn f, const char *id, const char *msg,
132  const octave_value_list& args, bool have_fmt)
133 {
134  std::string retval;
135 
136  std::string tmpstr;
137 
138  if (args.length () > 0)
139  {
140  octave_value arg;
141 
142  if (have_fmt)
143  {
144  octave_value_list tmp = octave::Fsprintf (args, 1);
145  arg = tmp(0);
146  }
147  else
148  arg = args(0);
149 
150  if (arg.is_defined ())
151  {
152  if (arg.isempty ())
153  return retval;
154  else if (arg.is_string ())
155  {
156  tmpstr = arg.string_value (); // 2-stage assignment required
157  msg = tmpstr.c_str (); // in order to generate pointer
158  // to valid memory.
159  }
160  }
161  }
162 
163  // Ugh.
164 
165  std::size_t len = strlen (msg);
166 
167  if (len > 0)
168  {
169  if (msg[len - 1] == '\n')
170  {
171  if (len > 1)
172  {
173  std::string tmp_msg (msg, len - 1);
174  f (id, "%s\n", tmp_msg.c_str ());
175  retval = tmp_msg;
176  }
177  }
178  else
179  {
180  f (id, "%s", msg);
181  retval = msg;
182  }
183  }
184 
185  return retval;
186 }
187 
188 // Determine whether the first argument to error or warning function
189 // should be handled as the message identifier or as the format string.
190 
191 static bool
192 maybe_extract_message_id (const std::string& caller,
193  const octave_value_list& args,
194  octave_value_list& nargs,
195  std::string& id)
196 {
197  nargs = args;
198  id = "";
199 
200  int nargin = args.length ();
201 
202  bool have_fmt = nargin > 1;
203 
204  if (nargin > 0)
205  {
206  std::string arg1 = args(0).string_value ();
207 
208  // For compatibility with Matlab, an identifier must contain ':',
209  // but not at the beginning or the end, and it must not contain '%'
210  // (even if it is not a valid conversion operator) or whitespace.
211 
212  if (arg1.find_first_of ("% \f\n\r\t\v") == std::string::npos
213  && arg1.find (':') != std::string::npos
214  && arg1[0] != ':'
215  && arg1.back () != ':')
216  {
217  if (nargin > 1)
218  {
219  id = arg1;
220 
221  nargs.resize (nargin-1);
222 
223  for (int i = 1; i < nargin; i++)
224  nargs(i-1) = args(i);
225  }
226  else
227  nargs(0) = "call to " + caller
228  + " with message identifier '" + arg1
229  + "' requires message";
230  }
231  }
232 
233  return have_fmt;
234 }
235 
237 
238 static octave_scalar_map
239 init_warning_options (const std::string& state)
240 {
241  octave_scalar_map initw;
242 
243  initw.setfield ("identifier", "all");
244  initw.setfield ("state", state);
245 
246  return initw;
247 }
248 
249 static octave_map
251 {
252  tree_evaluator& tw = interp.get_evaluator ();
253 
254  return tw.empty_backtrace ();
255 }
256 
258  : m_interpreter (interp),
259  m_debug_on_error (false),
260  m_debug_on_caught (false),
261  m_debug_on_warning (false),
262  m_discard_warning_messages (false),
263  m_beep_on_error (false),
264  m_backtrace_on_warning (true),
265  m_verbose_warning (false),
266  m_quiet_warning (false),
267  m_warning_options (init_warning_options ("on")),
268  m_last_error_message (),
269  m_last_warning_message (),
270  m_last_warning_id (),
271  m_last_error_id (),
272  m_last_error_stack (init_error_stack (interp))
273 {
275 }
276 
279 {
280  return set_internal_variable (m_debug_on_error, args, nargout,
281  "debug_on_error");
282 }
283 
286 {
287  return set_internal_variable (m_debug_on_caught, args, nargout,
288  "debug_on_caught");
289 }
290 
293 {
294  return set_internal_variable (m_debug_on_warning, args, nargout,
295  "debug_on_warning");
296 }
297 
300  int nargout)
301 {
302  return set_internal_variable (m_discard_warning_messages, args, nargout,
303  "discard_warning_messages");
304 }
305 
308 {
309  return set_internal_variable (m_beep_on_error, args, nargout,
310  "beep_on_error");
311 }
312 
315  int nargout)
316 {
317  return set_internal_variable (m_backtrace_on_warning, args, nargout,
318  "backtrace_on_warning");
319 }
320 
323 {
324  return set_internal_variable (m_verbose_warning, args, nargout,
325  "verbose_warning");
326 }
327 
330 {
331  return set_internal_variable (m_quiet_warning, args, nargout,
332  "quiet_warning");
333 }
334 
337 {
338  return set_internal_variable (m_last_error_message, args, nargout,
339  "last_error_message");
340 }
341 
344  int nargout)
345 {
346  return set_internal_variable (m_last_warning_message, args, nargout,
347  "last_warning_message");
348 }
349 
352 {
353  return set_internal_variable (m_last_warning_id, args, nargout,
354  "last_warning_id");
355 }
356 
359 {
360  return set_internal_variable (m_last_error_id, args, nargout,
361  "last_error_id");
362 }
363 
364 // Use static fields for the best efficiency.
365 // NOTE: C++0x will allow these two to be merged into one.
366 static const char *bt_fieldnames[] =
367 { "file", "name", "line", "column", nullptr };
368 
370 
372 error_system::make_stack_map (const std::list<frame_info>& frames)
373 {
374  std::size_t nframes = frames.size ();
375 
376  octave_map retval (dim_vector (nframes, 1), bt_fields);
377 
378  Cell& file = retval.contents (0);
379  Cell& name = retval.contents (1);
380  Cell& line = retval.contents (2);
381  Cell& column = retval.contents (3);
382 
383  octave_idx_type k = 0;
384 
385  for (const auto& frm : frames)
386  {
387  file(k) = frm.file_name ();
388  name(k) = frm.fcn_name ();
389  line(k) = frm.line ();
390  column(k) = frm.column ();
391 
392  k++;
393  }
394 
395  return retval;
396 }
397 
398 std::list<frame_info>
400 {
401  std::list<frame_info> frames;
402 
403  Cell file = stack.contents ("file");
404  Cell name = stack.contents ("name");
405  Cell line = stack.contents ("line");
406  Cell column = stack.contents ("column");
407 
408  octave_idx_type nel = name.numel ();
409 
410  for (octave_idx_type i = 0; i < nel; i++)
411  frames.push_back (frame_info (file(i).string_value (),
412  name(i).string_value (),
413  line(i).int_value (),
414  column(i).int_value ()));
415 
416  return frames;
417 }
418 
419 // For given warning ID, return 0 if warnings are disabled, 1 if
420 // enabled, and 2 if the given ID should be an error instead of a
421 // warning.
422 
423 int error_system::warning_enabled (const std::string& id)
424 {
425  int retval = 0;
426 
427  int all_state = -1;
428  int id_state = -1;
429 
430  octave_map opts = warning_options ();
431 
432  octave_idx_type nel = opts.numel ();
433 
434  if (nel > 0)
435  {
436  Cell identifier = opts.contents ("identifier");
437  Cell state = opts.contents ("state");
438 
439  bool all_found = false;
440  bool id_found = false;
441 
442  for (octave_idx_type i = 0; i < nel; i++)
443  {
444  octave_value ov = identifier(i);
445  std::string ovs = ov.string_value ();
446 
447  if (! all_found && ovs == "all")
448  {
449  all_state = check_state (state(i).string_value ());
450 
451  if (all_state >= 0)
452  all_found = true;
453  }
454 
455  if (! id_found && ovs == id)
456  {
457  id_state = check_state (state(i).string_value ());
458 
459  if (id_state >= 0)
460  id_found = true;
461  }
462 
463  if (all_found && id_found)
464  break;
465  }
466  }
467 
468  // If "all" is not present, assume warnings are enabled.
469  if (all_state == -1)
470  all_state = 1;
471 
472  if (all_state == 0)
473  {
474  if (id_state >= 0)
475  retval = id_state;
476  }
477  else if (all_state == 1)
478  {
479  if (id_state == 0 || id_state == 2)
480  retval = id_state;
481  else
482  retval = all_state;
483  }
484  else if (all_state == 2)
485  {
486  if (id_state == 0)
487  retval= id_state;
488  else
489  retval = all_state;
490  }
491 
492  return retval;
493 }
494 
495 void error_system::vusage (const char *id, const char *fmt, va_list args)
496 {
497  std::string str_id = id ? id : "";
498  std::string message = format_message (fmt, args);
499 
500  throw_error ("usage", str_id, message);
501 }
502 
503 void error_system::vwarning (const char *name, const char *id,
504  const char *fmt, va_list args)
505 {
506  flush_stdout ();
507 
508  std::string base_msg = format_message (fmt, args);
509  std::string msg_string;
510 
511  if (name)
512  msg_string = std::string (name) + ": ";
513 
514  msg_string += base_msg;
515 
516  bool fmt_suppresses_backtrace = false;
517  std::size_t fmt_len = (fmt ? strlen (fmt) : 0);
518  fmt_suppresses_backtrace = (fmt_len > 0 && fmt[fmt_len-1] == '\n');
519 
520  if (! fmt_suppresses_backtrace)
521  msg_string += '\n';
522 
523  last_warning_id (id);
524  last_warning_message (base_msg);
525 
527  return;
528 
530 
531  bool in_user_code = tw.in_user_code ();
532 
533  if (! quiet_warning ())
534  {
535  octave_diary << msg_string;
536  std::cerr << msg_string;
537 
538  if (! fmt_suppresses_backtrace && in_user_code
540  && ! discard_warning_messages ())
541  {
542  std::string bt_msg = tw.backtrace_message ();
543 
544  if (! bt_msg.empty ())
545  bt_msg = "warning: called from\n" + bt_msg;
546 
547  octave_diary << bt_msg << std::endl;
548  std::cerr << bt_msg << std::endl;
549  }
550  }
551 
552  bp_table& bptab = tw.get_bp_table ();
553 
554  if ((m_interpreter.interactive ()
556  && debug_on_warning () && in_user_code && bptab.debug_on_warn (id))
557  {
558  unwind_protect_var<bool> restore_var (m_debug_on_warning, false);
559 
560  tw.enter_debugger ();
561  }
562 }
563 
564 void error_system::error_1 (execution_exception& ee, const char *id,
565  const char *fmt, va_list args)
566 {
567  ee.set_identifier (id);
568  ee.set_message (format_message (fmt, args));
569 
570  throw_error (ee);
571 }
572 
573 void error_system::error_1 (const char *id, const char *fmt,
574  va_list args)
575 {
576  std::string message = format_message (fmt, args);
577 
578  std::list<frame_info> stack_info;
579 
580  throw_error ("error", id, message);
581 }
582 
583 void error_system::vwarning (const char *id, const char *fmt, va_list args)
584 {
585  int warn_opt = warning_enabled (id);
586 
587  if (warn_opt == 2)
588  {
589  // Handle this warning as an error.
590 
591  error_1 (id, fmt, args);
592  }
593  else if (warn_opt == 1)
594  vwarning ("warning", id, fmt, args);
595 }
596 
597 void error_system::rethrow_error (const std::string& id,
598  const std::string& msg,
599  const octave_map& stack)
600 {
601  std::list<frame_info> stack_info;
602 
603  execution_exception ee ("error", id, msg, stack_info);
604 
605  if (! stack.isempty ())
606  {
607  if (! (stack.contains ("file") && stack.contains ("name")
608  && stack.contains ("line")))
609  error ("rethrow: STACK struct must contain the fields 'file', 'name', and 'line'");
610 
611  if (! stack.contains ("column"))
612  {
613  octave_map new_stack = stack;
614 
615  new_stack.setfield ("column", Cell (octave_value (-1)));
616 
617  ee.set_stack_info (make_stack_frame_list (new_stack));
618  }
619  else
620  ee.set_stack_info (make_stack_frame_list (stack));
621  }
622 
623  throw_error (ee);
624 }
625 
626 void error_system::vpanic (const char *fmt, va_list args)
627 {
628  // Is there any point in trying to write the panic message to the
629  // diary?
630 
631  std::cerr << "panic: " << format_message (fmt, args) << std::endl;
632 
633  abort ();
634 }
635 
636 void error_system::panic (const char *fmt, ...)
637 {
638  va_list args;
639  va_start (args, fmt);
640  vpanic (fmt, args);
641  va_end (args);
642 }
643 
645 {
646  octave_scalar_map retval;
647 
648  std::string id = id_arg;
649 
650  if (id == "last")
651  id = last_warning_id ();
652 
653  octave_map opts = warning_options ();
654 
655  Cell ident = opts.contents ("identifier");
656  Cell state = opts.contents ("state");
657 
658  octave_idx_type nel = ident.numel ();
659 
660  panic_if (nel == 0);
661 
662  bool found = false;
663 
664  std::string val;
665 
666  for (octave_idx_type i = 0; i < nel; i++)
667  {
668  if (ident(i).string_value () == id)
669  {
670  val = state(i).string_value ();
671  found = true;
672  break;
673  }
674  }
675 
676  if (! found)
677  {
678  for (octave_idx_type i = 0; i < nel; i++)
679  {
680  if (ident(i).string_value () == "all")
681  {
682  val = state(i).string_value ();
683  found = true;
684  break;
685  }
686  }
687  }
688 
689  // The warning state "all" is always supposed to remain in the list,
690  // so we should always find a state, either explicitly or by using the
691  // state for "all".
692  panic_unless (found);
693 
694  retval.assign ("identifier", id);
695  retval.assign ("state", val);
696 
697  return retval;
698 }
699 
701 {
702  std::string retval = "on";
703 
704  octave_map opts = warning_options ();
705 
706  Cell ident = opts.contents ("identifier");
707  Cell state = opts.contents ("state");
708 
709  octave_idx_type nel = ident.numel ();
710 
711  for (octave_idx_type i = 0; i < nel; i++)
712  {
713  if (ident(i).string_value () == "all")
714  {
715  retval = state(i).string_value ();
716  break;
717  }
718  }
719 
720  return retval;
721 }
722 
724 {
725  octave_map opts = warning_options ();
726 
727  Cell ident = opts.contents ("identifier");
728  Cell state = opts.contents ("state");
729 
730  octave_idx_type nel = ident.numel ();
731 
732  std::string all_state = default_warning_state ();
733 
734  if (all_state == "on")
735  os << "By default, warnings are enabled.";
736  else if (all_state == "off")
737  os << "By default, warnings are disabled.";
738  else if (all_state == "error")
739  os << "By default, warnings are treated as errors.";
740  else
741  panic_impossible ();
742 
743  if (nel > 1)
744  {
745  os << "\n";
746  os << "Non-default warning states are:\n\n";
747  os << " State Warning ID\n";
748  }
749 
750  // The state for "all" is always supposed to be first in the list.
751 
752  for (octave_idx_type i = 1; i < nel; i++)
753  {
754  std::string tid = ident(i).string_value ();
755  std::string tst = state(i).string_value ();
756 
757  os << std::setw (7) << tst << " " << tid << "\n";
758  }
759 
760  os << std::endl;
761 }
762 
763 void error_system::set_warning_option (const std::string& state,
764  const std::string& ident)
765 {
766  std::string all_state = default_warning_state ();
767 
768  if (state != "on" && state != "off" && state != "error")
769  error ("invalid warning state: %s", state.c_str ());
770 
771  octave_map opts = warning_options ();
772 
773  Cell tid = opts.contents ("identifier");
774  Cell tst = opts.contents ("state");
775 
776  octave_idx_type nel = tid.numel ();
777 
778  for (octave_idx_type i = 0; i < nel; i++)
779  {
780  if (tid(i).string_value () == ident)
781  {
782  // We found it in the current list of options. If the state
783  // for "all" is same as arg1, we can simply remove the item
784  // from the list.
785 
786  if (state == all_state && ident != "all")
787  {
788  for (i = i + 1; i < nel; i++)
789  {
790  tid(i-1) = tid(i);
791  tst(i-1) = tst(i);
792  }
793 
794  tid.resize (dim_vector (1, nel-1));
795  tst.resize (dim_vector (1, nel-1));
796  }
797  else
798  tst(i) = state;
799 
800  opts.clear ();
801 
802  opts.assign ("identifier", tid);
803  opts.assign ("state", tst);
804 
805  warning_options (opts);
806 
807  return;
808  }
809  }
810 
811  // The option wasn't already in the list. Append it.
812 
813  tid.resize (dim_vector (1, nel+1));
814  tst.resize (dim_vector (1, nel+1));
815 
816  tid(nel) = ident;
817  tst(nel) = state;
818 
819  opts.clear ();
820 
821  opts.assign ("identifier", tid);
822  opts.assign ("state", tst);
823 
824  warning_options (opts);
825 }
826 
827 void error_system::disable_warning (const std::string& id)
828 {
829  set_warning_option ("off", id);
830 }
831 
833 {
835 
836  // Most people will want to have the following disabled.
837 
838  disable_warning ("Octave:array-as-logical");
839  disable_warning ("Octave:array-to-scalar");
840  disable_warning ("Octave:array-to-vector");
841  disable_warning ("Octave:imag-to-real");
842  disable_warning ("Octave:language-extension");
843  disable_warning ("Octave:missing-semicolon");
844  disable_warning ("Octave:neg-dim-as-zero");
845  disable_warning ("Octave:separator-insert");
846  disable_warning ("Octave:single-quote-string");
847  disable_warning ("Octave:str-to-num");
848  disable_warning ("Octave:mixed-string-concat");
849  disable_warning ("Octave:variable-switch-label");
850 }
851 
853 {
855  m_debug_on_error = false;
856 
858  m_debug_on_warning = false;
859 
860  // Leave debug_on_caught as it was, so errors in try/catch are still
861  // caught.
862 }
863 
864 void error_system::throw_error (const std::string& err_type,
865  const std::string& id,
866  const std::string& message,
867  const std::list<frame_info>& stack_info_arg)
868 {
869  std::list<frame_info> stack_info = stack_info_arg;
870 
871  if (stack_info.empty ())
872  {
874 
875  stack_info = tw.backtrace_info ();
876 
877  // Print the error message only if it is different from the
878  // previous one; makes the output more concise and readable.
879 
880  stack_info.unique ();
881  }
882 
883  execution_exception ex (err_type, id, message, stack_info);
884 
885  throw_error (ex);
886 }
887 
889 {
890  throw ex;
891 }
892 
894 {
895  last_error_id (ee.identifier ());
896  std::string message = ee.message ();
897  std::string xmsg
898  = (message.size () > 0 && message.back () == '\n'
899  ? message.substr (0, message.size () - 1) : message);
900  last_error_message (xmsg);
901  last_error_stack (make_stack_map (ee.stack_info ()));
902 }
903 
904 // DEPRECATED in Octave 7.
906  std::ostream& os) const
907 {
908  if (m_beep_on_error)
909  os << "\a";
910 
911  ee.display (octave_diary);
912  ee.display (os);
913 }
914 
916 {
917  // FIXME: How should we handle beep_on_error?
918 
919  ee.display (octave_diary);
920 
921  // FIXME: Handle display using an event manager message so that the
922  // GUI or other client can receive error messages without needing to
923  // capture them from std::cerr or some other stream.
924 
926 
928 }
929 
931 
932 void
933 vmessage (const char *name, const char *fmt, va_list args)
934 {
935  std::string message;
936 
937  if (name)
938  message = std::string (name) + ": ";
939 
940  message += format_message (fmt, args);
941 
942  octave_diary << message << std::endl;
943  std::cerr << message << std::endl;
944 }
945 
946 void
947 message (const char *name, const char *fmt, ...)
948 {
949  va_list args;
950  va_start (args, fmt);
951  vmessage (name, fmt, args);
952  va_end (args);
953 }
954 
955 void
956 vusage_with_id (const char *id, const char *fmt, va_list args)
957 {
958  octave::error_system& es = octave::__get_error_system__ ();
959 
960  es.vusage (id, fmt, args);
961 }
962 
963 void
964 usage_with_id (const char *id, const char *fmt, ...)
965 {
966  va_list args;
967  va_start (args, fmt);
968  vusage_with_id (id, fmt, args);
969  va_end (args);
970 }
971 
972 void
973 verror (const char *fmt, va_list args)
974 {
975  error_1 ("", fmt, args);
976 }
977 
978 void
979 error (const char *fmt, ...)
980 {
981  va_list args;
982  va_start (args, fmt);
983  verror (fmt, args);
984  va_end (args);
985 }
986 
987 void
988 verror (octave::execution_exception& ee, const char *fmt, va_list args)
989 {
990  error_1 (ee, "", fmt, args);
991 }
992 
993 void
994 error (octave::execution_exception& ee, const char *fmt, ...)
995 {
996  va_list args;
997  va_start (args, fmt);
998  verror (ee, fmt, args);
999  va_end (args);
1000 }
1001 
1002 void
1003 verror_with_cfn (const char *fmt, va_list args)
1004 {
1005  error_1 ("", fmt, args);
1006 }
1007 
1008 void
1009 error_with_cfn (const char *fmt, ...)
1010 {
1011  va_list args;
1012  va_start (args, fmt);
1013  verror_with_cfn (fmt, args);
1014  va_end (args);
1015 }
1016 
1017 void
1018 verror_with_id (const char *id, const char *fmt, va_list args)
1019 {
1020  error_1 (id, fmt, args);
1021 }
1022 
1023 void
1024 error_with_id (const char *id, const char *fmt, ...)
1025 {
1026  va_list args;
1027  va_start (args, fmt);
1028  verror_with_id (id, fmt, args);
1029  va_end (args);
1030 }
1031 
1032 void
1033 verror_with_id_cfn (const char *id, const char *fmt, va_list args)
1034 {
1035  error_1 (id, fmt, args);
1036 }
1037 
1038 void
1039 error_with_id_cfn (const char *id, const char *fmt, ...)
1040 {
1041  va_list args;
1042  va_start (args, fmt);
1043  verror_with_id_cfn (id, fmt, args);
1044  va_end (args);
1045 }
1046 
1047 void
1048 vwarning (const char *fmt, va_list args)
1049 {
1050  vwarning ("", fmt, args);
1051 }
1052 
1053 void
1054 warning (const char *fmt, ...)
1055 {
1056  va_list args;
1057  va_start (args, fmt);
1058  vwarning (fmt, args);
1059  va_end (args);
1060 }
1061 
1062 void
1063 vwarning_with_id (const char *id, const char *fmt, va_list args)
1064 {
1065  vwarning (id, fmt, args);
1066 }
1067 
1068 void
1069 warning_with_id (const char *id, const char *fmt, ...)
1070 {
1071  va_list args;
1072  va_start (args, fmt);
1073  vwarning (id, fmt, args);
1074  va_end (args);
1075 }
1076 
1077 void
1078 vparse_error (const char *fmt, va_list args)
1079 {
1080  error_1 ("", fmt, args);
1081 }
1082 
1083 void
1084 parse_error (const char *fmt, ...)
1085 {
1086  va_list args;
1087  va_start (args, fmt);
1088  vparse_error (fmt, args);
1089  va_end (args);
1090 }
1091 
1092 void
1093 vparse_error_with_id (const char *id, const char *fmt, va_list args)
1094 {
1095  error_1 (id, fmt, args);
1096 }
1097 
1098 void
1099 parse_error_with_id (const char *id, const char *fmt, ...)
1100 {
1101  va_list args;
1102  va_start (args, fmt);
1103  vparse_error_with_id (id, fmt, args);
1104  va_end (args);
1105 }
1106 
1107 OCTAVE_NORETURN
1108 void
1109 vpanic (const char *fmt, va_list args)
1110 {
1111  octave::error_system& es = octave::__get_error_system__ ();
1112 
1113  es.vpanic (fmt, args);
1114 }
1115 
1116 OCTAVE_NORETURN
1117 void
1118 panic (const char *fmt, ...)
1119 {
1120  va_list args;
1121  va_start (args, fmt);
1122  vpanic (fmt, args);
1123  va_end (args);
1124 }
1125 
1127 
1128 void
1129 defun_usage_message (const std::string& msg)
1130 {
1131  ::defun_usage_message ("%s", msg.c_str ());
1132 }
1133 
1134 DEFMETHOD (rethrow, interp, args, ,
1135  doc: /* -*- texinfo -*-
1136 @deftypefn {} {} rethrow (@var{err})
1137 Reissue a previous error as defined by @var{err}.
1138 
1139 @var{err} is a structure that must contain at least the @qcode{"message"}
1140 and @qcode{"identifier"} fields. @var{err} can also contain a field
1141 @qcode{"stack"} that gives information on the assumed location of the
1142 error. Typically @var{err} is returned from @code{lasterror}.
1143 @seealso{lasterror, lasterr, error}
1144 @end deftypefn */)
1145 {
1146  if (args.length () != 1)
1147  print_usage ();
1148 
1149  const octave_scalar_map err = args(0).scalar_map_value ();
1150 
1151  if (! (err.contains ("message") && err.contains ("identifier")))
1152  error ("rethrow: ERR struct must contain the fields 'message' and 'identifier'");
1153 
1154  std::string msg = err.contents ("message").string_value ();
1155  std::string id = err.contents ("identifier").string_value ();
1156 
1157  octave_map err_stack = init_error_stack (interp);
1158 
1159  if (err.contains ("stack"))
1160  err_stack = err.contents ("stack").xmap_value ("ERR.STACK must be a struct");
1161 
1162  error_system& es = interp.get_error_system ();
1163 
1164  es.rethrow_error (id, msg, err_stack);
1165 
1166  return ovl ();
1167 }
1168 
1169 DEFMETHOD (error, interp, args, ,
1170  doc: /* -*- texinfo -*-
1171 @deftypefn {} {} error (@var{template}, @dots{})
1172 @deftypefnx {} {} error (@var{id}, @var{template}, @dots{})
1173 Display an error message and stop m-file execution.
1174 
1175 Format the optional arguments under the control of the template string
1176 @var{template} using the same rules as the @code{printf} family of
1177 functions (@pxref{Formatted Output}) and print the resulting message
1178 on the @code{stderr} stream. This formatting is only done for
1179 single-quoted character vectors if there are additional arguments
1180 following the template string. If there are no additional arguments, the
1181 template string is used literally (i.e., without interpreting any escape
1182 sequences in single-quoted character vectors). The message is prefixed
1183 by @samp{error: }.
1184 
1185 Calling @code{error} also sets Octave's internal error state such that
1186 control will return to the top level without evaluating any further
1187 commands. This is useful for aborting from functions or scripts.
1188 
1189 If the error message does not end with a newline character, Octave will
1190 print a traceback of all the function calls leading to the error. For
1191 example, given the following function definitions:
1192 
1193 @example
1194 @group
1195 function f () g (); end
1196 function g () h (); end
1197 function h () nargin == 1 || error ("nargin != 1"); end
1198 @end group
1199 @end example
1200 
1201 @noindent
1202 calling the function @code{f} will result in a list of messages that
1203 can help you to quickly find the exact location of the error:
1204 
1205 @example
1206 @group
1207 f ()
1208 error: nargin != 1
1209 error: called from:
1210 error: h at line 1, column 27
1211 error: g at line 1, column 15
1212 error: f at line 1, column 15
1213 @end group
1214 @end example
1215 
1216 If the error message ends in a newline character, Octave will print the
1217 message but will not display any traceback messages as it returns
1218 control to the top level. For example, modifying the error message
1219 in the previous example to end in a newline causes Octave to only print
1220 a single message:
1221 
1222 @example
1223 @group
1224 function h () nargin == 1 || error ("nargin != 1\n"); end
1225 f ()
1226 error: nargin != 1
1227 @end group
1228 @end example
1229 
1230 A null string ("") input to @code{error} will be ignored and the code
1231 will continue running as if the statement were a NOP@. This is for
1232 compatibility with @sc{matlab}. It also makes it possible to write code
1233 such as
1234 
1235 @example
1236 @group
1237 err_msg = "";
1238 if (CONDITION 1)
1239  err_msg = "CONDITION 1 found";
1240 elseif (CONDITION2)
1241  err_msg = "CONDITION 2 found";
1242 @dots{}
1243 endif
1244 error (err_msg);
1245 @end group
1246 @end example
1247 
1248 @noindent
1249 which will only stop execution if an error has been found.
1250 
1251 Implementation Note: For compatibility with @sc{matlab}, escape
1252 sequences in @var{template} (e.g., @qcode{"@backslashchar{}n"} =>
1253 newline) are processed regardless of whether @var{template} has been defined
1254 with single quotes, as long as there are two or more input arguments. To
1255 disable escape sequence expansion use a second backslash before the sequence
1256 (e.g., @qcode{"@backslashchar{}@backslashchar{}n"}) or use the
1257 @code{regexptranslate} function.
1258 @seealso{warning, lasterror}
1259 @end deftypefn */)
1260 {
1261  int nargin = args.length ();
1262 
1263  if (nargin == 0)
1264  print_usage ();
1265 
1266  octave_value retval;
1267 
1268  std::string id;
1269  std::string message;
1270  std::list<frame_info> stack_info;
1271 
1272  bool have_fmt = false;
1273 
1274  if (nargin == 1 && args(0).isstruct ())
1275  {
1276  // empty struct is not an error. return and resume calling function.
1277  if (args(0).isempty ())
1278  return retval;
1279 
1280  octave_scalar_map m = args(0).scalar_map_value ();
1281 
1282  // empty struct is not an error. return and resume calling function.
1283  if (m.nfields () == 0)
1284  return retval;
1285 
1286  if (m.contains ("message"))
1287  {
1288  octave_value c = m.getfield ("message");
1289 
1290  if (c.is_string ())
1291  message = c.string_value ();
1292  }
1293 
1294  if (m.contains ("identifier"))
1295  {
1296  octave_value c = m.getfield ("identifier");
1297 
1298  if (c.is_string ())
1299  id = c.string_value ();
1300  }
1301 
1302  if (m.contains ("stack"))
1303  {
1304  octave_value c = m.getfield ("stack");
1305 
1306  if (c.isstruct ())
1307  stack_info
1309  }
1310  }
1311  else
1312  {
1313  octave_value_list nargs = args;
1314 
1315  have_fmt = maybe_extract_message_id ("error", args, nargs, id);
1316 
1317  if (nargs.length () == 0)
1318  message = "unspecified error";
1319  else
1320  {
1321  octave_value arg;
1322 
1323  if (have_fmt)
1324  {
1325  octave_value_list tmp = Fsprintf (nargs, 1);
1326  arg = tmp(0);
1327  }
1328  else
1329  arg = nargs(0);
1330 
1331  if (arg.is_defined ())
1332  {
1333  if (arg.isempty ())
1334  message = "";
1335  else if (arg.is_string ())
1336  message = arg.string_value ();
1337  }
1338  }
1339  }
1340 
1341  if (message.empty ())
1342  return retval;
1343 
1344  error_system& es = interp.get_error_system ();
1345 
1346  es.throw_error ("error", id, message, stack_info);
1347 
1348  return retval;
1349 }
1350 
1351 DEFMETHOD (warning, interp, args, nargout,
1352  doc: /* -*- texinfo -*-
1353 @deftypefn {} {} warning (@var{template}, @dots{})
1354 @deftypefnx {} {} warning (@var{id}, @var{template}, @dots{})
1355 @deftypefnx {} {} warning ("on", @var{id})
1356 @deftypefnx {} {} warning ("off", @var{id})
1357 @deftypefnx {} {} warning ("error", @var{id})
1358 @deftypefnx {} {} warning ("query", @var{id})
1359 @deftypefnx {} {} warning (@var{state}, @var{id}, "local")
1360 @deftypefnx {} {} warning (@var{warning_struct})
1361 @deftypefnx {} {@var{warning_struct} =} warning (@dots{})
1362 @deftypefnx {} {} warning (@var{state}, @var{mode})
1363 
1364 Display a warning message or control the behavior of Octave's warning system.
1365 
1366 The first call form uses a template @var{template} and optional additional
1367 arguments to display a message on the @code{stderr} stream. The message is
1368 formatted using the same rules as the @code{printf} family of functions
1369 (@pxref{Formatted Output}) and prefixed by the character string
1370 @w{@samp{warning: }}. You should use this function when you want to notify the
1371 user of an unusual condition, but only when it makes sense for your program to
1372 go on. For example:
1373 
1374 @example
1375 @group
1376 warning ("foo: maybe something wrong here");
1377 @end group
1378 @end example
1379 
1380 If the warning message does not end with a newline character, Octave will
1381 print a traceback of all the function calls leading to the warning. If the
1382 warning message does end in a newline character, Octave will suppress the
1383 traceback messages as it returns control to the top level. For more details
1384 and examples, @pxref{XREFerror,,@code{error}}.
1385 
1386 The optional warning identifier @var{id} allows users to enable or disable
1387 warnings tagged by this identifier. A message identifier is a string of the
1388 form @qcode{"NAMESPACE:WARNING-NAME"}. Octave's own warnings use the
1389 @qcode{"Octave"} namespace (@pxref{XREFwarning_ids,,@code{warning_ids}}). For
1390 example:
1391 
1392 @example
1393 @group
1394 warning ("MyNameSpace:check-something",
1395  "foo: maybe something wrong here");
1396 @end group
1397 @end example
1398 
1399 The second call form is meant to change and/or query the state of warnings.
1400 The first input argument must be a string @var{state} (@qcode{"on"},
1401 @qcode{"off"}, @qcode{"error"}, or @qcode{"query"}) followed by an optional
1402 warning identifier @var{id} or @qcode{"all"} (default).
1403 
1404 The optional output argument @var{warning_struct} is a structure or structure
1405 array with fields @qcode{"state"} and @qcode{"identifier"}. The @var{state}
1406 argument may have the following values:
1407 
1408 @table @asis
1409 @item @qcode{"on"}|@qcode{"off"}:
1410 Enable or disable the display of warnings identified by @var{id} and optionally
1411 return their previous state @var{stout}.
1412 
1413 @item @qcode{"error"}:
1414 Turn warnings identified by @var{id} into errors and optionally return their
1415 previous state @var{stout}.
1416 
1417 @item @qcode{"query"}:
1418 Return the current state of warnings identified by @var{id}.
1419 @end table
1420 
1421 A structure or structure array @var{warning_struct}, with fields
1422 @qcode{"state"} and @qcode{"identifier"}, may be given as an input to achieve
1423 equivalent results. The following example shows how to temporarily disable a
1424 warning and then restore its original state:
1425 
1426 @example
1427 @group
1428 loglog (-1:10);
1429 ## Disable the previous warning and save its original state
1430 [~, id] = lastwarn ();
1431 warnstate = warning ("off", id);
1432 loglog (-1:10);
1433 ## Restore its original state
1434 warning (warnstate);
1435 @end group
1436 @end example
1437 
1438 If a final argument @qcode{"local"} is provided then the warning state will be
1439 set temporarily until the end of the current function. Changes to warning
1440 states that are set locally affect the current function and all functions
1441 called from the current scope. The previous warning state is restored on
1442 return from the current function. The @qcode{"local"} option is ignored if
1443 used in the top-level workspace.
1444 
1445 With no input argument @code{warning ()} is equivalent to
1446 @code{warning ("query", "all")} except that in the absence of an output
1447 argument, the state of warnings is displayed on @code{stderr}.
1448 
1449 The level of verbosity of the warning system may also be controlled by two
1450 modes @var{mode}:
1451 
1452 @table @asis
1453 @item @qcode{"backtrace"}:
1454 enable/disable the display of the stack trace after the warning message
1455 
1456 @item @qcode{"verbose"}:
1457 enable/disable the display of additional information after the warning message
1458 @end table
1459 
1460 In this case the @var{state} argument may only be @qcode{"on"} or
1461 @qcode{"off"}.
1462 
1463 Implementation Note: For compatibility with @sc{matlab}, escape sequences in
1464 @var{template} (e.g., @qcode{"@backslashchar{}n"} => newline) are processed
1465 regardless of whether @var{template} has been defined with single quotes, as
1466 long as there are two or more input arguments. To disable escape sequence
1467 expansion use a second backslash before the sequence (e.g.,
1468 @qcode{"@backslashchar{}@backslashchar{}n"}) or use the
1469 @code{regexptranslate} function.
1470 @seealso{warning_ids, lastwarn, error}
1471 @end deftypefn */)
1472 {
1473  octave_value retval;
1474 
1475  int nargin = args.length ();
1476  bool done = false;
1477 
1478  error_system& es = interp.get_error_system ();
1479 
1480  if (nargin > 0 && args.all_strings_p ())
1481  {
1482  string_vector argv = args.make_argv ("warning");
1483 
1484  std::string arg1 = argv[1];
1485  std::transform (arg1.begin (), arg1.end (), arg1.begin (), tolower);
1486  std::string arg2 = "all";
1487  std::string arg2_lc = "all";
1488 
1489  if (nargin >= 2)
1490  {
1491  arg2 = argv[2];
1492  arg2_lc = arg2;
1493  std::transform (arg2_lc.begin (), arg2_lc.end (), arg2_lc.begin (),
1494  tolower);
1495  }
1496 
1497  if (arg1 == "on" || arg1 == "off" || arg1 == "error")
1498  {
1499  // Prepare output structure
1500  octave_map old_warning_options;
1501  if (arg2_lc == "all")
1502  old_warning_options = es.warning_options ();
1503  else
1504  old_warning_options = octave_map (es.warning_query (arg2));
1505 
1506  if (nargin == 3)
1507  {
1508  std::string arg3_lc = argv[3];
1509  std::transform (arg3_lc.begin (), arg3_lc.end (),
1510  arg3_lc.begin (), tolower);
1511  if (arg3_lc == "local" && ! interp.at_top_level ())
1512  {
1513  octave_scalar_map val = es.warning_query (arg2);
1514 
1515  octave_value curr_state = val.contents ("state");
1516 
1517  // FIXME: this might be better with a dictionary object.
1518  tree_evaluator& tw = interp.get_evaluator ();
1519 
1520  octave_value curr_warning_states
1522 
1523  octave_map m;
1524 
1525  if (curr_warning_states.is_defined ())
1526  m = curr_warning_states.map_value ();
1527  else
1528  {
1529  string_vector fields (2);
1530 
1531  fields(0) = "identifier";
1532  fields(1) = "state";
1533 
1534  m = octave_map (dim_vector (0, 1), fields);
1535  }
1536 
1537  Cell ids = m.contents ("identifier");
1538  Cell states = m.contents ("state");
1539 
1540  octave_idx_type nel = states.numel ();
1541  bool found = false;
1542  octave_idx_type i;
1543  for (i = 0; i < nel; i++)
1544  {
1545  std::string id = ids(i).string_value ();
1546 
1547  if (id == arg2)
1548  {
1549  states(i) = curr_state;
1550  found = true;
1551  break;
1552  }
1553  }
1554 
1555  if (! found)
1556  {
1557  m.resize (dim_vector (nel+1, 1));
1558 
1559  ids.resize (dim_vector (nel+1, 1));
1560  states.resize (dim_vector (nel+1, 1));
1561 
1562  ids(nel) = arg2;
1563  states(nel) = curr_state;
1564  }
1565 
1566  m.contents ("identifier") = ids;
1567  m.contents ("state") = states;
1568 
1570 
1571  // Now ignore the "local" argument,
1572  // and continue to handle the current setting.
1573  nargin--;
1574  }
1575  }
1576 
1577  if ((nargin == 1
1578  && (arg1 == "on" || arg1 == "off" || arg1 == "error"))
1579  || (nargin >= 2 && arg2_lc == "all"))
1580  {
1581  // If "all" is given implicitly or explicitly as ID.
1582  if (arg1 == "error")
1583  error (R"(warning: cannot specify "all" warning ID with state "error")");
1584 
1585  octave_map tmp;
1586 
1587  Cell id (1, 1);
1588  Cell st (1, 1);
1589 
1590  id(0) = "all";
1591  st(0) = arg1;
1592 
1593  tmp.assign ("identifier", id);
1594  tmp.assign ("state", st);
1595 
1596  es.warning_options (tmp);
1597 
1598  done = true;
1599  }
1600  else if (arg2_lc == "backtrace")
1601  {
1602  if (arg1 != "error")
1603  {
1604  es.backtrace_on_warning (arg1 == "on");
1605  done = true;
1606  }
1607  }
1608  else if (arg2_lc == "debug")
1609  {
1610  if (arg1 != "error")
1611  {
1612  es.debug_on_warning (arg1 == "on");
1613  done = true;
1614  }
1615  }
1616  else if (arg2_lc == "verbose")
1617  {
1618  if (arg1 != "error")
1619  {
1620  es.verbose_warning (arg1 == "on");
1621  done = true;
1622  }
1623  }
1624  else if (arg2_lc == "quiet")
1625  {
1626  if (arg1 != "error")
1627  {
1628  es.quiet_warning (arg1 == "on");
1629  done = true;
1630  }
1631  }
1632  else
1633  {
1634  if (arg2_lc == "last")
1635  arg2 = es.last_warning_id ();
1636 
1637  es.set_warning_option (arg1, arg2);
1638 
1639  done = true;
1640  }
1641 
1642  if (done && nargout > 0)
1643  retval = old_warning_options;
1644  }
1645  else if (arg1 == "query")
1646  {
1647  if (arg2_lc == "all")
1648  {
1649  if (nargout > 0)
1650  retval = es.warning_options ();
1651  else
1653  }
1654  else if (arg2_lc == "backtrace" || arg2_lc == "debug"
1655  || arg2_lc == "verbose" || arg2_lc == "quiet")
1656  {
1657  if (nargout > 0)
1658  {
1659  octave_scalar_map tmp;
1660  tmp.assign ("identifier", arg2_lc);
1661  if (arg2_lc == "backtrace")
1662  tmp.assign ("state", es.backtrace_on_warning () ? "on" : "off");
1663  else if (arg2_lc == "debug")
1664  tmp.assign ("state", es.debug_on_warning () ? "on" : "off");
1665  else if (arg2_lc == "verbose")
1666  tmp.assign ("state", es.verbose_warning () ? "on" : "off");
1667  else
1668  tmp.assign ("state", es.quiet_warning () ? "on" : "off");
1669 
1670  retval = tmp;
1671  }
1672  else
1673  {
1674  if (arg2_lc == "backtrace")
1675  octave_stdout << R"("backtrace" warning state is ")" <<
1676  (es.backtrace_on_warning () ? "on" : "off") <<
1677  "\"\n";
1678  else if (arg2_lc == "debug")
1679  octave_stdout << R"("debug" warning state is ")" <<
1680  (es.debug_on_warning () ? "on" : "off") <<
1681  "\"\n";
1682  else if (arg2_lc == "verbose")
1683  octave_stdout << R"("verbose" warning state is ")" <<
1684  (es.verbose_warning () ? "on" : "off") <<
1685  "\"\n";
1686  else
1687  octave_stdout << R"("quiet" warning state is ")" <<
1688  (es.quiet_warning () ? "on" : "off") <<
1689  "\"\n";
1690  }
1691  }
1692  else
1693  {
1694  if (nargout > 0)
1695  retval = es.warning_query (arg2);
1696  else
1697  {
1698  octave_scalar_map tmp = es.warning_query (arg2);
1699 
1700  octave_stdout << '"' << arg2 << R"(" warning state is ")" <<
1701  tmp.getfield ("state").string_value () <<
1702  "\"\n";
1703  }
1704  }
1705 
1706  done = true;
1707  }
1708  }
1709  else if (nargin == 0)
1710  {
1711  if (nargout > 0)
1712  retval = es.warning_options ();
1713  else
1715 
1716  done = true;
1717  }
1718  else if (nargin == 1)
1719  {
1720  octave_value arg = args(0);
1721 
1722  octave_map old_warning_options;
1723 
1724  if (arg.isstruct ())
1725  {
1726  octave_map m = arg.map_value ();
1727 
1728  if (! m.contains ("identifier") || ! m.contains ("state"))
1729  error ("warning: STATE structure must have fields 'identifier' and 'state'");
1730 
1731  // Simply step through the struct elements one at a time.
1732 
1733  Cell ident = m.contents ("identifier");
1734  Cell state = m.contents ("state");
1735 
1736  octave_idx_type nel = ident.numel ();
1737 
1738  // Prepare output structure
1739  old_warning_options = octave_map (m);
1740  Cell oldstate (state);
1741 
1742  for (octave_idx_type i = 0; i < nel; i++)
1743  {
1744  std::string tid = ident(i).string_value ();
1745  oldstate(i) = es.warning_query (tid).getfield ("state");
1746  }
1747  old_warning_options.setfield ("state", oldstate);
1748 
1749  // Set new values
1750  for (octave_idx_type i = 0; i < nel; i++)
1751  {
1752  std::string tst = state(i).string_value ();
1753  std::string tid = ident(i).string_value ();
1754 
1755  es.set_warning_option (tst, tid);
1756  }
1757 
1758  done = true;
1759 
1760  if (nargout > 0)
1761  retval = old_warning_options;
1762  }
1763  }
1764 
1765  if (! done)
1766  {
1767  octave_value_list nargs = args;
1768 
1769  std::string id;
1770 
1771  bool have_fmt = maybe_extract_message_id ("warning", args, nargs, id);
1772 
1773  std::string prev_msg = es.last_warning_message ();
1774 
1775  std::string curr_msg = handle_message (warning_with_id, id.c_str (),
1776  "unspecified warning", nargs,
1777  have_fmt);
1778 
1779  if (nargout > 0)
1780  retval = prev_msg;
1781  }
1782 
1783  return retval;
1784 }
1785 
1786 /*
1787 
1788 %!test <*51997>
1789 %! id = "Octave:logical-conversion";
1790 %! current = warning ("query", id);
1791 %! current_all = warning ();
1792 %! previous = warning (current_all);
1793 %! assert (previous, current_all);
1794 %! previous = warning (current);
1795 %! assert (previous, current);
1796 %! previous = warning (current.state, id);
1797 %! assert (previous, current);
1798 
1799 %!test <*57290>
1800 %! warning ("oN", "Octave:test-57290-ID");
1801 %! warnst = warning ("QUery", "Octave:test-57290-ID");
1802 %! assert (warnst.state, "on");
1803 %! assert (warnst.identifier, "Octave:test-57290-ID");
1804 %! warning ("OFF", "Octave:test-57290-ID");
1805 %! warnst = warning ("QUery", "ALL");
1806 %! idx = strcmp ({warnst.identifier}, "Octave:test-57290-ID");
1807 %! assert (warnst(idx).state, "off");
1808 
1809 %!error <cannot specify "all" warning ID> warning ("error")
1810 
1811 */
1812 
1814 set_warning_state (const std::string& id, const std::string& state)
1815 {
1816  octave_value_list args;
1817 
1818  args(1) = id;
1819  args(0) = state;
1820 
1821  interpreter& interp = __get_interpreter__ ();
1822 
1823  return Fwarning (interp, args, 1);
1824 }
1825 
1828 {
1829  interpreter& interp = __get_interpreter__ ();
1830 
1831  return Fwarning (interp, args, 1);
1832 }
1833 
1834 int
1835 warning_enabled (const std::string& id)
1836 {
1838 
1839  return es.warning_enabled (id);
1840 }
1841 
1842 void
1843 disable_warning (const std::string& id)
1844 {
1846 
1847  es.disable_warning (id);
1848 }
1849 
1850 DEFMETHOD (lasterror, interp, args, ,
1851  doc: /* -*- texinfo -*-
1852 @deftypefn {} {@var{lasterr} =} lasterror ()
1853 @deftypefnx {} {} lasterror (@var{err})
1854 @deftypefnx {} {} lasterror ("reset")
1855 Query or set the last error message structure.
1856 
1857 When called without arguments, return a structure containing the last error
1858 message and other information related to this error. The elements of the
1859 structure are:
1860 
1861 @table @code
1862 @item message
1863 The text of the last error message
1864 
1865 @item identifier
1866 The message identifier of this error message
1867 
1868 @item stack
1869 A structure containing information on where the message occurred. This may
1870 be an empty structure if the information cannot be obtained. The fields of
1871 the structure are:
1872 
1873 @table @code
1874 @item file
1875 The name of the file where the error occurred
1876 
1877 @item name
1878 The name of function in which the error occurred
1879 
1880 @item line
1881 The line number at which the error occurred
1882 
1883 @item column
1884 An optional field with the column number at which the error occurred
1885 @end table
1886 @end table
1887 
1888 The last error structure may be set by passing a scalar structure,
1889 @var{err}, as input. Any fields of @var{err} that match those above are
1890 set while any unspecified fields are initialized with default values.
1891 
1892 If @code{lasterror} is called with the argument @qcode{"reset"}, all
1893 fields are set to their default values.
1894 @seealso{lasterr, error, lastwarn}
1895 @end deftypefn */)
1896 {
1897  int nargin = args.length ();
1898 
1899  if (nargin > 1)
1900  print_usage ();
1901 
1902  error_system& es = interp.get_error_system ();
1903 
1904  octave_scalar_map err;
1905 
1906  err.assign ("message", es.last_error_message ());
1907  err.assign ("identifier", es.last_error_id ());
1908 
1909  err.assign ("stack", octave_value (es.last_error_stack ()));
1910 
1911  if (nargin == 1)
1912  {
1913  tree_evaluator& tw = interp.get_evaluator ();
1914 
1915  if (args(0).is_string ())
1916  {
1917  if (args(0).string_value () != "reset")
1918  error ("lasterror: unrecognized string argument");
1919 
1920  es.last_error_message ("");
1921  es.last_error_id ("");
1922 
1923  es.last_error_stack (tw.empty_backtrace ());
1924  }
1925  else if (args(0).isstruct ())
1926  {
1927  octave_scalar_map new_err = args(0).scalar_map_value ();
1928  octave_scalar_map new_err_stack;
1929  std::string new_error_message;
1930  std::string new_error_id;
1931  std::string new_error_file;
1932  std::string new_error_name;
1933  int new_error_line = -1;
1934  int new_error_column = -1;
1935  bool initialize_stack = false;
1936 
1937  if (new_err.contains ("message"))
1938  {
1939  const std::string tmp
1940  = new_err.getfield ("message").string_value ();
1941  new_error_message = tmp;
1942  }
1943 
1944  if (new_err.contains ("identifier"))
1945  {
1946  const std::string tmp
1947  = new_err.getfield ("identifier").string_value ();
1948  new_error_id = tmp;
1949  }
1950 
1951  if (new_err.contains ("stack"))
1952  {
1953  if (new_err.getfield ("stack").isempty ())
1954  initialize_stack = true;
1955  else
1956  {
1957  new_err_stack
1958  = new_err.getfield ("stack").scalar_map_value ();
1959 
1960  if (new_err_stack.contains ("file"))
1961  {
1962  const std::string tmp
1963  = new_err_stack.getfield ("file").string_value ();
1964  new_error_file = tmp;
1965  }
1966 
1967  if (new_err_stack.contains ("name"))
1968  {
1969  const std::string tmp
1970  = new_err_stack.getfield ("name").string_value ();
1971  new_error_name = tmp;
1972  }
1973 
1974  if (new_err_stack.contains ("line"))
1975  {
1976  const int tmp
1977  = new_err_stack.getfield ("line").nint_value ();
1978  new_error_line = tmp;
1979  }
1980 
1981  if (new_err_stack.contains ("column"))
1982  {
1983  const int tmp
1984  = new_err_stack.getfield ("column").nint_value ();
1985  new_error_column = tmp;
1986  }
1987  }
1988  }
1989 
1990  es.last_error_message (new_error_message);
1991  es.last_error_id (new_error_id);
1992 
1993  if (initialize_stack)
1994  es.last_error_stack (tw.empty_backtrace ());
1995  else if (new_err.contains ("stack"))
1996  {
1997  new_err_stack.setfield ("file", new_error_file);
1998  new_err_stack.setfield ("name", new_error_name);
1999  new_err_stack.setfield ("line", new_error_line);
2000  new_err_stack.setfield ("column", new_error_column);
2001 
2002  es.last_error_stack (new_err_stack);
2003  }
2004  else
2005  es.last_error_stack (tw.backtrace ());
2006  }
2007  else
2008  error ("lasterror: argument must be a structure or a string");
2009  }
2010 
2011  return ovl (err);
2012 }
2013 
2014 /*
2015 ## Test lasterror with empty error state
2016 %!test
2017 %! lasterror ("reset");
2018 %! x = lasterror ();
2019 %! assert (x.identifier, "")
2020 %! assert (x.message, "")
2021 %! assert (isempty (x.stack))
2022 %! lasterror (x);
2023 %! y = lasterror ();
2024 %! assert (y, x);
2025 */
2026 
2027 DEFMETHOD (lasterr, interp, args, nargout,
2028  doc: /* -*- texinfo -*-
2029 @deftypefn {} {[@var{msg}, @var{msgid}] =} lasterr ()
2030 @deftypefnx {} {} lasterr (@var{msg})
2031 @deftypefnx {} {} lasterr (@var{msg}, @var{msgid})
2032 Query or set the last error message.
2033 
2034 When called without input arguments, return the last error message and
2035 message identifier.
2036 
2037 With one argument, set the last error message to @var{msg}.
2038 
2039 With two arguments, also set the last message identifier.
2040 @seealso{lasterror, error, lastwarn}
2041 @end deftypefn */)
2042 {
2043  int nargin = args.length ();
2044 
2045  if (nargin > 2)
2046  print_usage ();
2047 
2048  error_system& es = interp.get_error_system ();
2049 
2050  string_vector argv = args.make_argv ("lasterr");
2051 
2052  std::string prev_error_id = es.last_error_id ();
2053  std::string prev_error_message = es.last_error_message ();
2054 
2055  if (nargin == 2)
2056  {
2057  es.last_error_id (argv[2]);
2058  es.last_error_message (argv[1]);
2059  }
2060  else if (nargin == 1)
2061  {
2062  es.last_error_id ("");
2063  es.last_error_message (argv[1]);
2064  }
2065 
2066  if (nargin == 0 || nargout > 0)
2067  return ovl (prev_error_message, prev_error_id);
2068  else
2069  return ovl ();
2070 }
2071 
2072 DEFMETHOD (lastwarn, interp, args, nargout,
2073  doc: /* -*- texinfo -*-
2074 @deftypefn {} {[@var{msg}, @var{msgid}] =} lastwarn ()
2075 @deftypefnx {} {} lastwarn (@var{msg})
2076 @deftypefnx {} {} lastwarn (@var{msg}, @var{msgid})
2077 Query or set the last warning message.
2078 
2079 When called without input arguments, return the last warning message and
2080 message identifier.
2081 
2082 With one argument, set the last warning message to @var{msg}.
2083 
2084 With two arguments, also set the last message identifier to @var{msgid}.
2085 @seealso{warning, lasterror, lasterr}
2086 @end deftypefn */)
2087 {
2088  int nargin = args.length ();
2089 
2090  if (nargin > 2)
2091  print_usage ();
2092 
2093  error_system& es = interp.get_error_system ();
2094 
2095  string_vector argv = args.make_argv ("lastwarn");
2096 
2097  std::string prev_warning_id = es.last_warning_id ();
2098  std::string prev_warning_message = es.last_warning_message ();
2099 
2100  if (nargin == 2)
2101  {
2102  es.last_warning_id (argv[2]);
2103  es.last_warning_message (argv[1]);
2104  }
2105  else if (nargin == 1)
2106  {
2107  es.last_warning_id ("");
2108  es.last_warning_message (argv[1]);
2109  }
2110 
2111  if (nargin == 0 || nargout > 0)
2112  return ovl (prev_warning_message, prev_warning_id);
2113  else
2114  return ovl ();
2115 }
2116 
2117 DEFMETHOD (beep_on_error, interp, args, nargout,
2118  doc: /* -*- texinfo -*-
2119 @deftypefn {} {@var{val} =} beep_on_error ()
2120 @deftypefnx {} {@var{old_val} =} beep_on_error (@var{new_val})
2121 @deftypefnx {} {@var{old_val} =} beep_on_error (@var{new_val}, "local")
2122 Query or set the internal variable that controls whether Octave will try
2123 to ring the terminal bell before printing an error message.
2124 
2125 When called from inside a function with the @qcode{"local"} option, the
2126 variable is changed locally for the function and any subroutines it calls.
2127 The original variable value is restored when exiting the function.
2128 @end deftypefn */)
2129 {
2130  error_system& es = interp.get_error_system ();
2131 
2132  return es.beep_on_error (args, nargout);
2133 }
2134 
2135 DEFMETHOD (debug_on_error, interp, args, nargout,
2136  doc: /* -*- texinfo -*-
2137 @deftypefn {} {@var{val} =} debug_on_error ()
2138 @deftypefnx {} {@var{old_val} =} debug_on_error (@var{new_val})
2139 @deftypefnx {} {@var{old_val} =} debug_on_error (@var{new_val}, "local")
2140 Query or set the internal variable that controls whether Octave will try
2141 to enter the debugger when an error is encountered.
2142 
2143 This will also inhibit printing of the normal traceback message (you will
2144 only see the top-level error message).
2145 
2146 When called from inside a function with the @qcode{"local"} option, the
2147 variable is changed locally for the function and any subroutines it calls.
2148 The original variable value is restored when exiting the function.
2149 @seealso{debug_on_warning, debug_on_interrupt}
2150 @end deftypefn */)
2151 {
2152  error_system& es = interp.get_error_system ();
2153 
2154  return es.debug_on_error (args, nargout);
2155 }
2156 
2157 DEFMETHOD (debug_on_warning, interp, args, nargout,
2158  doc: /* -*- texinfo -*-
2159 @deftypefn {} {@var{val} =} debug_on_warning ()
2160 @deftypefnx {} {@var{old_val} =} debug_on_warning (@var{new_val})
2161 @deftypefnx {} {@var{old_val} =} debug_on_warning (@var{new_val}, "local")
2162 Query or set the internal variable that controls whether Octave will try
2163 to enter the debugger when a warning is encountered.
2164 
2165 When called from inside a function with the @qcode{"local"} option, the
2166 variable is changed locally for the function and any subroutines it calls.
2167 The original variable value is restored when exiting the function.
2168 @seealso{debug_on_error, debug_on_interrupt}
2169 @end deftypefn */)
2170 {
2171  error_system& es = interp.get_error_system ();
2172 
2173  return es.debug_on_warning (args, nargout);
2174 }
2175 
2176 void
2178 {
2180 
2181  es.interpreter_try (frame);
2182 }
2183 
OCTAVE_END_NAMESPACE(octave)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:414
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array-base.cc:1032
Definition: Cell.h:43
Cell column(octave_idx_type i) const
Definition: Cell.cc:303
void protect_var(T &var)
static bool forced_interactive(void)
Definition: octave.cc:327
bool debug_on_warn(const std::string &id)
Definition: bp-table.h:198
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
bool m_backtrace_on_warning
TRUE means that Octave will try to display a stack trace when a warning is encountered.
Definition: error.h:376
bool quiet_warning(void) const
Definition: error.h:166
OCTINTERP_API error_system(interpreter &interp)
Definition: error.cc:257
OCTINTERP_API void initialize_default_warning_state(void)
Definition: error.cc:832
OCTINTERP_API octave_value beep_on_error(const octave_value_list &args, int nargout)
Definition: error.cc:307
bool m_discard_warning_messages
TRUE means warning messages are turned off.
Definition: error.h:368
std::string m_last_error_id
The last error message id.
Definition: error.h:399
bool backtrace_on_warning(void) const
Definition: error.h:138
OCTINTERP_API void interpreter_try(unwind_protect &frame)
Definition: error.cc:852
OCTINTERP_API void display_warning_options(std::ostream &os)
Definition: error.cc:723
std::string last_error_message(void) const
Definition: error.h:193
static OCTINTERP_API std::list< frame_info > make_stack_frame_list(const octave_map &stack)
Definition: error.cc:399
OCTINTERP_API octave_value last_error_id(const octave_value_list &args, int nargout)
Definition: error.cc:358
OCTAVE_NORETURN OCTINTERP_API void error_1(execution_exception &ee, const char *id, const char *fmt, va_list args)
Definition: error.cc:564
OCTAVE_NORETURN OCTINTERP_API void vpanic(const char *fmt, va_list args)
Definition: error.cc:626
OCTINTERP_API octave_value quiet_warning(const octave_value_list &args, int nargout)
Definition: error.cc:329
std::string m_last_error_message
The text of the last error message.
Definition: error.h:390
OCTINTERP_API void set_warning_option(const std::string &state, const std::string &id)
Definition: error.cc:763
bool debug_on_caught(void) const
Definition: error.h:76
OCTAVE_NORETURN OCTINTERP_API void rethrow_error(const std::string &id, const std::string &msg, const octave_map &stack)
Definition: error.cc:597
OCTINTERP_API octave_scalar_map warning_query(const std::string &id_arg)
Definition: error.cc:644
octave_map warning_options(void) const
Definition: error.h:175
OCTINTERP_API octave_value backtrace_on_warning(const octave_value_list &args, int nargout)
Definition: error.cc:314
std::string last_error_id(void) const
Definition: error.h:238
OCTINTERP_API octave_value last_warning_message(const octave_value_list &args, int nargout)
Definition: error.cc:343
OCTAVE_NORETURN OCTINTERP_API void throw_error(const std::string &err_type, const std::string &id, const std::string &message, const std::list< frame_info > &stack_info=std::list< frame_info >())
Definition: error.cc:864
std::string last_warning_id(void) const
Definition: error.h:224
OCTINTERP_API int warning_enabled(const std::string &id)
For given warning ID, return 0 if warnings are disabled, 1 if enabled, and 2 if the given ID should b...
Definition: error.cc:423
std::string m_last_warning_id
The last warning message id.
Definition: error.h:396
static OCTINTERP_API octave_map make_stack_map(const std::list< frame_info > &frames)
Definition: error.cc:372
bool beep_on_error(void) const
Definition: error.h:124
bool discard_warning_messages(void) const
Definition: error.h:107
OCTAVE_NORETURN OCTINTERP_API void vusage(const char *id, const char *fmt, va_list args)
Definition: error.cc:495
OCTINTERP_API octave_value debug_on_warning(const octave_value_list &args, int nargout)
Definition: error.cc:292
OCTINTERP_API octave_value verbose_warning(const octave_value_list &args, int nargout)
Definition: error.cc:322
bool m_debug_on_caught
TRUE means that Octave will try to enter the debugger when an error is encountered within the 'try' s...
Definition: error.h:359
bool m_debug_on_warning
TRUE means that Octave will try to enter the debugger when a warning is encountered.
Definition: error.h:364
OCTINTERP_API void display_exception(const execution_exception &ee, std::ostream &os) const
Definition: error.cc:905
OCTINTERP_API void disable_warning(const std::string &id)
Definition: error.cc:827
OCTINTERP_API void vwarning(const char *name, const char *id, const char *fmt, va_list args)
Definition: error.cc:503
bool debug_on_warning(void) const
Definition: error.h:90
OCTINTERP_API octave_value last_warning_id(const octave_value_list &args, int nargout)
Definition: error.cc:351
bool debug_on_error(void) const
Definition: error.h:62
OCTINTERP_API void save_exception(const execution_exception &ee)
Definition: error.cc:893
OCTINTERP_API octave_value debug_on_error(const octave_value_list &args, int nargout)
Definition: error.cc:278
bool m_beep_on_error
TRUE means that Octave will try to beep obnoxiously before printing error messages.
Definition: error.h:372
std::string last_warning_message(void) const
Definition: error.h:208
OCTINTERP_API octave_value last_error_message(const octave_value_list &args, int nargout)
Definition: error.cc:336
bool m_debug_on_error
TRUE means that Octave will try to enter the debugger when an error is encountered.
Definition: error.h:354
interpreter & m_interpreter
Definition: error.h:348
bool m_quiet_warning
TRUE means that Octave will print no warnings, but lastwarn will be updated.
Definition: error.h:384
bool m_verbose_warning
TRUE means that Octave will print a verbose warning.
Definition: error.h:380
octave_map last_error_stack(void) const
Definition: error.h:252
OCTINTERP_API std::string default_warning_state(void)
Definition: error.cc:700
OCTAVE_NORETURN OCTINTERP_API void panic(const char *fmt,...)
Definition: error.cc:636
std::string m_last_warning_message
The text of the last warning message.
Definition: error.h:393
bool verbose_warning(void) const
Definition: error.h:152
Provides threadsafe access to octave.
bool display_exception(const execution_exception &ee, bool beep=false)
event_manager & get_event_manager(void)
Definition: interpreter.h:328
tree_evaluator & get_evaluator(void)
bool interactive(void) const
Definition: interpreter.h:171
void setfield(const std::string &key, const Cell &val)
Definition: oct-map.cc:282
octave_idx_type numel(void) const
Definition: oct-map.h:389
bool contains(const std::string &name) const
Definition: oct-map.h:350
void assign(const std::string &k, const Cell &val)
Definition: oct-map.h:365
const Cell & contents(const_iterator p) const
Definition: oct-map.h:331
void clear(void)
Definition: oct-map.h:382
bool isempty(void) const
Definition: oct-map.h:391
bool contains(const std::string &name) const
Definition: oct-map.h:224
const octave_value & contents(const_iterator p) const
Definition: oct-map.h:205
void setfield(const std::string &key, const octave_value &val)
Definition: oct-map.cc:190
void assign(const std::string &k, const octave_value &val)
Definition: oct-map.h:238
octave_value getfield(const std::string &key) const
Definition: oct-map.cc:183
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
Definition: ovl.h:117
octave_idx_type length(void) const
Definition: ovl.h:113
OCTINTERP_API octave_scalar_map scalar_map_value(void) const
OCTINTERP_API octave_map xmap_value(const char *fmt,...) const
bool is_string(void) const
Definition: ov.h:682
bool is_defined(void) const
Definition: ov.h:637
bool isstruct(void) const
Definition: ov.h:694
std::string string_value(bool force=false) const
Definition: ov.h:1019
int nint_value(bool frc_str_conv=false) const
Definition: ov.h:864
bool isempty(void) const
Definition: ov.h:646
OCTINTERP_API octave_map map_value(void) const
OCTINTERP_API octave_idx_type length(void) const
@ SAVED_WARNING_STATES
Definition: stack-frame.h:136
octave_map empty_backtrace(void) const
Definition: pt-eval.cc:2607
octave_value get_auto_fcn_var(stack_frame::auto_var_type avt) const
Definition: pt-eval.cc:2205
octave_map backtrace(octave_idx_type &curr_user_frame, bool print_subfn=true) const
Definition: pt-eval.cc:2596
bool in_user_code(void) const
Definition: pt-eval.cc:2965
std::string backtrace_message(void) const
Definition: pt-eval.cc:2612
std::list< frame_info > backtrace_info(octave_idx_type &curr_user_frame, bool print_subfn=true) const
Definition: pt-eval.cc:2584
void set_auto_fcn_var(stack_frame::auto_var_type avt, const octave_value &val=octave_value())
Definition: pt-eval.cc:2198
void enter_debugger(const std::string &prompt="debug> ")
Definition: pt-eval.cc:1378
bp_table & get_bp_table(void)
Definition: pt-eval.h:429
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTINTERP_API void print_usage(void)
Definition: defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
void interpreter_try(unwind_protect &frame)
Definition: error.cc:2177
void error_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1024
static const octave_fields bt_fields(bt_fieldnames)
static int check_state(const std::string &state)
Definition: error.cc:94
void(* error_fcn)(const char *, const char *,...)
Definition: error.cc:128
void usage_with_id(const char *id, const char *fmt,...)
Definition: error.cc:964
void warning(const char *fmt,...)
Definition: error.cc:1054
OCTAVE_NORETURN void panic(const char *fmt,...)
Definition: error.cc:1118
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1069
void verror_with_id_cfn(const char *id, const char *fmt, va_list args)
Definition: error.cc:1033
void parse_error_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1099
OCTAVE_EXPORT octave_value_list Fwarning(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: error.cc:1471
static OCTAVE_NORETURN void error_1(octave::execution_exception &ee, const char *id, const char *fmt, va_list args)
Definition: error.cc:76
static void vwarning(const char *id, const char *fmt, va_list args)
Definition: error.cc:112
OCTAVE_NORETURN void vpanic(const char *fmt, va_list args)
Definition: error.cc:1109
void error_with_id_cfn(const char *id, const char *fmt,...)
Definition: error.cc:1039
void vwarning_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:1063
void verror(const char *fmt, va_list args)
Definition: error.cc:973
void verror_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:1018
static const char * bt_fieldnames[]
Definition: error.cc:366
void vusage_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:956
void verror_with_cfn(const char *fmt, va_list args)
Definition: error.cc:1003
void error_with_cfn(const char *fmt,...)
Definition: error.cc:1009
void vparse_error_with_id(const char *id, const char *fmt, va_list args)
Definition: error.cc:1093
void parse_error(const char *fmt,...)
Definition: error.cc:1084
static void defun_usage_message(const char *fmt,...)
Definition: error.cc:120
void error(const char *fmt,...)
Definition: error.cc:979
static std::string format_message(const char *fmt, va_list args)
Definition: error.cc:62
static std::string handle_message(error_fcn f, const char *id, const char *msg, const octave_value_list &args, bool have_fmt)
Definition: error.cc:131
void vparse_error(const char *fmt, va_list args)
Definition: error.cc:1078
static octave_map init_error_stack(interpreter &interp)
Definition: error.cc:250
static bool maybe_extract_message_id(const std::string &caller, const octave_value_list &args, octave_value_list &nargs, std::string &id)
Definition: error.cc:192
void message(const char *name, const char *fmt,...)
Definition: error.cc:947
static octave_scalar_map init_warning_options(const std::string &state)
Definition: error.cc:239
octave_value_list set_warning_state(const std::string &id, const std::string &state)
Definition: error.cc:1814
void vmessage(const char *name, const char *fmt, va_list args)
Definition: error.cc:933
void disable_warning(const std::string &id)
Definition: error.cc:1843
int warning_enabled(const std::string &id)
Definition: error.cc:1835
void panic_unless(bool cond)
Definition: error.h:526
void panic_if(bool cond)
Definition: error.h:512
#define panic_impossible()
Definition: error.h:508
OCTAVE_EXPORT octave_value_list Fsprintf(const octave_value_list &args, int)
Definition: file-io.cc:973
ColumnVector transform(const Matrix &m, double x, double y, double z)
Definition: graphics.cc:5819
error_system & __get_error_system__(void)
interpreter & __get_interpreter__(void)
F77_RET_T const F77_DBLE const F77_DBLE * f
T octave_idx_type m
Definition: mx-inlines.cc:773
T::size_type strlen(const typename T::value_type *str)
Definition: oct-string.cc:85
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
void flush_stdout(void)
Definition: pager.cc:260
#define octave_stdout
Definition: pager.h:314
#define octave_diary
Definition: pager.h:316
static uint32_t state[624]
Definition: randmtzig.cc:193
std::size_t vformat(std::ostream &os, const char *fmt, va_list args)
Definition: utils.cc:1487
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:584
F77_RET_T len
Definition: xerbla.cc:61