annotate liboctave/cruft/misc/lo-error.c @ 23084:ef4d915df748

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