aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-15 13:01:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-15 13:01:20 +0100
commit02e46c7eca0784aadbc5a14351b1d603a9e16c5f (patch)
treeff32498dac60fa1ee9bcc2afe819843103f94a5b
parent68d8d9395d2c53238a087413619039342cbf15c9 (diff)
downloadpaludis-02e46c7eca0784aadbc5a14351b1d603a9e16c5f.tar.gz
paludis-02e46c7eca0784aadbc5a14351b1d603a9e16c5f.tar.xz
kvcfo_ignore_single_quotes_inside_strings
-rw-r--r--paludis/util/config_file.cc5
-rw-r--r--paludis/util/config_file.se1
-rw-r--r--paludis/util/config_file_TEST.cc17
3 files changed, 22 insertions, 1 deletions
diff --git a/paludis/util/config_file.cc b/paludis/util/config_file.cc
index 0123118..4dc676c 100644
--- a/paludis/util/config_file.cc
+++ b/paludis/util/config_file.cc
@@ -389,7 +389,10 @@ namespace
parse_after_continuation(sr, parser, ! k.options()[kvcfo_disallow_comments]);
continue;
}
- else if (parser.consume(simple_parser::exact("'")))
+ else if ((! k.options()[kvcfo_ignore_single_quotes_inside_strings]) && parser.consume(simple_parser::exact("'")))
+ break;
+ else if ((k.options()[kvcfo_ignore_single_quotes_inside_strings]) && parser.lookahead(simple_parser::exact("'\n"))
+ && parser.consume(simple_parser::exact("'")))
break;
else if (parser.consume((simple_parser::any_except("") & *simple_parser::any_except("\\'")) >> s))
result.append(s);
diff --git a/paludis/util/config_file.se b/paludis/util/config_file.se
index fb5a974..26d9d3f 100644
--- a/paludis/util/config_file.se
+++ b/paludis/util/config_file.se
@@ -42,6 +42,7 @@ make_enum_KeyValueConfigFileOption()
key kvcfo_allow_sections "Allow [sections] \since 0.44"
key kvcfo_allow_fancy_assigns "Allow ?= assignments \since 0.54.1"
key kvcfo_allow_env "Allow \${ENV{blah}} \since 0.54.1"
+ key kvcfo_ignore_single_quotes_inside_strings "Allow 'broken 'quoted' strings' (for libtool) \since 0.62.1"
doxygen_comment << "END"
/**
diff --git a/paludis/util/config_file_TEST.cc b/paludis/util/config_file_TEST.cc
index 6b20d32..2034311 100644
--- a/paludis/util/config_file_TEST.cc
+++ b/paludis/util/config_file_TEST.cc
@@ -455,3 +455,20 @@ TEST(KeyValueConfigFile, EnvVars)
EXPECT_EQ("BRRRRGH", ff.get("b"));
}
+TEST(KeyValueConfigFile, AnnoyingLibtoolQuotes)
+{
+ std::stringstream s1;
+ s1 << "x='foo 'bar' baz'\ny=z" << std::endl;
+ EXPECT_THROW(KeyValueConfigFile ff(s1, { },
+ &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation), ConfigurationError);
+
+ std::stringstream s2;
+ s2 << "x='foo 'bar' baz'\ny=z" << std::endl;
+ KeyValueConfigFile ff(s2, { kvcfo_ignore_single_quotes_inside_strings },
+ &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation);
+
+ ASSERT_EQ(2, std::distance(ff.begin(), ff.end()));
+ EXPECT_EQ("foo 'bar' baz", ff.get("x"));
+ EXPECT_EQ("z", ff.get("y"));
+}
+