]> granicus.if.org Git - procps-ng/commitdiff
Also emulate error_at_line if not present
authorMichael Forney <mforney@mforney.org>
Tue, 1 Oct 2013 05:44:46 +0000 (05:44 +0000)
committerJaromir Capik <jcapik@redhat.com>
Thu, 28 Aug 2014 11:54:24 +0000 (13:54 +0200)
include/c.h
ps/display.c
ps/global.c

index 6bcdf5f526f26db0f3522ea1e252038d49826540..aca88a72e1071dc45fe1d8eb8dc32957db0282fe 100644 (file)
@@ -123,6 +123,24 @@ static void error(int status, int errnum, const char *format, ...)
         if (status != 0)
                 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
 #define xwarn(...) error(0, errno, __VA_ARGS__)
 #define xwarnx(...) error(0, 0, __VA_ARGS__)
index a659cbf339f52f328ba26e8e59395570ccf004e7..a2adcc8fca2eee523715e754d7538bbd8716d34b 100644 (file)
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <error.h>
 
 #include <sys/sysmacros.h>
 #include <sys/types.h>
@@ -38,6 +37,7 @@
 #include "../proc/wchan.h"
 
 #include "../include/fileutils.h"
+#include "../include/c.h"
 #include "common.h"
 
 #ifndef SIGCHLD
index b75f7284aeeb6ec3e62fb71d9fbdaee81dc5dc7b..5a4f1e57393f7ad41741381bec6be656d013680a 100644 (file)
@@ -25,7 +25,6 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
-#include <error.h>
 
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -36,6 +35,7 @@
 #include "../proc/version.h"
 #include "../proc/sysinfo.h"
 
+#include "../include/c.h"
 #include "common.h"
 
 #ifndef __GNU_LIBRARY__