Also emulate error_at_line if not present
This commit is contained in:
parent
d6a3a3d97e
commit
007c438148
18
include/c.h
18
include/c.h
@ -123,6 +123,24 @@ static void error(int status, int errnum, const char *format, ...)
|
|||||||
if (status != 0)
|
if (status != 0)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Emulate the error_at_line() function from glibc */
|
||||||
|
__attribute__((__format__(__printf__, 5, 6)))
|
||||||
|
static void error_at_line(int status, int errnum, const char *filename,
|
||||||
|
unsigned int linenum, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list argp;
|
||||||
|
fprintf(stderr, "%s:%s:%u: ", program_invocation_short_name,
|
||||||
|
filename, linenum);
|
||||||
|
va_start(argp, format);
|
||||||
|
vfprintf(stderr, format, argp);
|
||||||
|
va_end(argp);
|
||||||
|
if (errnum != 0)
|
||||||
|
fprintf(stderr, ": error code %d", errnum);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
if (status != 0)
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#define xwarn(...) error(0, errno, __VA_ARGS__)
|
#define xwarn(...) error(0, errno, __VA_ARGS__)
|
||||||
#define xwarnx(...) error(0, 0, __VA_ARGS__)
|
#define xwarnx(...) error(0, 0, __VA_ARGS__)
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <error.h>
|
|
||||||
|
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -38,6 +37,7 @@
|
|||||||
#include "../proc/wchan.h"
|
#include "../proc/wchan.h"
|
||||||
|
|
||||||
#include "../include/fileutils.h"
|
#include "../include/fileutils.h"
|
||||||
|
#include "../include/c.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#ifndef SIGCHLD
|
#ifndef SIGCHLD
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <error.h>
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -36,6 +35,7 @@
|
|||||||
#include "../proc/version.h"
|
#include "../proc/version.h"
|
||||||
#include "../proc/sysinfo.h"
|
#include "../proc/sysinfo.h"
|
||||||
|
|
||||||
|
#include "../include/c.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#ifndef __GNU_LIBRARY__
|
#ifndef __GNU_LIBRARY__
|
||||||
|
Loading…
Reference in New Issue
Block a user