Mercurial > octave
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 |
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 | 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 | 28 #endif |
29 | |
30 #include <stdarg.h> | |
31 #include <stdio.h> | |
32 #include <stdlib.h> | |
33 | |
34 #include "lo-error.h" | |
35 | |
2597 | 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 | 38 |
2597 | 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 | 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 | 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 | 50 |
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 | 54 |
55 static void | |
56 verror (const char *name, const char *fmt, va_list args) | |
57 { | |
58 if (name) | |
59 fprintf (stderr, "%s: ", name); | |
60 | |
61 vfprintf (stderr, fmt, args); | |
62 fprintf (stderr, "\n"); | |
63 fflush (stderr); | |
64 } | |
65 | |
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 | 68 { |
69 if (f) | |
70 current_liboctave_error_handler = f; | |
71 else | |
72 current_liboctave_error_handler = liboctave_fatal; | |
73 } | |
74 | |
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 | 86 set_liboctave_warning_handler (liboctave_warning_handler f) |
87 { | |
88 if (f) | |
89 current_liboctave_warning_handler = f; | |
90 else | |
91 current_liboctave_warning_handler = liboctave_warning; | |
92 } | |
93 | |
94 void | |
5781 | 95 set_liboctave_warning_with_id_handler (liboctave_warning_with_id_handler f) |
96 { | |
97 if (f) | |
98 current_liboctave_warning_with_id_handler = f; | |
99 else | |
100 current_liboctave_warning_with_id_handler = liboctave_warning_with_id; | |
101 } | |
102 | |
103 void | |
2551 | 104 liboctave_fatal (const char *fmt, ...) |
105 { | |
106 va_list args; | |
107 va_start (args, fmt); | |
108 verror ("fatal", fmt, args); | |
109 va_end (args); | |
110 | |
111 exit (1); | |
112 } | |
113 | |
3325 | 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 | 128 liboctave_warning (const char *fmt, ...) |
129 { | |
130 va_list args; | |
131 va_start (args, fmt); | |
132 verror ("warning", fmt, args); | |
133 va_end (args); | |
134 } | |
135 | |
5781 | 136 void |
137 liboctave_warning_with_id (const char *id, const char *fmt, ...) | |
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 | 142 va_start (args, fmt); |
143 verror ("warning", fmt, args); | |
144 va_end (args); | |
145 } |