annotate liboctave/util/lo-error.c @ 33657:6f2baadfdb3d bytecode-interpreter tip

maint: Merge default to bytecode-interpreter.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Tue, 04 Jun 2024 20:06:05 -0400
parents 2e484f9f1f18
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
3 // Copyright (C) 1996-2024 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2551
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
27 # include "config.h"
2551
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
28 #endif
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
29
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
30 #include <stdarg.h>
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
31 #include <stdio.h>
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
32 #include <stdlib.h>
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
33
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
34 #include "lo-error.h"
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
35
2597
106ae3df29f5 [project @ 1996-12-17 17:48:01 by jwe]
jwe
parents: 2551
diff changeset
36 /* Having this file in this directory is a kluge to avoid unresolved
23426
58d56f52d50a move contents of liboctave/cruft/misc to liboctave/util
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
37 symbol errors when creating shared versions of liboctave. */
2551
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
38
2597
106ae3df29f5 [project @ 1996-12-17 17:48:01 by jwe]
jwe
parents: 2551
diff changeset
39 /* Pointer to the current error handling function. */
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
40 OCTAVE_NORETURN liboctave_error_handler
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
41 current_liboctave_error_handler = liboctave_fatal;
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
42
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
43 /* Pointer to the current error_with_id handling function. */
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
44 OCTAVE_NORETURN liboctave_error_with_id_handler
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
45 current_liboctave_error_with_id_handler = liboctave_fatal_with_id;
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
46
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
47 /* Pointer to the current warning handler. */
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
48 liboctave_warning_handler
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
49 current_liboctave_warning_handler = liboctave_warning;
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
50
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
51 /* Pointer to the current warning_with_id handler. */
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
52 liboctave_warning_with_id_handler
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 current_liboctave_warning_with_id_handler = liboctave_warning_with_id;
2551
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
54
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
55 static void
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
56 verror (const char *name, const char *fmt, va_list args)
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
57 {
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
58 if (name)
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
59 fprintf (stderr, "%s: ", name);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
60
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
61 vfprintf (stderr, fmt, args);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
62 fprintf (stderr, "\n");
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
63 fflush (stderr);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
64 }
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
65
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
66 void
21040
3e7cfee5f786 maint: Rename attributes GCC_ATTR_XXX to OCTAVE_XXX.
Rik <rik@octave.org>
parents: 21037
diff changeset
67 set_liboctave_error_handler (OCTAVE_NORETURN liboctave_error_handler f)
2551
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
68 {
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
69 if (f)
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
70 current_liboctave_error_handler = f;
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
71 else
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
72 current_liboctave_error_handler = liboctave_fatal;
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
73 }
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
74
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
75 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
76 set_liboctave_error_with_id_handler (OCTAVE_NORETURN
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
77 liboctave_error_with_id_handler f)
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
78 {
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
79 if (f)
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
80 current_liboctave_error_with_id_handler = f;
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
81 else
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
82 current_liboctave_error_with_id_handler = liboctave_fatal_with_id;
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
83 }
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
84
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
85 void
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
86 set_liboctave_warning_handler (liboctave_warning_handler f)
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
87 {
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
88 if (f)
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
89 current_liboctave_warning_handler = f;
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
90 else
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
91 current_liboctave_warning_handler = liboctave_warning;
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
92 }
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
93
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
94 void
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
95 set_liboctave_warning_with_id_handler (liboctave_warning_with_id_handler f)
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
96 {
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
97 if (f)
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
98 current_liboctave_warning_with_id_handler = f;
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
99 else
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
100 current_liboctave_warning_with_id_handler = liboctave_warning_with_id;
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
101 }
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
102
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
103 void
2551
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
104 liboctave_fatal (const char *fmt, ...)
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
105 {
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
106 va_list args;
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
107 va_start (args, fmt);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
108 verror ("fatal", fmt, args);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
109 va_end (args);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
110
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
111 exit (1);
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
112 }
65e2cd433c7f [project @ 1996-11-20 23:08:48 by jwe]
jwe
parents:
diff changeset
113
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
114 void
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
115 liboctave_fatal_with_id (const char *id, const char *fmt, ...)
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
116 {
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
117 octave_unused_parameter (id);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
118
14759
2feab289622a Move variable declaration at the beginning of code block.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14658
diff changeset
119 va_list args;
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
120 va_start (args, fmt);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
121 verror ("fatal", fmt, args);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
122 va_end (args);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
123
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
124 exit (1);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
125 }
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
126
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
127 void
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
128 liboctave_warning (const char *fmt, ...)
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
129 {
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
130 va_list args;
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
131 va_start (args, fmt);
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
132 verror ("warning", fmt, args);
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
133 va_end (args);
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
134 }
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 2847
diff changeset
135
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
136 void
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
137 liboctave_warning_with_id (const char *id, const char *fmt, ...)
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
138 {
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
139 octave_unused_parameter (id);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
140
14759
2feab289622a Move variable declaration at the beginning of code block.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14658
diff changeset
141 va_list args;
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
142 va_start (args, fmt);
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
143 verror ("warning", fmt, args);
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
144 va_end (args);
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5307
diff changeset
145 }