Skip to content
Permalink
Browse files

. 在菜单项首行增加 !BAT 可按批处理方式书写与执行,使用批处理的功能。比如:goto :label

  书写方式区别在于转义符 % 的使用。
  在原菜单项:
      set a2=%@root:~0,-2%0)
      set srs=%SRS0PE%%srs%
  按批处理方式书写菜单项:
      !BAT
      set a2=%@root:~0,-2%%0)
      set srs=%SRS0PE%%%srs%
  撤销2018-04-08与2018-02-20修改说明。
  • Loading branch information...
yaya
yaya committed Apr 23, 2018
1 parent 08c011f commit 90d6606a4c1ee9aa57e1f6f9366bf4096f531827
Showing with 22 additions and 30 deletions.
  1. +11 −7 ChangeLog_chenall.txt
  2. +1 −15 stage2/builtins.c
  3. +10 −8 stage2/stage2.c
@@ -1,7 +1,15 @@
更新说明:
2018-03-26(yaya)
在批处理脚本中,变量可以使用单'%'。
如:partnew %@root:~0,-2%0) 0x00 (hd0,3)+1
2018-04-23(yaya)
在菜单项首行增加 !BAT 可按批处理方式书写与执行,使用批处理的功能。比如:goto :label
书写方式区别在于转义符 % 的使用。
在原菜单项:
set a2=%@root:~0,-2%0)
set srs=%SRS0PE%%srs%
按批处理方式书写菜单项:
!BAT
set a2=%@root:~0,-2%%0)
set srs=%SRS0PE%%%srs%
撤销2018-04-08与2018-02-20修改说明。

2018-03-26(yaya)
函数 map 增加 --in-situ=FLAGS_AND_ID 参数。
@@ -17,10 +25,6 @@
没有X, 表示水平居中.
-Y表示从菜单底部计数. -0就是最后一行.

2018-02-20(yaya)
增强菜单项目脚本处理。
比如可使用 goto :label

2017-12-05(yaya)
增强颜色赋值功能。修正color及echo帮助信息。
1. 按目标分配颜色,顺序不能乱(未选菜单 被选菜单 帮助 标题)。颜色可用占位符n替换。
@@ -16954,27 +16954,14 @@ static int bat_run_script(char *filename,char *arg,int flags)
continue;
}

int per_cent = 0;
int asd = 0;
while(*p_bat)
{
while (*p_bat == '%' && *(p_bat+1) == '%' && *(p_bat+2) == '%')
p_bat++;
if (*p_bat != '%' || (file_ext = p_bat++,*p_bat == '%' && per_cent==0))
if (*p_bat != '%' || (file_ext = p_bat++,*p_bat == '%'))
{//if *p_bat != '%' or p_bat[1] == '%'(*p_bat == p_bat[1] == '%');
*p_cmd++ = *p_bat++;
continue;
}//file_ext now use for backup p_bat see the loop end.

if (*p_bat == '^')
asd = 1;
if (per_cent && asd == 0)
{
per_cent = 0;
p_bat = file_ext;
*p_cmd++ = *p_bat++;
continue;
}
i = 0;

if (*p_bat == '~')
@@ -17042,7 +17029,6 @@ static int bat_run_script(char *filename,char *arg,int flags)
}
else
{
per_cent = 1;
p_bat = file_ext;
*p_cmd++ = *p_bat;
}
@@ -590,10 +590,9 @@ extern int checkrange_func (char *arg1, int flags);
static int
run_script (char *script, char *heap)
{
// char *old_entry = 0;
char *old_entry = 0;
char *cur_entry = script;
// struct builtin *builtin = 0;
char tmp[5] = {'!','B','A','T',0x0a};
struct builtin *builtin = 0;
char cmd_add[16];
char *menu_bat;
char *p;
@@ -611,6 +610,8 @@ run_script (char *script, char *heap)
errnum = 0;
errorcheck = 1; /* errorcheck on */

if (grub_memcmp (cur_entry, "!BAT", 4) == 0)
{
while (1)
{
while (*cur_entry++);
@@ -622,8 +623,7 @@ run_script (char *script, char *heap)
if (menu_bat == NULL)
return 0;
p = (char *)(((int)menu_bat + 511) & ~511);
grub_memmove (p, &tmp, 5);
grub_memmove (p + 5, script, cur_entry - script);
grub_memmove (p, 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, BUILTIN_SCRIPT);
grub_free(menu_bat);
@@ -642,7 +642,9 @@ run_script (char *script, char *heap)
/* Otherwise, the command boot is run implicitly. */
grub_sprintf (cmd_add, "boot", 5);
run_line (cmd_add , BUILTIN_SCRIPT);
#if 0
goto ppp;
}

while (1)
{
if (errnum == MAX_ERR_NUM)
@@ -707,7 +709,7 @@ run_script (char *script, char *heap)
if (! *old_entry) /* HEAP holds the implicit BOOT command */
break;
} /* while (1) */
#endif

ppp:
kernel_type = KERNEL_TYPE_NONE;

@@ -2458,7 +2460,7 @@ cmain (void)
char *cmdline = (char *) CMDLINE_BUF;

/* Get the pointer to the builtin structure. */
if (*cmdline == ':')
if (*cmdline == ':' || *cmdline == '!')
goto sss;
builtin = find_command (cmdline);
errnum = 0;

0 comments on commit 90d6606

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