aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-01 15:09:59 +0000
committerRoy Marples <roy@marples.name>2008-02-01 15:09:59 +0000
commitf12f3e0641430b9011e21e2ba7781035d545b4ed (patch)
tree7a8f84b6104c1a8ec598196cadfc371ed64ce55d
parent62096f542ff767d41bb237bcf43e972c9690523a (diff)
Factor out the str attribute in the ecolors array to its own array. This way ecolors can be marked const.
-rw-r--r--src/libeinfo/libeinfo.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c
index eec7798f..15e54d60 100644
--- a/src/libeinfo/libeinfo.c
+++ b/src/libeinfo/libeinfo.c
@@ -122,18 +122,18 @@ struct ecolor {
einfo_color_t color;
int def;
const char *name;
- char *str;
};
static char nullstr = '\0';
-static struct ecolor ecolors[] = {
- { ECOLOR_GOOD, GOOD, "good", NULL },
- { ECOLOR_WARN, WARN, "warn", NULL },
- { ECOLOR_BAD, BAD, "bad", NULL },
- { ECOLOR_HILITE, HILITE, "hilite", NULL },
- { ECOLOR_BRACKET, BRACKET, "bracket", NULL },
- { ECOLOR_NORMAL, 0, NULL, NULL },
+static const struct ecolor ecolors[] = {
+ { ECOLOR_GOOD, GOOD, "good" },
+ { ECOLOR_WARN, WARN, "warn" },
+ { ECOLOR_BAD, BAD, "bad" },
+ { ECOLOR_HILITE, HILITE, "hilite" },
+ { ECOLOR_BRACKET, BRACKET, "bracket" },
+ { ECOLOR_NORMAL, 0, NULL },
};
+static const char *ecolors_str[sizeof(ecolors)/sizeof(ecolors[0])];
static char *flush = NULL;
static char *up = NULL;
@@ -442,9 +442,9 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f)
_GET_CAP (tmp, _me);
if (tmp[0])
- _ASSIGN_CAP (ecolors[i].str)
+ _ASSIGN_CAP (ecolors_str[i])
else
- ecolors[i].str = &nullstr;
+ ecolors_str[i] = &nullstr;
}
_GET_CAP (tmp, _ce)
@@ -540,7 +540,7 @@ static const char *_ecolor (FILE * __EINFO_RESTRICT f, einfo_color_t color)
for (i = 0; i < sizeof (ecolors) / sizeof (ecolors[0]); i++) {
if (ecolors[i].color == color)
- return (ecolors[i].str);
+ return (ecolors_str[i]);
}
return ("");