From 6fdda85ae6a255458808d4e4042eb51d55eb1380 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 30 Apr 2010 13:50:41 +0530 Subject: [PATCH 1/2] fix comment and brace handling --- conf/tests.rmk | 4 ++++ script/yylex.l | 4 ++-- tests/grub_script_comments.in | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/grub_script_comments.in diff --git a/conf/tests.rmk b/conf/tests.rmk index d48bc3dd9..9af2f8f86 100644 --- a/conf/tests.rmk +++ b/conf/tests.rmk @@ -68,6 +68,9 @@ grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in check_SCRIPTS += grub_script_dollar grub_script_dollar_SOURCES = tests/grub_script_dollar.in +check_SCRIPTS += grub_script_comments +grub_script_comments_SOURCES = tests/grub_script_comments.in + # List of tests to execute on "make check" # SCRIPTED_TESTS = example_scripted_test # SCRIPTED_TESTS += example_grub_script_test @@ -83,6 +86,7 @@ SCRIPTED_TESTS += grub_script_if SCRIPTED_TESTS += grub_script_blanklines SCRIPTED_TESTS += grub_script_final_semicolon SCRIPTED_TESTS += grub_script_dollar +SCRIPTED_TESTS += grub_script_comments # dependencies between tests and testing-tools $(SCRIPTED_TESTS): grub-shell grub-shell-tester diff --git a/script/yylex.l b/script/yylex.l index 29aa5c2e3..7d4ea9e4e 100644 --- a/script/yylex.l +++ b/script/yylex.l @@ -112,9 +112,9 @@ typedef size_t yy_size_t; %option extra-type="struct grub_parser_param*" BLANK [ \t] -COMMENT ^[ \t]*#.*$ +COMMENT #.*$ -CHAR [^|&$;<> \t\n\'\"\\] +CHAR [^{}|&$;<> \t\n\'\"\\] DIGITS [[:digit:]]+ NAME [[:alpha:]_][[:alnum:][:digit:]_]* diff --git a/tests/grub_script_comments.in b/tests/grub_script_comments.in new file mode 100644 index 000000000..7b3410717 --- /dev/null +++ b/tests/grub_script_comments.in @@ -0,0 +1,19 @@ +#! @builddir@/grub-shell-tester +# +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +echo a###b +echo a# #b From c548018b7c9e7a61310bcf551238b63df847a76b Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Sat, 1 May 2010 15:39:59 +0530 Subject: [PATCH 2/2] added few more test cases --- tests/grub_script_comments.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/grub_script_comments.in b/tests/grub_script_comments.in index 7b3410717..f212cc1e1 100644 --- a/tests/grub_script_comments.in +++ b/tests/grub_script_comments.in @@ -17,3 +17,12 @@ echo a###b echo a# #b + +echo # +echo \# + +echo '#' +echo "#" + +echo '\#' +echo "\#"