aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/glibc/generic/error.cpp
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/options/glibc/generic/error.cpp
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/glibc/generic/error.cpp')
-rw-r--r--lib/mlibc/options/glibc/generic/error.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/lib/mlibc/options/glibc/generic/error.cpp b/lib/mlibc/options/glibc/generic/error.cpp
deleted file mode 100644
index 45203b2..0000000
--- a/lib/mlibc/options/glibc/generic/error.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <error.h>
-
-unsigned int error_message_count = 0;
-int error_one_per_line = 0;
-void (*error_print_progname)(void) = NULL;
-
-void error(int status, int errnum, const char *format, ...) {
- va_list args;
- va_start(args, format);
-
- error_message_count++;
-
- fflush(stdout);
- if(error_print_progname) {
- error_print_progname();
- } else {
- fprintf(stderr, "%s: ", program_invocation_name);
- }
- vfprintf(stderr, format, args);
- va_end(args);
-
- if(errnum) {
- fprintf(stderr, ": %s\n", strerror(errnum));
- }
-
- if(status) {
- exit(status);
- }
-}
-
-void error_at_line(int status, int errnum, const char *filename, unsigned int linenum, const char *format, ...) {
- va_list args;
- va_start(args, format);
-
- static bool first_call = true;
- static unsigned int last_line = 0;
- if(!(last_line == linenum && error_one_per_line && !first_call)) {
- first_call = false;
- last_line = linenum;
- error_message_count++;
-
- fflush(stdout);
- if(error_print_progname) {
- error_print_progname();
- } else {
- fprintf(stderr, "%s:", program_invocation_name);
- }
- fprintf(stderr, "%s:%u: ", filename, linenum);
- vfprintf(stderr, format, args);
-
- if(errnum) {
- fprintf(stderr, ": %s\n", strerror(errnum));
- }
- }
- va_end(args);
-
- if(status) {
- exit(status);
- }
-}