aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-26 00:10:15 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-26 00:10:15 +0000
commit2d870534d110c4c633bda49379b86de63cf1095b (patch)
tree31fea3ac2e8a2188f4ce46766026bbb44b9b0e34
parent4c3fa649a894fb8638a7c9c7b492637ed09525c4 (diff)
downloadpaludis-2d870534d110c4c633bda49379b86de63cf1095b.tar.gz
paludis-2d870534d110c4c633bda49379b86de63cf1095b.tar.xz
Fix line continuations. Fixes: ticket:164
-rw-r--r--paludis/config_file.cc4
-rw-r--r--paludis/config_file_TEST.cc5
2 files changed, 6 insertions, 3 deletions
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 35f1944..eb8e87f 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -168,6 +168,7 @@ LineConfigFile::LineConfigFile(const Source & s) :
while ('\\' == line.at(line.length() - 1))
{
+ line.erase(line.length() - 1);
std::string next_line;
if (! std::getline(s.stream(), next_line))
throw ConfigFileError(s.filename(), "Line continuation at end of input");
@@ -175,8 +176,7 @@ LineConfigFile::LineConfigFile(const Source & s) :
if (next_line.empty())
throw ConfigFileError(s.filename(), "Line continuation followed by empty line");
- next_line = strip_leading(strip_trailing(line, " \t\r\n"), " \t\r\n");
- if ((! line.empty()) && ('#' == line.at(0)))
+ if ((! next_line.empty()) && ('#' == next_line.at(0)))
throw ConfigFileError(s.filename(), "Line continuation followed by comment");
line.append(next_line);
diff --git a/paludis/config_file_TEST.cc b/paludis/config_file_TEST.cc
index 46f4bc7..750fd8e 100644
--- a/paludis/config_file_TEST.cc
+++ b/paludis/config_file_TEST.cc
@@ -60,14 +60,17 @@ namespace test_cases
s << "#" << std::endl;
s << " # \t " << std::endl;
s << "four four" << std::endl;
+ s << "five \\" << std::endl;
+ s << "six" << std::endl;
LineConfigFile f(s);
- TEST_CHECK_EQUAL(std::distance(f.begin(), f.end()), 4);
+ TEST_CHECK_EQUAL(std::distance(f.begin(), f.end()), 5);
std::vector<std::string> lines;
std::copy(f.begin(), f.end(), std::back_inserter(lines));
TEST_CHECK_EQUAL(lines.at(0), "one");
TEST_CHECK_EQUAL(lines.at(1), "two");
TEST_CHECK_EQUAL(lines.at(2), "three");
TEST_CHECK_EQUAL(lines.at(3), "four four");
+ TEST_CHECK_EQUAL(lines.at(4), "five six");
}
} test_config_file;