Fix for misspelled color names defaulting to black/black (bug
reported by Doug Nazar) * include/grub/normal.h (grub_parse_color_name_pair): Add return status to prototype. * normal/color.c (grub_parse_color_name_pair): Return failure status. (grub_env_write_color_normal): Ignore bad color names. (grub_env_write_color_highlight): Likewise. * normal/main.c (GRUB_MOD_INIT): Set default color names.
This commit is contained in:
commit
7a3c13dea5
4 changed files with 32 additions and 12 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2010-08-12 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
Fix for misspelled color names defaulting to black/black (bug
|
||||||
|
reported by Doug Nazar)
|
||||||
|
|
||||||
|
* include/grub/normal.h (grub_parse_color_name_pair): Add return
|
||||||
|
status to prototype.
|
||||||
|
* normal/color.c (grub_parse_color_name_pair): Return failure
|
||||||
|
status.
|
||||||
|
(grub_env_write_color_normal): Ignore bad color names.
|
||||||
|
(grub_env_write_color_highlight): Likewise.
|
||||||
|
* normal/main.c (GRUB_MOD_INIT): Set default color names.
|
||||||
|
|
||||||
2010-08-12 BVK Chaitanya <bvk.groups@gmail.com>
|
2010-08-12 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
"shift" command support to GRUB script.
|
"shift" command support to GRUB script.
|
||||||
|
|
|
@ -73,7 +73,7 @@ grub_err_t grub_normal_print_device_info (const char *name);
|
||||||
/* Defined in `color.c'. */
|
/* Defined in `color.c'. */
|
||||||
char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
|
char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
|
||||||
char *grub_env_write_color_highlight (struct grub_env_var *var, const char *val);
|
char *grub_env_write_color_highlight (struct grub_env_var *var, const char *val);
|
||||||
void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
|
int grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
|
||||||
|
|
||||||
/* Defined in `menu_text.c'. */
|
/* Defined in `menu_text.c'. */
|
||||||
void grub_wait_after_message (void);
|
void grub_wait_after_message (void);
|
||||||
|
|
|
@ -56,22 +56,23 @@ parse_color_name (grub_uint8_t *ret, char *name)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
grub_parse_color_name_pair (grub_uint8_t *ret, const char *name)
|
grub_parse_color_name_pair (grub_uint8_t *color, const char *name)
|
||||||
{
|
{
|
||||||
|
int result = 1;
|
||||||
grub_uint8_t fg, bg;
|
grub_uint8_t fg, bg;
|
||||||
char *fg_name, *bg_name;
|
char *fg_name, *bg_name;
|
||||||
|
|
||||||
/* nothing specified by user */
|
/* nothing specified by user */
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return;
|
return result;
|
||||||
|
|
||||||
fg_name = grub_strdup (name);
|
fg_name = grub_strdup (name);
|
||||||
if (fg_name == NULL)
|
if (fg_name == NULL)
|
||||||
{
|
{
|
||||||
/* "out of memory" message was printed by grub_strdup() */
|
/* "out of memory" message was printed by grub_strdup() */
|
||||||
grub_wait_after_message ();
|
grub_wait_after_message ();
|
||||||
return;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bg_name = grub_strchr (fg_name, '/');
|
bg_name = grub_strchr (fg_name, '/');
|
||||||
|
@ -97,10 +98,12 @@ grub_parse_color_name_pair (grub_uint8_t *ret, const char *name)
|
||||||
goto free_and_return;
|
goto free_and_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret = (bg << 4) | fg;
|
*color = (bg << 4) | fg;
|
||||||
|
result = 0;
|
||||||
|
|
||||||
free_and_return:
|
free_and_return:
|
||||||
grub_free (fg_name);
|
grub_free (fg_name);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint8_t color_normal, color_highlight;
|
static grub_uint8_t color_normal, color_highlight;
|
||||||
|
@ -122,10 +125,10 @@ set_colors (void)
|
||||||
|
|
||||||
/* Replace default `normal' colors with the ones specified by user (if any). */
|
/* Replace default `normal' colors with the ones specified by user (if any). */
|
||||||
char *
|
char *
|
||||||
grub_env_write_color_normal (struct grub_env_var *var __attribute__ ((unused)),
|
grub_env_write_color_normal (struct grub_env_var *var, const char *val)
|
||||||
const char *val)
|
|
||||||
{
|
{
|
||||||
grub_parse_color_name_pair (&color_normal, val);
|
if (grub_parse_color_name_pair (&color_normal, val))
|
||||||
|
return 0;
|
||||||
|
|
||||||
set_colors ();
|
set_colors ();
|
||||||
|
|
||||||
|
@ -134,10 +137,10 @@ grub_env_write_color_normal (struct grub_env_var *var __attribute__ ((unused)),
|
||||||
|
|
||||||
/* Replace default `highlight' colors with the ones specified by user (if any). */
|
/* Replace default `highlight' colors with the ones specified by user (if any). */
|
||||||
char *
|
char *
|
||||||
grub_env_write_color_highlight (struct grub_env_var *var __attribute__ ((unused)),
|
grub_env_write_color_highlight (struct grub_env_var *var, const char *val)
|
||||||
const char *val)
|
|
||||||
{
|
{
|
||||||
grub_parse_color_name_pair (&color_highlight, val);
|
if (grub_parse_color_name_pair (&color_highlight, val))
|
||||||
|
return 0;
|
||||||
|
|
||||||
set_colors ();
|
set_colors ();
|
||||||
|
|
||||||
|
|
|
@ -705,6 +705,10 @@ GRUB_MOD_INIT(normal)
|
||||||
/* Preserve hooks after context changes. */
|
/* Preserve hooks after context changes. */
|
||||||
grub_env_export ("color_normal");
|
grub_env_export ("color_normal");
|
||||||
grub_env_export ("color_highlight");
|
grub_env_export ("color_highlight");
|
||||||
|
|
||||||
|
/* Set default color names. */
|
||||||
|
grub_env_set ("color_normal", "white/black");
|
||||||
|
grub_env_set ("color_highlight", "black/white");
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(normal)
|
GRUB_MOD_FINI(normal)
|
||||||
|
|
Loading…
Reference in a new issue