From 6719c4c8286eb51982035454033ff39b5d27d455 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 18 Jun 2014 15:11:32 +0200 Subject: [PATCH] starter: Explicitly allow @# at the beginning of strings Since we treat everything after # as comment identities of type ID_KEY_ID couldn't be parsed otherwise, unless quoted. --- src/starter/parser/lexer.l | 2 +- src/starter/tests/suites/test_parser.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/starter/parser/lexer.l b/src/starter/parser/lexer.l index 22ad6177e..a88cbe809 100644 --- a/src/starter/parser/lexer.l +++ b/src/starter/parser/lexer.l @@ -79,7 +79,7 @@ static void include_files(parser_helper_t *ctx); yy_push_state(str, yyscanner); } -[^\"#= \t\n]+ { +(@#)?[^\"#= \t\n]+ { yylval->s = strdup(yytext); return STRING; } diff --git a/src/starter/tests/suites/test_parser.c b/src/starter/tests/suites/test_parser.c index 84b5eedc8..684bc2a27 100644 --- a/src/starter/tests/suites/test_parser.c +++ b/src/starter/tests/suites/test_parser.c @@ -224,6 +224,9 @@ static struct { { "conn foo # asdf\n\tkey=val", TRUE, "val" }, { "conn foo # asdf\n#\tkey=val", TRUE, NULL }, { "conn foo # asdf\n\t#key=val", TRUE, NULL }, + { "conn foo # asdf\n\tkey=@#keyid", TRUE, "@#keyid" }, + { "conn foo # asdf\n\tkey=\"@#keyid\"", TRUE, "@#keyid" }, + { "conn foo # asdf\n\tkey=asdf@#keyid", TRUE, "asdf@" }, { "conn foo # asdf\n\tkey=#val", TRUE, NULL }, { "conn foo # asdf\n\tkey=val#asdf", TRUE, "val" }, { "conn foo # asdf\n\tkey=\"val#asdf\"", TRUE, "val#asdf" },