aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-02 08:17:44 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-02 08:17:44 +0100
commite03c947815655875d93107066863995aa47de675 (patch)
tree3904495960f7c23bb771b60863cfe7f508b6accb
parentc6191d90ca1a19440d79ddc5fa6f4a035f6bb231 (diff)
downloadpaludis-e03c947815655875d93107066863995aa47de675.tar.gz
paludis-e03c947815655875d93107066863995aa47de675.tar.xz
Add kvcfo_allow_multiple_assigns_per_line.
The KeyValueConfigFile option kvcfo_allow_multiple_assigns_per_line allows multiple assigns per line, like A="b" C="d". If combined with kvcfo_disallow_space_inside_unquoted_values, A=b C=d is also accepted. In preparation for: ticket:608.
-rw-r--r--paludis/util/config_file.cc9
-rw-r--r--paludis/util/config_file.se1
-rw-r--r--paludis/util/config_file_TEST.cc25
3 files changed, 33 insertions, 2 deletions
diff --git a/paludis/util/config_file.cc b/paludis/util/config_file.cc
index c3e77eb..80c396e 100644
--- a/paludis/util/config_file.cc
+++ b/paludis/util/config_file.cc
@@ -442,8 +442,13 @@ namespace
else if (parser.consume(+simple_parser::any_of(" \t") >> w))
{
if (k.options()[kvcfo_disallow_space_inside_unquoted_values])
- throw ConfigFileError(sr.filename(), "Not allowed space inside unquoted values at line "
- + stringify(parser.current_line_number()));
+ {
+ if (k.options()[kvcfo_allow_multiple_assigns_per_line])
+ break;
+ else
+ throw ConfigFileError(sr.filename(), "Not allowed space inside unquoted values at line "
+ + stringify(parser.current_line_number()));
+ }
else if (k.options()[kvcfo_preserve_whitespace])
result.append(w);
else
diff --git a/paludis/util/config_file.se b/paludis/util/config_file.se
index e2312ea..3960c00 100644
--- a/paludis/util/config_file.se
+++ b/paludis/util/config_file.se
@@ -38,6 +38,7 @@ make_enum_KeyValueConfigFileOption()
key kvcfo_preserve_whitespace "Do not strip trailing whitespace from values"
key kvcfo_ignore_export "Accept and ignore the word export at the beginning of a line"
key kvcfo_allow_inline_comments "Allow inline comments. \since 0.28"
+ key kvcfo_allow_multiple_assigns_per_line "Allow A='b' B='c' (and unquoted if kvcfo_disallow_space_inside_unquoted_values). \since 0.28"
doxygen_comment << "END"
/**
diff --git a/paludis/util/config_file_TEST.cc b/paludis/util/config_file_TEST.cc
index acbaac2..f5a46c1 100644
--- a/paludis/util/config_file_TEST.cc
+++ b/paludis/util/config_file_TEST.cc
@@ -454,5 +454,30 @@ namespace test_cases
TEST_CHECK_EQUAL(ff.get("five"), "five");
}
} test_key_value_config_file_inline_comments;
+
+ struct KeyValueConfigFileMultipleAssignsTest : TestCase
+ {
+ KeyValueConfigFileMultipleAssignsTest() : TestCase("key value config multiple assigns") { }
+
+ void run()
+ {
+ std::stringstream d_s;
+ d_s << "one=\"one\" two=two" << std::endl;
+ d_s << "three = \\" << std::endl;
+ d_s << "three four = \\" << std::endl;
+ d_s << "\"four\" # one=three" << std::endl;
+ d_s << "five=five # six=six" << std::endl;
+ KeyValueConfigFile ff(d_s, KeyValueConfigFileOptions() + kvcfo_allow_inline_comments + kvcfo_allow_multiple_assigns_per_line
+ + kvcfo_disallow_space_inside_unquoted_values,
+ &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation);
+
+ TEST_CHECK_EQUAL(std::distance(ff.begin(), ff.end()), 5);
+ TEST_CHECK_EQUAL(ff.get("one"), "one");
+ TEST_CHECK_EQUAL(ff.get("two"), "two");
+ TEST_CHECK_EQUAL(ff.get("three"), "three");
+ TEST_CHECK_EQUAL(ff.get("four"), "four");
+ TEST_CHECK_EQUAL(ff.get("five"), "five");
+ }
+ } test_key_value_config_file_multiple_assigns;
}