* util/grub-mkfont.c (grub_font_info): Make name a const char *.
(add_pixel): Make static. (add_font): Likewise. (write_string_section): Make name and str a const char *. (write_be16_section): Make name a const char *. (print_glyphs): Make static. (write_font_ascii_bitmap): Likewise. (write_font_width_spec): Likewise. (write_font_pf2): Likewise. (argp_parser): Remove unused variable. Respect format security. (main): Avoid shadowing. Respect format security.
This commit is contained in:
parent
0809527b9d
commit
31731fc04f
2 changed files with 73 additions and 58 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* util/grub-mkfont.c (grub_font_info): Make name a const char *.
|
||||||
|
(add_pixel): Make static.
|
||||||
|
(add_font): Likewise.
|
||||||
|
(write_string_section): Make name and str a const char *.
|
||||||
|
(write_be16_section): Make name a const char *.
|
||||||
|
(print_glyphs): Make static.
|
||||||
|
(write_font_ascii_bitmap): Likewise.
|
||||||
|
(write_font_width_spec): Likewise.
|
||||||
|
(write_font_pf2): Likewise.
|
||||||
|
(argp_parser): Remove unused variable.
|
||||||
|
Respect format security.
|
||||||
|
(main): Avoid shadowing. Respect format security.
|
||||||
|
|
||||||
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* util/grub-editenv.c (argp_parser): Make static.
|
* util/grub-editenv.c (argp_parser): Make static.
|
||||||
|
|
|
@ -80,7 +80,7 @@ enum file_formats
|
||||||
|
|
||||||
struct grub_font_info
|
struct grub_font_info
|
||||||
{
|
{
|
||||||
char* name;
|
const char *name;
|
||||||
int style;
|
int style;
|
||||||
int desc;
|
int desc;
|
||||||
int asce;
|
int asce;
|
||||||
|
@ -99,7 +99,7 @@ struct grub_font_info
|
||||||
|
|
||||||
static int font_verbosity;
|
static int font_verbosity;
|
||||||
|
|
||||||
void
|
static void
|
||||||
add_pixel (grub_uint8_t **data, int *mask, int not_blank)
|
add_pixel (grub_uint8_t **data, int *mask, int not_blank)
|
||||||
{
|
{
|
||||||
if (*mask == 0)
|
if (*mask == 0)
|
||||||
|
@ -557,7 +557,7 @@ process_cursive (struct gsub_feature *feature,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
|
add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
|
||||||
{
|
{
|
||||||
struct gsub_header *gsub = NULL;
|
struct gsub_header *gsub = NULL;
|
||||||
|
@ -650,7 +650,8 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_string_section (char *name, char *str, int* offset, FILE *file,
|
write_string_section (const char *name, const char *str,
|
||||||
|
int *offset, FILE *file,
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
grub_uint32_t leng, leng_be32;
|
grub_uint32_t leng, leng_be32;
|
||||||
|
@ -666,8 +667,8 @@ write_string_section (char *name, char *str, int* offset, FILE *file,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_be16_section (char *name, grub_uint16_t data, int* offset, FILE *file,
|
write_be16_section (const char *name, grub_uint16_t data, int* offset,
|
||||||
const char *filename)
|
FILE *file, const char *filename)
|
||||||
{
|
{
|
||||||
grub_uint32_t leng;
|
grub_uint32_t leng;
|
||||||
|
|
||||||
|
@ -680,7 +681,7 @@ write_be16_section (char *name, grub_uint16_t data, int* offset, FILE *file,
|
||||||
*offset += 10;
|
*offset += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
print_glyphs (struct grub_font_info *font_info)
|
print_glyphs (struct grub_font_info *font_info)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
@ -752,7 +753,7 @@ print_glyphs (struct grub_font_info *font_info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
|
write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
@ -786,7 +787,7 @@ write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
|
||||||
fclose (file);
|
fclose (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
write_font_width_spec (struct grub_font_info *font_info, char *output_file)
|
write_font_width_spec (struct grub_font_info *font_info, char *output_file)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
@ -811,7 +812,7 @@ write_font_width_spec (struct grub_font_info *font_info, char *output_file)
|
||||||
free (out);
|
free (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
write_font_pf2 (struct grub_font_info *font_info, char *output_file)
|
write_font_pf2 (struct grub_font_info *font_info, char *output_file)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
@ -992,8 +993,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||||
know is a pointer to our arguments structure. */
|
know is a pointer to our arguments structure. */
|
||||||
struct arguments *arguments = state->input;
|
struct arguments *arguments = state->input;
|
||||||
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -1038,7 +1037,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||||
|
|
||||||
a = strtoul (p, &p, 0);
|
a = strtoul (p, &p, 0);
|
||||||
if (*p != '-')
|
if (*p != '-')
|
||||||
grub_util_error (_("invalid font range"));
|
grub_util_error ("%s", _("invalid font range"));
|
||||||
b = strtoul (p + 1, &p, 0);
|
b = strtoul (p + 1, &p, 0);
|
||||||
if ((arguments->font_info.num_range
|
if ((arguments->font_info.num_range
|
||||||
& (GRUB_FONT_RANGE_BLOCK - 1)) == 0)
|
& (GRUB_FONT_RANGE_BLOCK - 1)) == 0)
|
||||||
|
@ -1054,9 +1053,8 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||||
if (*p)
|
if (*p)
|
||||||
{
|
{
|
||||||
if (*p != ',')
|
if (*p != ',')
|
||||||
grub_util_error (_("invalid font range"));
|
grub_util_error ("%s", _("invalid font range"));
|
||||||
else
|
p++;
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -1106,7 +1104,6 @@ main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FT_Library ft_lib;
|
FT_Library ft_lib;
|
||||||
struct arguments arguments;
|
struct arguments arguments;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
set_program_name (argv[0]);
|
||||||
|
|
||||||
|
@ -1129,7 +1126,7 @@ main (int argc, char *argv[])
|
||||||
if (arguments.file_format == ASCII_BITMAPS
|
if (arguments.file_format == ASCII_BITMAPS
|
||||||
&& arguments.font_info.num_range > 0)
|
&& arguments.font_info.num_range > 0)
|
||||||
{
|
{
|
||||||
grub_util_error (_("Option --ascii-bitmaps doesn't accept ranges (it always uses ASCII)."));
|
grub_util_error ("%s", _("Option --ascii-bitmaps doesn't accept ranges (it always uses ASCII)."));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (arguments.file_format == ASCII_BITMAPS)
|
else if (arguments.file_format == ASCII_BITMAPS)
|
||||||
|
@ -1144,54 +1141,57 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! arguments.output_file)
|
if (! arguments.output_file)
|
||||||
grub_util_error (_("output file must be specified"));
|
grub_util_error ("%s", _("output file must be specified"));
|
||||||
|
|
||||||
if (FT_Init_FreeType (&ft_lib))
|
if (FT_Init_FreeType (&ft_lib))
|
||||||
grub_util_error (_("FT_Init_FreeType fails"));
|
grub_util_error ("%s", _("FT_Init_FreeType fails"));
|
||||||
|
|
||||||
for (i = 0; i < arguments.nfiles; i++)
|
|
||||||
{
|
|
||||||
FT_Face ft_face;
|
|
||||||
int size;
|
|
||||||
FT_Error err;
|
|
||||||
|
|
||||||
err = FT_New_Face (ft_lib, arguments.files[i],
|
{
|
||||||
arguments.font_index, &ft_face);
|
size_t i;
|
||||||
if (err)
|
for (i = 0; i < arguments.nfiles; i++)
|
||||||
{
|
{
|
||||||
grub_printf (_("can't open file %s, index %d: error %d"),
|
FT_Face ft_face;
|
||||||
arguments.files[i],
|
int size;
|
||||||
arguments.font_index, err);
|
FT_Error err;
|
||||||
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
|
|
||||||
printf (": %s\n", ft_errmsgs[err]);
|
|
||||||
else
|
|
||||||
printf ("\n");
|
|
||||||
|
|
||||||
continue;
|
err = FT_New_Face (ft_lib, arguments.files[i],
|
||||||
}
|
arguments.font_index, &ft_face);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_printf (_("can't open file %s, index %d: error %d"),
|
||||||
|
arguments.files[i],
|
||||||
|
arguments.font_index, err);
|
||||||
|
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
|
||||||
|
printf (": %s\n", ft_errmsgs[err]);
|
||||||
|
else
|
||||||
|
printf ("\n");
|
||||||
|
|
||||||
if ((! arguments.font_info.name) && (ft_face->family_name))
|
continue;
|
||||||
arguments.font_info.name = xstrdup (ft_face->family_name);
|
}
|
||||||
|
|
||||||
size = arguments.font_size;
|
if ((! arguments.font_info.name) && (ft_face->family_name))
|
||||||
if (! size)
|
arguments.font_info.name = xstrdup (ft_face->family_name);
|
||||||
{
|
|
||||||
if ((ft_face->face_flags & FT_FACE_FLAG_SCALABLE) ||
|
|
||||||
(! ft_face->num_fixed_sizes))
|
|
||||||
size = GRUB_FONT_DEFAULT_SIZE;
|
|
||||||
else
|
|
||||||
size = ft_face->available_sizes[0].height;
|
|
||||||
}
|
|
||||||
|
|
||||||
arguments.font_info.style = ft_face->style_flags;
|
size = arguments.font_size;
|
||||||
arguments.font_info.size = size;
|
if (! size)
|
||||||
|
{
|
||||||
|
if ((ft_face->face_flags & FT_FACE_FLAG_SCALABLE) ||
|
||||||
|
(! ft_face->num_fixed_sizes))
|
||||||
|
size = GRUB_FONT_DEFAULT_SIZE;
|
||||||
|
else
|
||||||
|
size = ft_face->available_sizes[0].height;
|
||||||
|
}
|
||||||
|
|
||||||
if (FT_Set_Pixel_Sizes (ft_face, size, size))
|
arguments.font_info.style = ft_face->style_flags;
|
||||||
grub_util_error (_("can't set %dx%d font size"),
|
arguments.font_info.size = size;
|
||||||
size, size);
|
|
||||||
add_font (&arguments.font_info, ft_face, arguments.file_format != PF2);
|
if (FT_Set_Pixel_Sizes (ft_face, size, size))
|
||||||
FT_Done_Face (ft_face);
|
grub_util_error (_("can't set %dx%d font size"),
|
||||||
}
|
size, size);
|
||||||
|
add_font (&arguments.font_info, ft_face, arguments.file_format != PF2);
|
||||||
|
FT_Done_Face (ft_face);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FT_Done_FreeType (ft_lib);
|
FT_Done_FreeType (ft_lib);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue