diff --git a/ChangeLog b/ChangeLog index 21ed6ff7f..da1e88c7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-05-08 Vladimir Serbinenko + + * grub-core/script/yylex.l: Ugly fix for "\\\n ". + * tests/grub_script_echo1.in: Add tests. + 2012-05-08 Vladimir Serbinenko * util/grub-install.in: Ignore empty devicetree directory. diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l index 3d6899a93..a8e66cfd4 100644 --- a/grub-core/script/yylex.l +++ b/grub-core/script/yylex.l @@ -139,7 +139,8 @@ SPECIAL \?|\#|\*|\@ VARIABLE ${NAME}|$\{{NAME}\}|${DIGITS}|$\{{DIGITS}\}|${SPECIAL}|$\{{SPECIAL}\} WORD ({CHAR}|{DQSTR}|{SQSTR}|{ESC}|{VARIABLE}|{I18NSTR})+ -MULTILINE {WORD}?((\"{DQCHR}*)|(\$\"{DQCHR}*)|(\'{SQCHR}*)|(\\\n)) +MULTILINE {WORD}?((\"{DQCHR}*)|(\$\"{DQCHR}*)|(\'{SQCHR}*)) +POS_MULTILINE {WORD}?\\\n %x SPLIT %x DQUOTE @@ -190,6 +191,26 @@ MULTILINE {WORD}?((\"{DQCHR}*)|(\$\"{DQCHR}*)|(\'{SQCHR}*)|(\\\n)) return GRUB_PARSER_TOKEN_BAD; } +{POS_MULTILINE} { + if (yyg->yy_c_buf_p + 1 == &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + { + if (grub_lexer_unput (yytext, yyscanner)) + return GRUB_PARSER_TOKEN_BAD; + } + else + { + RECORD; + yypush_buffer_state (YY_CURRENT_BUFFER, yyscanner); + if (grub_lexer_resplit (yytext, yyscanner)) + { + yypop_buffer_state (yyscanner); + return GRUB_PARSER_TOKEN_WORD; + } + yyextra->lexerstate->resplit = 1; + } + } + + {NAME} { RECORD; return GRUB_PARSER_TOKEN_NAME; } {WORD} { RECORD; diff --git a/tests/grub_script_echo1.in b/tests/grub_script_echo1.in index 82a1198c9..620911795 100644 --- a/tests/grub_script_echo1.in +++ b/tests/grub_script_echo1.in @@ -144,5 +144,33 @@ echo "one\ echo "one\ two" +echo one \ + two + +echo one x\ + two + +echo one x\ +"x" two +echo one x\ +'x' two +echo one x\ +\\ two + +echo one x\ +\ +x + +echo one x\ + + + +echo one x\ +; + +echo one x\ +$var + + if test x$grubshell = xyes; then insmod regexp; fi echo /boot/grub/i386-pc/normal.mod