Merge from trunk
This commit is contained in:
commit
d94000ed13
210 changed files with 4949 additions and 2557 deletions
23
lib/arg.c
23
lib/arg.c
|
@ -22,6 +22,7 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
/* Built-in parser for default options. */
|
||||
#define SHORT_ARG_HELP -100
|
||||
|
@ -30,9 +31,9 @@
|
|||
static const struct grub_arg_option help_options[] =
|
||||
{
|
||||
{"help", SHORT_ARG_HELP, 0,
|
||||
"display this help and exit", 0, ARG_TYPE_NONE},
|
||||
N_("Display this help and exit."), 0, ARG_TYPE_NONE},
|
||||
{"usage", SHORT_ARG_USAGE, 0,
|
||||
"display the usage of this command and exit", 0, ARG_TYPE_NONE},
|
||||
N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -106,7 +107,7 @@ find_long (const struct grub_arg_option *options, const char *s, int len)
|
|||
static void
|
||||
show_usage (grub_extcmd_t cmd)
|
||||
{
|
||||
grub_printf ("Usage: %s\n", cmd->cmd->summary);
|
||||
grub_printf ("%s %s\n", _("Usage:"), _(cmd->cmd->summary));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -143,7 +144,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
|
|||
}
|
||||
}
|
||||
|
||||
const char *doc = opt->doc;
|
||||
const char *doc = _(opt->doc);
|
||||
for (;;)
|
||||
{
|
||||
while (spacing-- > 0)
|
||||
|
@ -176,7 +177,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
|
|||
}
|
||||
|
||||
show_usage (cmd);
|
||||
grub_printf ("%s\n\n", cmd->cmd->description);
|
||||
grub_printf ("%s\n\n", _(cmd->cmd->description));
|
||||
if (cmd->options)
|
||||
showargs (cmd->options);
|
||||
showargs (help_options);
|
||||
|
@ -274,7 +275,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
if (! opt)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Unknown argument `-%c'\n", *curshort);
|
||||
"unknown argument `-%c'", *curshort);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -326,7 +327,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
opt = find_long (cmd->options, arg + 2, arglen);
|
||||
if (! opt)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown argument `%s'\n", arg);
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown argument `%s'", arg);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +338,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
if (! option)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Missing mandatory option for `%s'\n", opt->longarg);
|
||||
"missing mandatory option for `%s'", opt->longarg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -359,7 +360,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
if (tail == 0 || tail == option || *tail != '\0' || grub_errno)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"The argument `%s' requires an integer.",
|
||||
"the argument `%s' requires an integer",
|
||||
arg);
|
||||
|
||||
goto fail;
|
||||
|
@ -382,8 +383,8 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
if (option)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"A value was assigned to the argument `%s' while it "
|
||||
"doesn't require an argument\n", arg);
|
||||
"a value was assigned to the argument `%s' while it "
|
||||
"doesn't require an argument", arg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
116
lib/charset.c
Normal file
116
lib/charset.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
|
||||
bytes (if SRCSIZE is -1, it is ignored) in length to a UTF-16 string.
|
||||
Return the number of characters converted. DEST must be able to hold
|
||||
at least DESTSIZE characters. If an invalid sequence is found, return -1.
|
||||
If SRCEND is not NULL, then *SRCEND is set to the next byte after the
|
||||
last byte used in SRC. */
|
||||
|
||||
#include <grub/charset.h>
|
||||
|
||||
grub_ssize_t
|
||||
grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend)
|
||||
{
|
||||
grub_uint16_t *p = dest;
|
||||
int count = 0;
|
||||
grub_uint32_t code = 0;
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
|
||||
while (srcsize && destsize)
|
||||
{
|
||||
grub_uint32_t c = *src++;
|
||||
if (srcsize != (grub_size_t)-1)
|
||||
srcsize--;
|
||||
if (count)
|
||||
{
|
||||
if ((c & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||
{
|
||||
/* invalid */
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
code <<= 6;
|
||||
code |= (c & GRUB_UINT8_6_TRAILINGBITS);
|
||||
count--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
if ((c & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||
code = c;
|
||||
else if ((c & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS)
|
||||
{
|
||||
count = 1;
|
||||
code = c & GRUB_UINT8_5_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS)
|
||||
{
|
||||
count = 2;
|
||||
code = c & GRUB_UINT8_4_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS)
|
||||
{
|
||||
count = 3;
|
||||
code = c & GRUB_UINT8_3_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_6_LEADINGBITS) == GRUB_UINT8_5_LEADINGBITS)
|
||||
{
|
||||
count = 4;
|
||||
code = c & GRUB_UINT8_2_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_7_LEADINGBITS) == GRUB_UINT8_6_LEADINGBITS)
|
||||
{
|
||||
count = 5;
|
||||
code = c & GRUB_UINT8_1_TRAILINGBIT;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (destsize < 2 && code >= GRUB_UCS2_LIMIT)
|
||||
break;
|
||||
if (code >= GRUB_UCS2_LIMIT)
|
||||
{
|
||||
*p++ = GRUB_UTF16_UPPER_SURROGATE (code);
|
||||
*p++ = GRUB_UTF16_LOWER_SURROGATE (code);
|
||||
destsize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = code;
|
||||
destsize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
return p - dest;
|
||||
}
|
|
@ -33,7 +33,7 @@ grub_get_root_biosnumber_default (void)
|
|||
return grub_strtoul (biosnum, 0, 0);
|
||||
|
||||
dev = grub_device_open (0);
|
||||
if (dev && dev->disk && dev->disk->dev
|
||||
if (dev && dev->disk && dev->disk->dev
|
||||
&& dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID)
|
||||
ret = (int) dev->disk->id;
|
||||
|
||||
|
|
|
@ -85,14 +85,14 @@ write_call_relocator_fw (void *ptr, void *src, grub_uint32_t dest,
|
|||
grub_relocator32_forward_dest = dest;
|
||||
grub_relocator32_forward_src = PTR_TO_UINT64 (src);
|
||||
grub_relocator32_forward_size = size;
|
||||
|
||||
|
||||
grub_relocator32_forward_eax = state.eax;
|
||||
grub_relocator32_forward_ebx = state.ebx;
|
||||
grub_relocator32_forward_ecx = state.ecx;
|
||||
grub_relocator32_forward_edx = state.edx;
|
||||
grub_relocator32_forward_eip = state.eip;
|
||||
grub_relocator32_forward_esp = state.esp;
|
||||
|
||||
|
||||
grub_memmove (ptr,
|
||||
&grub_relocator32_forward_start,
|
||||
RELOCATOR_SIZEOF (forward));
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#else
|
||||
#define RAX %eax
|
||||
#define RCX %ecx
|
||||
#define RDI %edi
|
||||
#define RSI %esi
|
||||
#define RDI %edi
|
||||
#define RSI %esi
|
||||
#endif
|
||||
|
||||
/* The code segment of the protected mode. */
|
||||
|
@ -41,7 +41,7 @@
|
|||
|
||||
/* The data segment of the protected mode. */
|
||||
#define DATA_SEGMENT 0x18
|
||||
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
|
||||
RELOCATOR_VARIABLE(start)
|
||||
|
@ -92,7 +92,7 @@ RELOCATOR_VARIABLE(size)
|
|||
#endif
|
||||
|
||||
mov RDI, RAX
|
||||
|
||||
|
||||
#ifdef BACKWARD
|
||||
add RCX, RSI
|
||||
add RCX, RDI
|
||||
|
@ -104,7 +104,7 @@ RELOCATOR_VARIABLE(size)
|
|||
add $0x3, RCX
|
||||
shr $2, RCX
|
||||
|
||||
|
||||
|
||||
#ifdef BACKWARD
|
||||
/* Backward movsl is implicitly off-by-four. compensate that. */
|
||||
sub $4, RSI
|
||||
|
@ -213,7 +213,7 @@ RELOCATOR_VARIABLE (eip)
|
|||
LOCAL(gdt):
|
||||
/* NULL. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
|
||||
/* Reserved. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
|
@ -234,7 +234,7 @@ LOCAL(gdt_addr):
|
|||
/* Filled by the code. */
|
||||
.long 0
|
||||
#endif
|
||||
|
||||
|
||||
.p2align 4
|
||||
LOCAL(jump_vector):
|
||||
/* Jump location. Is filled by the code */
|
||||
|
|
|
@ -79,7 +79,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest,
|
|||
/* Very unlikely condition: Relocator may risk overwrite itself.
|
||||
Just move it a bit up. */
|
||||
if ((grub_addr_t) dest < (grub_addr_t) relocator
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)
|
||||
&& (grub_addr_t) dest + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
|
||||
> (grub_addr_t) relocator)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest,
|
|||
"Backward relocator: code %p, source: %p, "
|
||||
"destination: 0x%x, size: 0x%lx\n",
|
||||
(char *) relocator - overhead,
|
||||
(char *) relocator - overhead,
|
||||
(char *) relocator - overhead,
|
||||
(unsigned) dest - overhead,
|
||||
(unsigned long) size + overhead);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue