26 |
# define vfprintf(stream, message, args) _doprnt (message, args, stream) |
# define vfprintf(stream, message, args) _doprnt (message, args, stream) |
27 |
#endif |
#endif |
28 |
|
|
|
#if STDC_HEADERS || _LIBC |
|
|
# include <stdlib.h> |
|
|
# include <string.h> |
|
|
#endif |
|
|
|
|
29 |
#include "complain.h" |
#include "complain.h" |
30 |
#include "files.h" |
#include "files.h" |
31 |
|
|
33 |
# define _(String) String |
# define _(String) String |
34 |
#endif |
#endif |
35 |
|
|
|
#ifdef _LIBC |
|
|
/* In the GNU C library, there is a predefined variable for this. */ |
|
|
|
|
|
# define program_name program_invocation_name |
|
|
# include <errno.h> |
|
|
|
|
|
/* In GNU libc we want do not want to use the common name `error' directly. |
|
|
Instead make it a weak alias. */ |
|
|
# define error __error |
|
|
# define error_at_line __error_at_line |
|
|
|
|
|
# ifdef USE_IN_LIBIO |
|
|
# include <libio/iolibio.h> |
|
|
# define fflush(s) _IO_fflush (s) |
|
|
# endif |
|
|
|
|
|
#else /* not _LIBC */ |
|
|
|
|
36 |
/* The calling program should define program_name and set it to the |
/* The calling program should define program_name and set it to the |
37 |
name of the executing program. */ |
name of the executing program. */ |
38 |
extern char *program_name; |
extern char *program_name; |
39 |
|
|
40 |
# if HAVE_STRERROR |
#if HAVE_STRERROR |
41 |
# ifndef HAVE_DECL_STRERROR |
# ifndef HAVE_DECL_STRERROR |
42 |
"this configure-time declaration test was not run" |
"this configure-time declaration test was not run" |
43 |
# endif |
# endif |
44 |
# if !HAVE_DECL_STRERROR && !defined strerror |
# if !HAVE_DECL_STRERROR && !defined strerror |
45 |
char *strerror (int); |
char *strerror (int); |
46 |
# endif |
# endif |
47 |
# else |
#else |
48 |
static char * |
static char * |
49 |
private_strerror (int errnum) |
private_strerror (int errnum) |
50 |
{ |
{ |
55 |
return _(sys_errlist[errnum]); |
return _(sys_errlist[errnum]); |
56 |
return _("Unknown system error"); |
return _("Unknown system error"); |
57 |
} |
} |
58 |
# define strerror private_strerror |
# define strerror private_strerror |
59 |
# endif /* HAVE_STRERROR */ |
#endif /* HAVE_STRERROR */ |
|
#endif /* not _LIBC */ |
|
60 |
|
|
61 |
/* This variable is set each time `warn' is called. */ |
/* This variable is set each time `warn' is called. */ |
62 |
bool warning_issued; |
bool warning_issued; |
70 |
`--------------------------------*/ |
`--------------------------------*/ |
71 |
|
|
72 |
void |
void |
73 |
warn_at (location_t location, const char *message, ...) |
warn_at (location loc, const char *message, ...) |
74 |
{ |
{ |
75 |
va_list args; |
va_list args; |
76 |
|
|
77 |
fflush (stdout); |
fflush (stdout); |
78 |
location_print (stderr, location); |
location_print (stderr, loc); |
79 |
fputs (": ", stderr); |
fputs (": ", stderr); |
80 |
fputs (_("warning: "), stderr); |
fputs (_("warning: "), stderr); |
81 |
|
|
110 |
`-----------------------------------------------------------*/ |
`-----------------------------------------------------------*/ |
111 |
|
|
112 |
void |
void |
113 |
complain_at (location_t location, const char *message, ...) |
complain_at (location loc, const char *message, ...) |
114 |
{ |
{ |
115 |
va_list args; |
va_list args; |
116 |
|
|
117 |
fflush (stdout); |
fflush (stdout); |
118 |
location_print (stderr, location); |
location_print (stderr, loc); |
119 |
fputs (": ", stderr); |
fputs (": ", stderr); |
120 |
|
|
121 |
va_start (args, message); |
va_start (args, message); |
149 |
`-------------------------------------------------*/ |
`-------------------------------------------------*/ |
150 |
|
|
151 |
void |
void |
152 |
fatal_at (location_t location, const char *message, ...) |
fatal_at (location loc, const char *message, ...) |
153 |
{ |
{ |
154 |
va_list args; |
va_list args; |
155 |
|
|
156 |
fflush (stdout); |
fflush (stdout); |
157 |
location_print (stderr, location); |
location_print (stderr, loc); |
158 |
fputs (": ", stderr); |
fputs (": ", stderr); |
159 |
fputs (_("fatal error: "), stderr); |
fputs (_("fatal error: "), stderr); |
160 |
|
|