mailing list of musl libc
 help / color / mirror / code / Atom feed
c5000fa461675ecb29204feab4d6726f002268dc blob 1553 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
 
#include <error.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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);
	flockfile(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);

	funlockfile(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);
}
debug log:

solving c5000fa4 ...
found c5000fa4 in https://inbox.vuxu.org/musl/CAA2zVHrTwFc26Zvgq5gk0=h39hUTYfVUk_JE4FB9FxJ76GjKJQ@mail.gmail.com/

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

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

index at:
100644 c5000fa461675ecb29204feab4d6726f002268dc	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).