aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-10 18:45:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-10 18:45:00 +0000
commitb711a91e3004f591b1bfe124c6be071f136bae38 (patch)
tree437f2c978e92647fd540cd233e1749a4868d9d15
parent697bb9ea1266ee50e3aebb7cfd008f4e35683966 (diff)
downloadpaludis-b711a91e3004f591b1bfe124c6be071f136bae38.tar.gz
paludis-b711a91e3004f591b1bfe124c6be071f136bae38.tar.xz
Reallow continuations in line-based config files. Fixes: ticket:135
-rw-r--r--paludis/config_file.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 87ba131..35f1944 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -163,6 +163,25 @@ LineConfigFile::LineConfigFile(const Source & s) :
std::string line;
while (std::getline(s.stream(), line))
{
+ if (line.empty())
+ continue;
+
+ while ('\\' == line.at(line.length() - 1))
+ {
+ std::string next_line;
+ if (! std::getline(s.stream(), next_line))
+ throw ConfigFileError(s.filename(), "Line continuation at end of input");
+
+ 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)))
+ throw ConfigFileError(s.filename(), "Line continuation followed by comment");
+
+ line.append(next_line);
+ }
+
line = strip_leading(strip_trailing(line, " \t\r\n"), " \t\r\n");
if (line.empty())
continue;