mailing list of musl libc
 help / color / mirror / code / Atom feed
98fdaca225a964d29e9205506cd20e58f88cedb1 blob 2297 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
81
82
83
84
 
/* Public domain fmtmsg()
 * Written by Isaac Dunham, 2014
 */
#include <fmtmsg.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


/* 
 * If lstr is the first part of bstr, check that the next char in bstr
 * is either \0 or :
 */
static int _strcolcmp(const char *lstr, const char *bstr)
{
	size_t i = 0;
	while (lstr[i] && bstr[i] && (bstr[i] == lstr[i])) i++;
	if ( lstr[i] || (bstr[i] && bstr[i] != ':')) return 1;
	return 0;
}
int fmtmsg(long classification, const char *label, int severity,
	       	const char *text, const char *action, const char *tag)
{
	int ret = 0, i, consolefd = 0, verb = 0;
	char *errstring = MM_NULLSEV, *cmsg = getenv("MSGVERB");
	char *const msgs[] = {
		"label", "severity", "text", "action", "tag", NULL
	};

	if (classification & MM_CONSOLE)
		consolefd = open("/dev/console", O_WRONLY);
	if (consolefd < 0) {
		classification &= ~MM_CONSOLE;
		ret = MM_NOCON;
		consolefd = 0;
	}
	if (severity == MM_HALT) errstring = "HALT: ";
	else if (severity == MM_ERROR) errstring = "ERROR: ";
	else if (severity == MM_WARNING) errstring = "WARNING: ";
	else if (severity == MM_INFO) errstring = "INFO: ";
	if (consolefd) {
		if (dprintf(consolefd, "%s%s%s%s%s%s%s%s\n",
			    label?label:"", label?": ":"",
			    severity?errstring:"", text?text:"",
			    action?"\nTO FIX: ":"",
			    action?action:"", action?" ":"", tag?tag:"" )<1) 
			ret = MM_NOCON;
	}

	if (cmsg) {
		while (cmsg && cmsg[0]) {
			for(i=0; msgs[i]; i++) {
				if (!_strcolcmp(msgs[i], cmsg)) break;
			}
			if (msgs[i] == NULL) {
				//ignore MSGVERB-unrecognized component 
				verb =0xFF;
				break;
			} else {
				verb |= (1 << i);
				cmsg = strchr(cmsg, ':');
				if (cmsg) cmsg++;
			}
		}
	}
	if (!verb) verb = 0xFF;
	if (classification & MM_PRINT) {
		if (dprintf(2, "%s%s%s%s%s%s%s%s\n",
			    (verb&1 && label) ? label : "",
			    (verb&1 && label) ? ": " : "",
			    (verb&2 && severity) ? errstring : "",
			    (verb&4 && text) ? text : "",
			    (verb&8 && action) ? "\nTO FIX: " : "",
			    (verb&8 && action) ? action : "",
			    (verb&8 && action) ? " " : "",
			    (verb&16 && tag) ? tag : "" ) < 1)
			ret |= MM_NOMSG;
	}
	if ((ret & (MM_NOCON|MM_NOMSG) ) ==  (MM_NOCON|MM_NOMSG))
		ret = MM_NOTOK;
	return ret;
}
debug log:

solving 98fdaca ...
found 98fdaca in https://inbox.vuxu.org/musl/20140620143200.GA783@muslin/

applying [1/1] https://inbox.vuxu.org/musl/20140620143200.GA783@muslin/
diff --git a/src/misc/fmtmsg.c b/src/misc/fmtmsg.c
new file mode 100644
index 0000000..98fdaca

1:18: trailing whitespace.
/* 
1:30: space before tab in indent.
	       	const char *text, const char *action, const char *tag)
1:54: trailing whitespace.
			    action?action:"", action?" ":"", tag?tag:"" )<1) 
1:64: trailing whitespace.
				//ignore MSGVERB-unrecognized component 
Checking patch src/misc/fmtmsg.c...
Applied patch src/misc/fmtmsg.c cleanly.
warning: 4 lines add whitespace errors.

index at:
100644 98fdaca225a964d29e9205506cd20e58f88cedb1	src/misc/fmtmsg.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).