mailing list of musl libc
 help / color / mirror / code / Atom feed
2b8209546e44fdf2ca82a694fb69382ca6103b0d blob 1897 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
#include <error.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stdio_impl.h"
#include "libc.h"

void (*__error_print_progname) (void) = 0;
unsigned int __error_message_count = 0;
int __error_one_per_line = 0;

static unsigned int saved_linenum = 0;
static const char *saved_file = 0;

static void errorv(int status, int errnum,
		   const char *file, unsigned int linenum,
		   const char *fmt, va_list ap) {
	++__error_message_count;

	fflush(stdout);
	FLOCK(stderr);

	if (__error_print_progname)
		__error_print_progname();
	else {
		fprintf(stderr, "%s:", __progname_full);
		if (!file)
			fputc(' ', stderr);
	}

	if (file)
		fprintf(stderr, "%s:%u: ", file, linenum);

	vfprintf(stderr, fmt, ap);
	if (errnum)
		fprintf(stderr, ": %s", strerror(errnum));
	fputc('\n', stderr);

	fflush(stderr);
	FUNLOCK(stderr);

	if (status)
		exit(status);
}

void __error(int status, int errnum, const char *fmt, ...) {
	va_list ap;
	va_start(ap, fmt);
	errorv(status, errnum, NULL, 0, fmt, ap);
	va_end(ap);
}

void __error_at_line(int status, int errnum,
                     const char *file, unsigned int linenum,
                     const char *fmt, ...) {
	if (error_one_per_line) {
		if(saved_linenum == linenum && file != NULL &&
		   saved_file != NULL && !strcmp(file, saved_file))
			return;
		saved_linenum = linenum;
		// Assuming that the lifetime of the passed in file name extends
		// until the next call is rather questionable, but appears to be
		// the expected semantics.
		saved_file = file;
	}

	va_list ap;
	va_start(ap, fmt);
	errorv(status, errnum, file, linenum, fmt, ap);
	va_end(ap);
}


weak_alias(__error_print_progname, error_print_progname);
weak_alias(__error_message_count, error_message_count);
weak_alias(__error_one_per_line, error_one_per_line);

weak_alias(__error, error);
weak_alias(__error_at_line, error_at_line);
debug log:

solving 2b820954 ...
found 2b820954 in https://inbox.vuxu.org/musl/CAA2zVHqpF3oHQL51vRQm5B1uK0oTc6qoSCkZxyZfV00BLCu7ng@mail.gmail.com/

applying [1/1] https://inbox.vuxu.org/musl/CAA2zVHqpF3oHQL51vRQm5B1uK0oTc6qoSCkZxyZfV00BLCu7ng@mail.gmail.com/
diff --git a/src/legacy/error.c b/src/legacy/error.c
new file mode 100644
index 00000000..2b820954

Checking patch src/legacy/error.c...
Applied patch src/legacy/error.c cleanly.

index at:
100644 2b8209546e44fdf2ca82a694fb69382ca6103b0d	src/legacy/error.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).