aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2022-03-09 21:08:04 +0000
committerEd Maste <emaste@FreeBSD.org>2022-03-18 01:58:01 +0000
commit1dcb6002c500b65b97e96584aa22398c70d31ee5 (patch)
tree49870a9e1954fbf15c1f9c0b6539918c915fe178
parent19b779498ca7c2ea1cc24cf1ede62c22b4d09a42 (diff)
downloadsrc-1dcb6002c500.tar.gz
src-1dcb6002c500.zip
loader: support numeric and named bright colors (8-15)
Accept "bright" or "light" prefix for named colors. For numeric colors, update error message to specify that values 0 to 15 are allowed, and verify that values are in that range. Reviewed by: imp, tsoome (both earlier version) Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34512 (cherry picked from commit 425e57e7a2f754f7be8425bf3b00ce1469aba5b0)
-rw-r--r--stand/efi/libefi/efi_console.c34
-rw-r--r--stand/i386/libi386/vidconsole.c34
2 files changed, 44 insertions, 24 deletions
diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c
index bacc2546e070..a000b8872c84 100644
--- a/stand/efi/libefi/efi_console.c
+++ b/stand/efi/libefi/efi_console.c
@@ -436,36 +436,44 @@ efi_cons_probe(struct console *cp)
static bool
color_name_to_teken(const char *name, int *val)
{
+ int light = 0;
+ if (strncasecmp(name, "light", 5) == 0) {
+ name += 5;
+ light = TC_LIGHT;
+ } else if (strncasecmp(name, "bright", 6) == 0) {
+ name += 6;
+ light = TC_LIGHT;
+ }
if (strcasecmp(name, "black") == 0) {
- *val = TC_BLACK;
+ *val = TC_BLACK | light;
return (true);
}
if (strcasecmp(name, "red") == 0) {
- *val = TC_RED;
+ *val = TC_RED | light;
return (true);
}
if (strcasecmp(name, "green") == 0) {
- *val = TC_GREEN;
+ *val = TC_GREEN | light;
return (true);
}
if (strcasecmp(name, "brown") == 0) {
- *val = TC_BROWN;
+ *val = TC_BROWN | light;
return (true);
}
if (strcasecmp(name, "blue") == 0) {
- *val = TC_BLUE;
+ *val = TC_BLUE | light;
return (true);
}
if (strcasecmp(name, "magenta") == 0) {
- *val = TC_MAGENTA;
+ *val = TC_MAGENTA | light;
return (true);
}
if (strcasecmp(name, "cyan") == 0) {
- *val = TC_CYAN;
+ *val = TC_CYAN | light;
return (true);
}
if (strcasecmp(name, "white") == 0) {
- *val = TC_WHITE;
+ *val = TC_WHITE | light;
return (true);
}
return (false);
@@ -475,7 +483,7 @@ static int
efi_set_colors(struct env_var *ev, int flags, const void *value)
{
int val = 0;
- char buf[2];
+ char buf[3];
const void *evalue;
const teken_attr_t *ap;
teken_attr_t a;
@@ -488,14 +496,16 @@ efi_set_colors(struct env_var *ev, int flags, const void *value)
evalue = buf;
} else {
char *end;
+ long lval;
errno = 0;
- val = (int)strtol(value, &end, 0);
- if (errno != 0 || *end != '\0') {
+ lval = strtol(value, &end, 0);
+ if (errno != 0 || *end != '\0' || lval < 0 || lval > 15) {
printf("Allowed values are either ansi color name or "
- "number from range [0-7].\n");
+ "number from range [0-15].\n");
return (CMD_OK);
}
+ val = (int)lval;
evalue = value;
}
diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c
index b933a7807687..3a6cba8f1561 100644
--- a/stand/i386/libi386/vidconsole.c
+++ b/stand/i386/libi386/vidconsole.c
@@ -524,36 +524,44 @@ vidc_probe(struct console *cp)
static bool
color_name_to_teken(const char *name, int *val)
{
+ int light = 0;
+ if (strncasecmp(name, "light", 5) == 0) {
+ name += 5;
+ light = TC_LIGHT;
+ } else if (strncasecmp(name, "bright", 6) == 0) {
+ name += 6;
+ light = TC_LIGHT;
+ }
if (strcasecmp(name, "black") == 0) {
- *val = TC_BLACK;
+ *val = TC_BLACK | light;
return (true);
}
if (strcasecmp(name, "red") == 0) {
- *val = TC_RED;
+ *val = TC_RED | light;
return (true);
}
if (strcasecmp(name, "green") == 0) {
- *val = TC_GREEN;
+ *val = TC_GREEN | light;
return (true);
}
if (strcasecmp(name, "brown") == 0) {
- *val = TC_BROWN;
+ *val = TC_BROWN | light;
return (true);
}
if (strcasecmp(name, "blue") == 0) {
- *val = TC_BLUE;
+ *val = TC_BLUE | light;
return (true);
}
if (strcasecmp(name, "magenta") == 0) {
- *val = TC_MAGENTA;
+ *val = TC_MAGENTA | light;
return (true);
}
if (strcasecmp(name, "cyan") == 0) {
- *val = TC_CYAN;
+ *val = TC_CYAN | light;
return (true);
}
if (strcasecmp(name, "white") == 0) {
- *val = TC_WHITE;
+ *val = TC_WHITE | light;
return (true);
}
return (false);
@@ -563,7 +571,7 @@ static int
vidc_set_colors(struct env_var *ev, int flags, const void *value)
{
int val = 0;
- char buf[2];
+ char buf[3];
const void *evalue;
const teken_attr_t *ap;
teken_attr_t a;
@@ -576,14 +584,16 @@ vidc_set_colors(struct env_var *ev, int flags, const void *value)
evalue = buf;
} else {
char *end;
+ long lval;
errno = 0;
- val = (int)strtol(value, &end, 0);
- if (errno != 0 || *end != '\0') {
+ lval = strtol(value, &end, 0);
+ if (errno != 0 || *end != '\0' || lval < 0 || lval > 15) {
printf("Allowed values are either ansi color name or "
- "number from range [0-7].\n");
+ "number from range [0-15].\n");
return (CMD_OK);
}
+ val = (int)lval;
evalue = value;
}