1
|
1 // error.cc -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef __GNUG__ |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #include <stdio.h> |
|
29 #include <stdlib.h> |
|
30 #include <stdarg.h> |
|
31 |
|
32 #include "error.h" |
|
33 |
|
34 static void |
|
35 verror (const char *name, const char *fmt, va_list args) |
|
36 { |
|
37 if (name != (char *) NULL) |
|
38 fprintf (stderr, "%s: ", name); |
|
39 |
|
40 vfprintf (stderr, fmt, args); |
|
41 fprintf (stderr, "\n"); |
|
42 fflush (stderr); |
|
43 } |
|
44 |
|
45 void |
|
46 message (const char *name, const char *fmt, ...) |
|
47 { |
|
48 va_list args; |
|
49 va_start (args, fmt); |
|
50 verror (name, fmt, args); |
|
51 va_end (args); |
|
52 } |
|
53 |
|
54 void |
|
55 usage (const char *fmt, ...) |
|
56 { |
|
57 va_list args; |
|
58 va_start (args, fmt); |
|
59 verror ("usage", fmt, args); |
|
60 va_end (args); |
|
61 } |
|
62 |
|
63 void |
|
64 warning (const char *fmt, ...) |
|
65 { |
|
66 va_list args; |
|
67 va_start (args, fmt); |
|
68 verror ("warning", fmt, args); |
|
69 va_end (args); |
|
70 } |
|
71 |
|
72 void |
|
73 error (const char *fmt, ...) |
|
74 { |
|
75 va_list args; |
|
76 va_start (args, fmt); |
|
77 verror ("error", fmt, args); |
|
78 va_end (args); |
|
79 } |
|
80 |
103
|
81 void volatile |
1
|
82 panic (const char *fmt, ...) |
|
83 { |
|
84 va_list args; |
|
85 va_start (args, fmt); |
|
86 verror ("panic", fmt, args); |
|
87 va_end (args); |
|
88 abort (); |
|
89 } |
|
90 |
|
91 /* |
|
92 ;;; Local Variables: *** |
|
93 ;;; mode: C++ *** |
|
94 ;;; page-delimiter: "^/\\*" *** |
|
95 ;;; End: *** |
|
96 */ |