Improve gettext support. Stylistic fixes and error handling fixes while

on it.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-08 19:26:01 +01:00
parent 215c90cb82
commit 9c4b5c13e6
184 changed files with 1175 additions and 959 deletions

View file

@ -60,12 +60,12 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
unsigned int size;
if (!bitmap)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
return grub_error (GRUB_ERR_BUG, "invalid argument");
*bitmap = 0;
if (width == 0 || height == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
return grub_error (GRUB_ERR_BUG, "invalid argument");
*bitmap = (struct grub_video_bitmap *)grub_malloc (sizeof (struct grub_video_bitmap));
if (! *bitmap)
@ -130,7 +130,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
grub_free (*bitmap);
*bitmap = 0;
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported bitmap format");
}
@ -190,7 +190,7 @@ grub_video_bitmap_load (struct grub_video_bitmap **bitmap,
grub_video_bitmap_reader_t reader = bitmap_readers_list;
if (!bitmap)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
return grub_error (GRUB_ERR_BUG, "invalid argument");
*bitmap = 0;
@ -202,7 +202,7 @@ grub_video_bitmap_load (struct grub_video_bitmap **bitmap,
reader = reader->next;
}
return grub_error(GRUB_ERR_BAD_FILE_TYPE, "unsupported bitmap format");
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported bitmap format");
}
/* Return bitmap width. */

View file

@ -54,22 +54,22 @@ grub_video_bitmap_create_scaled (struct grub_video_bitmap **dst,
/* Verify the simplifying assumptions. */
if (src == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BUG,
"null src bitmap in grub_video_bitmap_create_scaled");
if (src->mode_info.red_field_pos % 8 != 0
|| src->mode_info.green_field_pos % 8 != 0
|| src->mode_info.blue_field_pos % 8 != 0
|| src->mode_info.reserved_field_pos % 8 != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"src format not supported for scale");
if (src->mode_info.width == 0 || src->mode_info.height == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"source bitmap has a zero dimension");
if (dst_width <= 0 || dst_height <= 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BUG,
"requested to scale to a size w/ a zero dimension");
if (src->mode_info.bytes_per_pixel * 8 != src->mode_info.bpp)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BUG,
"bitmap to scale has inconsistent Bpp and bpp");
/* Create the new bitmap. */
@ -90,7 +90,7 @@ grub_video_bitmap_create_scaled (struct grub_video_bitmap **dst,
ret = scale_bilinear (*dst, src);
break;
default:
ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid scale_method value");
ret = grub_error (GRUB_ERR_BUG, "Invalid scale_method value");
break;
}
@ -123,17 +123,19 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
{
/* Verify the simplifying assumptions. */
if (dst == 0 || src == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "null bitmap in scale_nn");
return grub_error (GRUB_ERR_BUG, "null bitmap in scale_nn");
if (dst->mode_info.red_field_pos % 8 != 0
|| dst->mode_info.green_field_pos % 8 != 0
|| dst->mode_info.blue_field_pos % 8 != 0
|| dst->mode_info.reserved_field_pos % 8 != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "dst format not supported");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"dst format not supported");
if (src->mode_info.red_field_pos % 8 != 0
|| src->mode_info.green_field_pos % 8 != 0
|| src->mode_info.blue_field_pos % 8 != 0
|| src->mode_info.reserved_field_pos % 8 != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "src format not supported");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"src format not supported");
if (dst->mode_info.red_field_pos != src->mode_info.red_field_pos
|| dst->mode_info.red_mask_size != src->mode_info.red_mask_size
|| dst->mode_info.green_field_pos != src->mode_info.green_field_pos
@ -144,12 +146,14 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
src->mode_info.reserved_field_pos
|| dst->mode_info.reserved_mask_size !=
src->mode_info.reserved_mask_size)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "dst and src not compatible");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"dst and src not compatible");
if (dst->mode_info.bytes_per_pixel != src->mode_info.bytes_per_pixel)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "dst and src not compatible");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"dst and src not compatible");
if (dst->mode_info.width == 0 || dst->mode_info.height == 0
|| src->mode_info.width == 0 || src->mode_info.height == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bitmap has a zero dimension");
return grub_error (GRUB_ERR_BUG, "bitmap has a zero dimension");
grub_uint8_t *ddata = dst->data;
grub_uint8_t *sdata = src->data;
@ -206,17 +210,17 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
{
/* Verify the simplifying assumptions. */
if (dst == 0 || src == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "null bitmap in scale func");
return grub_error (GRUB_ERR_BUG, "null bitmap in scale func");
if (dst->mode_info.red_field_pos % 8 != 0
|| dst->mode_info.green_field_pos % 8 != 0
|| dst->mode_info.blue_field_pos % 8 != 0
|| dst->mode_info.reserved_field_pos % 8 != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "dst format not supported");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "dst format not supported");
if (src->mode_info.red_field_pos % 8 != 0
|| src->mode_info.green_field_pos % 8 != 0
|| src->mode_info.blue_field_pos % 8 != 0
|| src->mode_info.reserved_field_pos % 8 != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "src format not supported");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "src format not supported");
if (dst->mode_info.red_field_pos != src->mode_info.red_field_pos
|| dst->mode_info.red_mask_size != src->mode_info.red_mask_size
|| dst->mode_info.green_field_pos != src->mode_info.green_field_pos
@ -227,12 +231,12 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
src->mode_info.reserved_field_pos
|| dst->mode_info.reserved_mask_size !=
src->mode_info.reserved_mask_size)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "dst and src not compatible");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "dst and src not compatible");
if (dst->mode_info.bytes_per_pixel != src->mode_info.bytes_per_pixel)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "dst and src not compatible");
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "dst and src not compatible");
if (dst->mode_info.width == 0 || dst->mode_info.height == 0
|| src->mode_info.width == 0 || src->mode_info.height == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bitmap has a zero dimension");
return grub_error (GRUB_ERR_BUG, "bitmap has a zero dimension");
grub_uint8_t *ddata = dst->data;
grub_uint8_t *sdata = src->data;

View file

@ -22,6 +22,7 @@
#include <grub/gui_string_util.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");

View file

@ -1130,7 +1130,7 @@ grub_video_fb_create_render_target (struct grub_video_fbrender_target **result,
if ((! result)
|| (width == 0)
|| (height == 0))
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BUG,
"invalid argument given");
/* Allocate memory for render target. */
@ -1263,7 +1263,7 @@ grub_video_fb_set_active_render_target (struct grub_video_fbrender_target *targe
target = framebuffer.back_target;
if (! target->data)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BUG,
"invalid render target given");
framebuffer.render_target = target;

View file

@ -434,7 +434,7 @@ grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot get preferred mode");
}
grub_err_t
static grub_err_t
grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
struct grub_vbe_mode_info_block *vbe_mode_info)
{

View file

@ -773,7 +773,7 @@ grub_cmd_jpegtest (grub_command_t cmd __attribute__ ((unused)),
struct grub_video_bitmap *bitmap = 0;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("file name expected"));
grub_video_reader_jpeg (&bitmap, args[0]);
if (grub_errno != GRUB_ERR_NONE)

View file

@ -877,7 +877,7 @@ grub_cmd_pngtest (grub_command_t cmd __attribute__ ((unused)),
struct grub_video_bitmap *bitmap = 0;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
grub_video_reader_png (&bitmap, args[0]);
if (grub_errno != GRUB_ERR_NONE)

View file

@ -21,6 +21,7 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -440,7 +441,7 @@ parse_modespec (const char *current_mode, int *width, int *height, int *depth)
param = grub_strchr(param, 'x');
if (param == NULL)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
N_("invalid video mode specification `%s'"),
current_mode);
param++;
@ -448,7 +449,7 @@ parse_modespec (const char *current_mode, int *width, int *height, int *depth)
*width = grub_strtoul (value, 0, 0);
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
N_("invalid video mode specification `%s'"),
current_mode);
/* Find height value. */
@ -459,7 +460,7 @@ parse_modespec (const char *current_mode, int *width, int *height, int *depth)
*height = grub_strtoul (value, 0, 0);
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
N_("invalid video mode specification `%s'"),
current_mode);
}
else
@ -470,7 +471,7 @@ parse_modespec (const char *current_mode, int *width, int *height, int *depth)
*height = grub_strtoul (value, 0, 0);
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
N_("invalid video mode specification `%s'"),
current_mode);
/* Convert color depth value. */
@ -478,7 +479,7 @@ parse_modespec (const char *current_mode, int *width, int *height, int *depth)
*depth = grub_strtoul (value, 0, 0);
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
N_("invalid video mode specification `%s'"),
current_mode);
}
return GRUB_ERR_NONE;