Skip to content
Permalink
Browse files

. 修正bug。(issues #168)

  • Loading branch information...
yaya
yaya committed Mar 2, 2018
1 parent 23976bd commit 1c94e3bb4c5b953724dd7495442c90be84ad68f2
Showing with 26 additions and 7 deletions.
  1. +21 −4 stage2/builtins.c
  2. +5 −3 stage2/stage2.c
@@ -4763,7 +4763,8 @@ fallback_func (char *arg, int flags)
fallback_entries[i] = -1;

fallback_entryno = (i == 0) ? -1 : 0;
if (go) return (errnum = MAX_ERR_NUM);
// if (go) return (errnum = MAX_ERR_NUM);
if (go) return (errnum = 1000);
// return 1;
return 0;
}
@@ -17140,21 +17141,35 @@ static int bat_run_script(char *filename,char *arg,int flags)
static int goto_func(char *arg, int flags)
{
errorcheck_func ("on",0);
#if 0
errnum = ERR_BAT_GOTO;
// if (flags & BUILTIN_BAT_SCRIPT)//batch script return arg addr.
if (*arg == ':')
if (flags & BUILTIN_BAT_SCRIPT)//batch script return arg addr.
{
return bat_find_label(arg);
}
else
return fallback_func(arg,flags);//in menu script call fallback_func to jump next menu.
#endif
unsigned long long val;
char *p = arg;
if (*arg == '+' || *arg == '-' || safe_parse_maxint (&p, &val))
{
errnum = ERR_BAT_GOTO;
return fallback_func(arg,flags);
}
errnum = ERR_BAT_GOTO;
return bat_find_label(arg);
}

static struct builtin builtin_goto =
{
"goto",
goto_func,
BUILTIN_SCRIPT | BUILTIN_BAT_SCRIPT,
BUILTIN_SCRIPT | BUILTIN_BAT_SCRIPT | BUILTIN_HELP_LIST | BUILTIN_MENU | BUILTIN_CMDLINE,
"goto [+|-|:]DESTINATION",
"e.g. goto [+|-]NUM. Use in menus. Jump to the specified title.\n"
"e.g. goto [:]LABEL. Use in batch files or menus. Jump to the specified ':LABEL'.\n"
"When the LABEL there is no prefix ':', the LABEL can't be a number."
};

static int call_func(char *arg,int flags)
@@ -17208,10 +17223,12 @@ static struct builtin builtin_call =

static int exit_func(char *arg, int flags)
{
#if 0
if (flags == BUILTIN_SCRIPT)
{
errnum = MAX_ERR_NUM;
} else
#endif
{
long long t = 0;
read_val(&arg, &t);
@@ -592,7 +592,7 @@ run_script (char *script, char *heap)
{
// char *old_entry = 0;
char *cur_entry = script;
struct builtin *builtin = 0;
// struct builtin *builtin = 0;
char tmp[5] = {'!','B','A','T',0x0a};
char cmd_add[16];
char *menu_bat;
@@ -625,10 +625,10 @@ run_script (char *script, char *heap)
grub_memmove (p, &tmp, 5);
grub_memmove (p + 5, script, cur_entry - script);
grub_sprintf (cmd_add, "(md)%d+%d", (int)p >> 9, ((cur_entry - script + 10 + 511) & ~511) >> 9);
command_func (cmd_add, 1);
command_func (cmd_add, BUILTIN_SCRIPT);
grub_free(menu_bat);

if (errnum == MAX_ERR_NUM)
if (errnum >= 1000)
{
errnum=ERR_NONE;
return 0;
@@ -715,8 +715,10 @@ run_script (char *script, char *heap)

if (fallback_entryno < 0)
{
#if 0
if (! (builtin->flags & BUILTIN_NO_ECHO))
grub_printf ("%s\n", heap);
#endif
print_error ();

grub_printf ("\nPress any key to continue...");

0 comments on commit 1c94e3b

Please sign in to comment.
You can’t perform that action at this time.