libc: Eliminate some relative relocations in fmtmsg().

This commit is contained in:
Jilles Tjoelker 2012-02-22 21:47:50 +00:00
parent fb53214d28
commit 8b34578da7

View File

@ -45,10 +45,6 @@ static const char
*sevinfo(int); *sevinfo(int);
static int validmsgverb(const char *); static int validmsgverb(const char *);
static const char *validlist[] = {
"label", "severity", "text", "action", "tag", NULL
};
int int
fmtmsg(long class, const char *label, int sev, const char *text, fmtmsg(long class, const char *label, int sev, const char *text,
const char *action, const char *tag) const char *action, const char *tag)
@ -205,14 +201,18 @@ sevinfo(int sev)
static int static int
validmsgverb(const char *msgverb) validmsgverb(const char *msgverb)
{ {
const char *validlist = "label\0severity\0text\0action\0tag\0";
char *msgcomp; char *msgcomp;
int i, equality; size_t len1, len2;
const char *p;
int equality;
equality = 0; equality = 0;
while ((msgcomp = nextcomp(msgverb)) != NULL) { while ((msgcomp = nextcomp(msgverb)) != NULL) {
equality--; equality--;
for (i = 0; validlist[i] != NULL; i++) { len1 = strlen(msgcomp);
if (strcmp(msgcomp, validlist[i]) == 0) for (p = validlist; (len2 = strlen(p)) != 0; p += len2 + 1) {
if (len1 == len2 && memcmp(msgcomp, p, len1) == 0)
equality++; equality++;
} }
} }