merge with mainline
This commit is contained in:
commit
5ef88f6e95
123 changed files with 4111 additions and 13452 deletions
|
@ -29,6 +29,25 @@
|
|||
#define ARG_ALLOCATION_UNIT (32 * sizeof (char))
|
||||
#define ARGV_ALLOCATION_UNIT (8 * sizeof (void*))
|
||||
|
||||
static unsigned
|
||||
round_up_exp (unsigned v)
|
||||
{
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
|
||||
if (sizeof (v) > 4)
|
||||
v |= v >> 32;
|
||||
|
||||
v++;
|
||||
v += (v == 0);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline int regexop (char ch);
|
||||
static char ** merge (char **lhs, char **rhs);
|
||||
static char *make_dir (const char *prefix, const char *start, const char *end);
|
||||
|
@ -47,7 +66,7 @@ static int expand (char *arg, struct grub_script_argv *argv);
|
|||
void
|
||||
grub_script_argv_free (struct grub_script_argv *argv)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
if (argv->args)
|
||||
{
|
||||
|
@ -69,7 +88,7 @@ grub_script_argv_next (struct grub_script_argv *argv)
|
|||
|
||||
if (argv->argc == 0)
|
||||
{
|
||||
p = grub_malloc (ALIGN_UP (2 * sizeof (char *), ARG_ALLOCATION_UNIT));
|
||||
p = grub_malloc (2 * sizeof (char *));
|
||||
if (! p)
|
||||
return 1;
|
||||
|
||||
|
@ -83,8 +102,7 @@ grub_script_argv_next (struct grub_script_argv *argv)
|
|||
if (! argv->args[argv->argc - 1])
|
||||
return 0;
|
||||
|
||||
p = grub_realloc (p, ALIGN_UP ((argv->argc + 1) * sizeof (char *),
|
||||
ARG_ALLOCATION_UNIT));
|
||||
p = grub_realloc (p, round_up_exp ((argv->argc + 1) * sizeof (char *)));
|
||||
if (! p)
|
||||
return 1;
|
||||
|
||||
|
@ -114,8 +132,7 @@ append (struct grub_script_argv *argv, const char *s, enum append_type type)
|
|||
a = p ? grub_strlen (p) : 0;
|
||||
b = grub_strlen (s) * (type == APPEND_ESCAPED ? 2 : 1);
|
||||
|
||||
p = grub_realloc (p, ALIGN_UP ((a + b + 1) * sizeof (char),
|
||||
ARG_ALLOCATION_UNIT));
|
||||
p = grub_realloc (p, round_up_exp ((a + b + 1) * sizeof (char)));
|
||||
if (! p)
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type)
|
|||
}
|
||||
else if (grub_strcmp (name, "*") == 0)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; ! errors && i < scope->argv.argc; i++)
|
||||
if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
|
||||
|
@ -97,7 +97,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type)
|
|||
}
|
||||
else if (grub_strcmp (name, "@") == 0)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; ! errors && i < scope->argv.argc; i++)
|
||||
{
|
||||
|
@ -364,8 +364,8 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd)
|
|||
grub_err_t
|
||||
grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
|
||||
{
|
||||
int i;
|
||||
int result;
|
||||
unsigned i;
|
||||
grub_err_t result;
|
||||
struct grub_script_argv argv;
|
||||
struct grub_script_cmdfor *cmdfor = (struct grub_script_cmdfor *) cmd;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue