2005-08-12 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Added normal/completion.c. * normal/completion.c: New file. * term/i386/pc/console.c (grub_console_getwh): New function. (grub_console_term): Assign grub_console_getwh to getwh. * normal/cmdline.c (grub_tab_complete): Removed. Now the same function is defined in normal/completion.c as grub_normal_do_completion. (grub_cmdline_get): Use grub_normal_do_completion instead of grub_tab_complete. * kern/partition.c (grub_partition_map_iterate): Return 1 if HOOK returns non-zero, otherwise return 0. (grub_partition_iterate): First, probe the partition map. Then, call ITERATE only for this partition map. * kern/misc.c (grub_strncmp): Rewritten. * kern/disk.c (grub_disk_dev_iterate): Return 1 if P->ITERATE returns non-zero. Otherwise return 0. * include/grub/partition.h (grub_partition_map_iterate): Return int instead of void. * include/grub/normal.h (grub_normal_do_completion): New prototype. * include/grub/misc.h (grub_strncmp): Change the type of N to grub_size_t. * include/grub/disk.h (grub_disk_dev_iterate): Return int instead of void. * normal/menu.c (draw_border): Cast GRUB_TERM_BORDER_WIDTH to unsigned explictly before comparing it with I. * kern/main.c (grub_env_write_root): Add the attribute unused into VAR. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Added normal/completion.c. (normal_mod_SOURCES): Likewise. * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. (normal_mod_SOURCES): Likewise. * normal/command.c (grub_iterate_commands): If ITERATE returns non-zero, return one immediately.
This commit is contained in:
parent
e85e144bfc
commit
8de3495c7b
18 changed files with 192 additions and 348 deletions
|
@ -194,14 +194,16 @@ grub_disk_dev_unregister (grub_disk_dev_t dev)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
grub_disk_dev_iterate (int (*hook) (const char *name))
|
||||
{
|
||||
grub_disk_dev_t p;
|
||||
|
||||
for (p = grub_disk_dev_list; p; p = p->next)
|
||||
if ((p->iterate) (hook))
|
||||
break;
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_disk_t
|
||||
|
|
|
@ -60,7 +60,8 @@ grub_load_modules (void)
|
|||
/* Write hook for the environment variables of root. Remove surrounding
|
||||
parentheses, if any. */
|
||||
static char *
|
||||
grub_env_write_root (struct grub_env_var *var, const char *val)
|
||||
grub_env_write_root (struct grub_env_var *var __attribute__ ((unused)),
|
||||
const char *val)
|
||||
{
|
||||
/* XXX Is it better to check the existence of the device? */
|
||||
grub_size_t len = grub_strlen (val);
|
||||
|
|
10
kern/misc.c
10
kern/misc.c
|
@ -191,18 +191,18 @@ grub_strcmp (const char *s1, const char *s2)
|
|||
}
|
||||
|
||||
int
|
||||
grub_strncmp (const char *s1, const char *s2, int c)
|
||||
grub_strncmp (const char *s1, const char *s2, grub_size_t n)
|
||||
{
|
||||
int p = 1;
|
||||
|
||||
while (*s1 && *s2 && p < c)
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
while (*s1 && *s2 && --n)
|
||||
{
|
||||
if (*s1 != *s2)
|
||||
return (int) *s1 - (int) *s2;
|
||||
|
||||
s1++;
|
||||
s2++;
|
||||
p++;
|
||||
}
|
||||
|
||||
return (int) *s1 - (int) *s2;
|
||||
|
|
|
@ -42,14 +42,16 @@ grub_partition_map_unregister (grub_partition_map_t partmap)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
grub_partition_map_iterate (int (*hook) (const grub_partition_map_t partmap))
|
||||
{
|
||||
grub_partition_map_t p;
|
||||
|
||||
for (p = grub_partition_map_list; p; p = p->next)
|
||||
if (hook (p))
|
||||
break;
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_partition_t
|
||||
|
@ -85,23 +87,35 @@ grub_err_t
|
|||
grub_partition_iterate (struct grub_disk *disk,
|
||||
int (*hook) (const grub_partition_t partition))
|
||||
{
|
||||
auto int part_map_iterate (const grub_partition_map_t partmap);
|
||||
grub_partition_map_t partmap = 0;
|
||||
|
||||
int part_map_iterate (const grub_partition_map_t partmap)
|
||||
auto int part_map_iterate (const grub_partition_map_t p);
|
||||
auto int part_map_iterate_hook (const grub_partition_t partition);
|
||||
|
||||
int part_map_iterate_hook (const grub_partition_t partition __attribute__ ((unused)))
|
||||
{
|
||||
grub_err_t err = partmap->iterate (disk, hook);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int part_map_iterate (const grub_partition_map_t p)
|
||||
{
|
||||
grub_err_t err = p->iterate (disk, part_map_iterate_hook);
|
||||
|
||||
if (err == GRUB_ERR_BAD_PART_TABLE)
|
||||
if (err != GRUB_ERR_NONE)
|
||||
{
|
||||
/* Continue to next partition map type. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
partmap = p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_partition_map_iterate (part_map_iterate);
|
||||
if (partmap)
|
||||
partmap->iterate (disk, hook);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue