From 432069398f7975b42fa256cf432f39883a8b50e1 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 9 Feb 2012 14:48:35 +0100 Subject: [PATCH] * grub-core/video/colors.c (grub_video_parse_color): Fix error message. Remove assignment in if while on it. --- ChangeLog | 5 +++++ grub-core/video/colors.c | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a64aa80c..c9c54a1e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-09 Vladimir Serbinenko + + * grub-core/video/colors.c (grub_video_parse_color): Fix error message. + Remove assignment in if while on it. + 2012-02-09 Vladimir Serbinenko * util/grub-mkstandalone.in: Fix modules directory. diff --git a/grub-core/video/colors.c b/grub-core/video/colors.c index ca1d3332b..76359eaf0 100644 --- a/grub-core/video/colors.c +++ b/grub-core/video/colors.c @@ -245,11 +245,14 @@ grub_err_t grub_video_parse_color (const char *s, grub_video_rgba_color_t *color) { grub_video_rgba_color_t c; + const char *s0; /* Skip whitespace. */ while (*s && grub_isspace (*s)) s++; + s0 = s; + if (*s == '#') { /* HTML-style. Number if hex digits: @@ -289,23 +292,26 @@ grub_video_parse_color (const char *s, grub_video_rgba_color_t *color) } else return grub_error (GRUB_ERR_BAD_ARGUMENT, - "invalid HTML-type color string `%s'", s); + N_("invalid color specification `%s'"), s0); } else if (grub_isdigit (*s)) { /* Comma separated decimal values. */ c.red = grub_strtoul (s, 0, 0); - if ((s = grub_strchr (s, ',')) == 0) + s = grub_strchr (s, ','); + if (!s) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "missing 1st comma separator in color `%s'", s); + N_("invalid color specification `%s'"), s0); s++; c.green = grub_strtoul (s, 0, 0); - if ((s = grub_strchr (s, ',')) == 0) + s = grub_strchr (s, ','); + if (!s) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "missing 2nd comma separator in color `%s'", s); + N_("invalid color specification `%s'"), s0); s++; c.blue = grub_strtoul (s, 0, 0); - if ((s = grub_strchr (s, ',')) == 0) + s = grub_strchr (s, ','); + if (!s) c.alpha = 255; else { @@ -317,7 +323,7 @@ grub_video_parse_color (const char *s, grub_video_rgba_color_t *color) { if (! grub_video_get_named_color (s, &c)) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "invalid named color `%s'", s); + N_("invalid color specification `%s'"), s0); } if (grub_errno == GRUB_ERR_NONE)