aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-13 23:11:37 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-13 23:11:37 +0000
commite495833fa8e452c610dc6b757ddaf2277f98df28 (patch)
treebff50301645240b327d68edfb6530802bfa0434d
parent118a29da5f40def75dead130c5a9e62b55b25ecb (diff)
downloadpaludis-e495833fa8e452c610dc6b757ddaf2277f98df28.tar.gz
paludis-e495833fa8e452c610dc6b757ddaf2277f98df28.tar.xz
Make LineConfigFile's behaviour configurable
-rw-r--r--paludis/config_file.cc40
-rw-r--r--paludis/config_file.hh46
-rw-r--r--paludis/config_file.se23
-rw-r--r--paludis/config_file_TEST.cc32
-rw-r--r--paludis/environments/paludis/paludis_config.cc12
-rw-r--r--paludis/environments/paludis/paludis_environment.cc2
-rw-r--r--paludis/environments/portage/portage_environment.cc8
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/qa/categories_check.cc4
-rw-r--r--paludis/qa/dep_packages_check.cc4
-rw-r--r--paludis/qa/deprecated_functions_check.cc4
-rw-r--r--paludis/qa/inherits_check.cc2
-rw-r--r--paludis/qa/iuse_check.cc2
-rw-r--r--paludis/qa/profile_paths_exist_check.cc4
-rw-r--r--paludis/qa/repo_name_check.cc4
-rw-r--r--paludis/repositories/cran/cran_description.cc2
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc4
-rw-r--r--paludis/repositories/cran/cran_repository.cc2
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc16
-rw-r--r--paludis/repositories/gentoo/portage_repository_news.cc11
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.cc6
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile_file.cc2
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.cc2
-rw-r--r--paludis/repositories/gentoo/use_desc.cc2
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc4
-rw-r--r--paludis/repository.cc2
-rw-r--r--src/clients/adjutrix/display_profiles_use.cc4
-rw-r--r--src/clients/contrarius/target_config.cc2
28 files changed, 175 insertions, 73 deletions
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 0e88a66..b1f6520 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -41,6 +41,8 @@
using namespace paludis;
+#include <paludis/config_file-se.cc>
+
ConfigFileError::ConfigFileError(const std::string & f, const std::string & m) throw () :
ConfigurationError("Configuration file error: " + (f.empty() ? m : f + ": " + m))
{
@@ -154,6 +156,19 @@ LineConfigFile::LineConfigFile(const Source & s) :
ConfigFile(s),
PrivateImplementationPattern<LineConfigFile>(new Implementation<LineConfigFile>)
{
+ _parse(s, LineConfigFileOptions());
+}
+
+LineConfigFile::LineConfigFile(const Source & s, const LineConfigFileOptions & o) :
+ ConfigFile(s),
+ PrivateImplementationPattern<LineConfigFile>(new Implementation<LineConfigFile>)
+{
+ _parse(s, o);
+}
+
+void
+LineConfigFile::_parse(const Source & s, const LineConfigFileOptions & opts)
+{
Context context("When parsing line configuration file" + (s.filename().empty() ? ":" :
"'" + s.filename() + "':"));
@@ -164,9 +179,13 @@ LineConfigFile::LineConfigFile(const Source & s) :
while (std::getline(s.stream(), line))
{
if (line.empty())
+ {
+ if (opts[lcfo_no_skip_blank_lines])
+ _imp->lines.push_back(line);
continue;
+ }
- while ('\\' == line.at(line.length() - 1))
+ while ((! opts[lcfo_disallow_continuations]) && '\\' == line.at(line.length() - 1))
{
line.erase(line.length() - 1);
std::string next_line;
@@ -176,18 +195,23 @@ LineConfigFile::LineConfigFile(const Source & s) :
if (next_line.empty())
throw ConfigFileError(s.filename(), "Line continuation followed by empty line");
- if ((! next_line.empty()) && ('#' == next_line.at(0)))
- throw ConfigFileError(s.filename(), "Line continuation followed by comment");
+ if (! opts[lcfo_disallow_comments])
+ if ((! next_line.empty()) && ('#' == next_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;
+ if (! opts[lcfo_preserve_whitespace])
+ line = strip_leading(strip_trailing(line, " \t\r\n"), " \t\r\n");
- if ('#' == line.at(0))
- continue;
+ if (! opts[lcfo_no_skip_blank_lines])
+ if (line.empty())
+ continue;
+
+ if (! opts[lcfo_disallow_comments])
+ if ('#' == line.at(0))
+ continue;
_imp->lines.push_back(line);
}
diff --git a/paludis/config_file.hh b/paludis/config_file.hh
index 5cfe5f8..ad1fe39 100644
--- a/paludis/config_file.hh
+++ b/paludis/config_file.hh
@@ -24,6 +24,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/options.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -39,6 +40,8 @@
namespace paludis
{
+#include <paludis/config_file-se.hh>
+
class FSEntry;
/**
@@ -123,7 +126,7 @@ namespace paludis
/**
* Our filename (may be empty), for use by ConfigFile.
*/
- std::string filename() const;
+ std::string filename() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
///\name Basic operations
@@ -144,11 +147,23 @@ namespace paludis
};
/**
+ * Options for a LineConfigFile.
+ *
+ * \see LineConfigFileOption
+ * \see LineConfigFile
+ * \ingroup grplineconfigfile
+ */
+ typedef Options<LineConfigFileOption> LineConfigFileOptions;
+
+ /**
* A line-based configuration file.
*
- * Line continuations, where a line ends in a backslash, are supported. Comment lines
- * start with a hash character. Leading and trailing whitespace on a line is automatically
- * stripped.
+ * Various syntax options are available, and are controlled by LineConfigFileOptions:
+ *
+ * - Unless lcfo_disallow_continuations, lines ending in a backslash are continuations
+ * - Unless lcfo_disallow_comments, lines starting with a \# are comments
+ * - Unless lcfo_preserve_whitespace, leading and trailing whitespace is stripped
+ * - Unless lcfo_no_skip_blank_lines, blank lines are skipped.
*
* \ingroup grplineconfigfile
* \nosubgrouping
@@ -157,11 +172,22 @@ namespace paludis
public ConfigFile,
private PrivateImplementationPattern<LineConfigFile>
{
+ private:
+ void _parse(const Source &, const LineConfigFileOptions &);
+
public:
///\name Basic operations
///\{
- LineConfigFile(const Source &);
+ /**
+ * Deprecated constructor.
+ *
+ * \deprecated Use the two argument form.
+ */
+ LineConfigFile(const Source &) PALUDIS_ATTRIBUTE((deprecated));
+
+ LineConfigFile(const Source &, const LineConfigFileOptions &);
+
~LineConfigFile();
///\}
@@ -240,8 +266,8 @@ namespace paludis
///\{
typedef libwrapiter::ForwardIterator<Defaults, const std::pair<const std::string, std::string> > Iterator;
- Iterator begin() const;
- Iterator end() const;
+ Iterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ Iterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
///\}
};
@@ -259,15 +285,15 @@ namespace paludis
///\{
typedef libwrapiter::ForwardIterator<KeyValueConfigFile, const std::pair<const std::string, std::string> > Iterator;
- Iterator begin() const;
- Iterator end() const;
+ Iterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ Iterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
///\}
/**
* Fetch the value for a particular key.
*/
- std::string get(const std::string &) const;
+ std::string get(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
diff --git a/paludis/config_file.se b/paludis/config_file.se
new file mode 100644
index 0000000..04d81a7
--- /dev/null
+++ b/paludis/config_file.se
@@ -0,0 +1,23 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_LineConfigFileOption()
+{
+ prefix lcfo
+
+ key lcfo_disallow_continuations "Do not recognise line continuations"
+ key lcfo_disallow_comments "Do not recognise comments"
+ key lcfo_preserve_whitespace "Preserve exact whitespace"
+ key lcfo_no_skip_blank_lines "Do not skip blank lines"
+
+ doxygen_comment << "END"
+ /**
+ * Options for a LineConfigFile.
+ *
+ * \see LineConfigFile
+ * \see LineConfigFileOptions
+ * \ingroup grpconfigfile
+ */
+END
+}
+
diff --git a/paludis/config_file_TEST.cc b/paludis/config_file_TEST.cc
index 807451e..df56983 100644
--- a/paludis/config_file_TEST.cc
+++ b/paludis/config_file_TEST.cc
@@ -26,6 +26,7 @@
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <vector>
+#include <iomanip>
#include <unistd.h>
using namespace test;
@@ -62,7 +63,8 @@ namespace test_cases
s << "four four" << std::endl;
s << "five \\" << std::endl;
s << "six" << std::endl;
- LineConfigFile f(s);
+
+ LineConfigFile f(s, LineConfigFileOptions());
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));
@@ -71,6 +73,26 @@ namespace test_cases
TEST_CHECK_EQUAL(lines.at(2), "three");
TEST_CHECK_EQUAL(lines.at(3), "four four");
TEST_CHECK_EQUAL(lines.at(4), "five six");
+
+ s.clear();
+ s.seekg(0, std::ios::beg);
+
+ LineConfigFile g(s, LineConfigFileOptions() + lcfo_disallow_comments
+ + lcfo_preserve_whitespace + lcfo_no_skip_blank_lines);
+ TEST_CHECK_EQUAL(std::distance(g.begin(), g.end()), 11);
+ lines.clear();
+ std::copy(g.begin(), g.end(), std::back_inserter(lines));
+ TEST_CHECK_EQUAL(lines.at(0), "one");
+ TEST_CHECK_EQUAL(lines.at(1), " two \t ");
+ TEST_CHECK_EQUAL(lines.at(2), " \t ");
+ TEST_CHECK_EQUAL(lines.at(3), "");
+ TEST_CHECK_EQUAL(lines.at(4), "three");
+ TEST_CHECK_EQUAL(lines.at(5), "# blah");
+ TEST_CHECK_EQUAL(lines.at(6), " # blah");
+ TEST_CHECK_EQUAL(lines.at(7), "#");
+ TEST_CHECK_EQUAL(lines.at(8), " # \t ");
+ TEST_CHECK_EQUAL(lines.at(9), "four four");
+ TEST_CHECK_EQUAL(lines.at(10), "five six");
}
} test_config_file;
@@ -86,21 +108,21 @@ namespace test_cases
{
FSEntry ff("config_file_TEST_dir/config_file");
TEST_CHECK(ff.is_regular_file());
- LineConfigFile f(ff);
+ LineConfigFile f(ff, LineConfigFileOptions());
TEST_CHECK_EQUAL(std::distance(f.begin(), f.end()), 1);
TEST_CHECK_EQUAL(*f.begin(), "I am a fish.");
FSEntry ff2("config_file_TEST_dir/not_a_config_file");
TEST_CHECK(! ff2.exists());
LineConfigFile * f2(0);
- TEST_CHECK_THROWS(f2 = new LineConfigFile(ff2), ConfigFileError);
+ TEST_CHECK_THROWS(f2 = new LineConfigFile(ff2, LineConfigFileOptions()), ConfigFileError);
if (0 != geteuid())
{
FSEntry ff3("config_file_TEST_dir/unreadable_file");
TEST_CHECK(ff3.is_regular_file());
LineConfigFile * f3(0);
- TEST_CHECK_THROWS(f3 = new LineConfigFile(ff3), ConfigFileError);
+ TEST_CHECK_THROWS(f3 = new LineConfigFile(ff3, LineConfigFileOptions()), ConfigFileError);
}
}
} test_config_file_open_file;
@@ -126,7 +148,7 @@ namespace test_cases
s << "#" << std::endl;
s << " # \t " << std::endl;
s << "four four" << std::endl;
- LineConfigFile ff(s);
+ LineConfigFile ff(s, LineConfigFileOptions());
std::vector<std::string> f(ff.begin(), ff.end());
TEST_CHECK_EQUAL(f.size(), 4);
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 8ee9f0b..75d7392 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -463,7 +463,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- LineConfigFile f(*file);
+ LineConfigFile f(*file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
@@ -519,7 +519,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- LineConfigFile f(*file);
+ LineConfigFile f(*file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
@@ -573,7 +573,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- LineConfigFile f(*file);
+ LineConfigFile f(*file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
@@ -613,7 +613,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- LineConfigFile f(*file);
+ LineConfigFile f(*file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
@@ -653,7 +653,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- LineConfigFile f(*file);
+ LineConfigFile f(*file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
@@ -785,7 +785,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- LineConfigFile f(*file);
+ LineConfigFile f(*file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 7709c8f..a92f957 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -643,7 +643,7 @@ PaludisEnvironment::local_package_set(const SetName & s) const
FSEntry ff(FSEntry(_imp->config->config_dir()) / "sets" / (stringify(s) + ".conf"));
if (ff.exists())
{
- LineConfigFile f(ff);
+ LineConfigFile f(ff, LineConfigFileOptions());
std::tr1::shared_ptr<AllDepSpec> result(new AllDepSpec);
std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(s, stringify(s) + ".conf"));
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index c4043e6..ed41c73 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -223,7 +223,7 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
if ((_imp->conf_dir / "portage" / "mirrors").exists())
{
- LineConfigFile mirrors(_imp->conf_dir / "portage" / "mirrors");
+ LineConfigFile mirrors(_imp->conf_dir / "portage" / "mirrors", LineConfigFileOptions());
for (LineConfigFile::Iterator line(mirrors.begin()), line_end(mirrors.end()) ;
line != line_end ; ++line)
{
@@ -257,7 +257,7 @@ PortageEnvironment::_load_atom_file(const FSEntry & f, I_ i, const std::string &
}
else
{
- LineConfigFile file(f);
+ LineConfigFile file(f, LineConfigFileOptions());
for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
line != line_end ; ++line)
{
@@ -301,7 +301,7 @@ PortageEnvironment::_load_lined_file(const FSEntry & f, I_ i)
}
else
{
- LineConfigFile file(f);
+ LineConfigFile file(f, LineConfigFileOptions());
for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
line != line_end ; ++line)
*i++ = std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
@@ -318,7 +318,7 @@ PortageEnvironment::_load_profile(const FSEntry & d)
{
Context context_local("When loading parent profiles:");
- LineConfigFile f(d / "parent");
+ LineConfigFile f(d / "parent", LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments);
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
_load_profile((d / *line).realpath());
diff --git a/paludis/files.m4 b/paludis/files.m4
index 8f1d02b..f8afe24 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -9,7 +9,7 @@ dnl `test', `impl', `testscript'. Note that there isn't much error checking done
dnl on this file at present...
add(`about', `hh', `test')
-add(`config_file', `hh', `cc', `test', `testscript')
+add(`config_file', `hh', `cc', `se', `test', `testscript')
add(`contents', `hh', `cc')
add(`dep_spec', `hh', `cc', `se', `test')
add(`dep_spec_flattener', `hh', `cc')
diff --git a/paludis/qa/categories_check.cc b/paludis/qa/categories_check.cc
index 314f341..ae1219a 100644
--- a/paludis/qa/categories_check.cc
+++ b/paludis/qa/categories_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -42,7 +42,7 @@ CategoriesCheck::operator() (const FSEntry & d) const
result << Message(qal_fatal, "Categories file '" + stringify(cats) + "' is not a regular file");
else
{
- LineConfigFile cf(cats);
+ LineConfigFile cf(cats, LineConfigFileOptions());
std::set<CategoryNamePart> c;
for (LineConfigFile::Iterator line(cf.begin()), line_end(cf.end()) ;
diff --git a/paludis/qa/dep_packages_check.cc b/paludis/qa/dep_packages_check.cc
index 301e147..aea058b 100644
--- a/paludis/qa/dep_packages_check.cc
+++ b/paludis/qa/dep_packages_check.cc
@@ -97,7 +97,7 @@ DepPackagesCheck::operator() (const EbuildCheckData & e) const
try
{
LineConfigFile file(FSEntry(getenv_with_default(
- "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "suspicious_depend.txt");
+ "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "suspicious_depend.txt", LineConfigFileOptions());
std::copy(file.begin(), file.end(), create_inserter<QualifiedPackageName>(std::inserter(
suspicious_depend, suspicious_depend.end())));
}
@@ -120,7 +120,7 @@ DepPackagesCheck::operator() (const EbuildCheckData & e) const
try
{
LineConfigFile file(FSEntry(getenv_with_default(
- "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "suspicious_rdepend.txt");
+ "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "suspicious_rdepend.txt", LineConfigFileOptions());
std::copy(file.begin(), file.end(), create_inserter<QualifiedPackageName>(std::inserter(
suspicious_rdepend, suspicious_rdepend.end())));
}
diff --git a/paludis/qa/deprecated_functions_check.cc b/paludis/qa/deprecated_functions_check.cc
index 703b1e3..7548660 100644
--- a/paludis/qa/deprecated_functions_check.cc
+++ b/paludis/qa/deprecated_functions_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -62,7 +62,7 @@ DeprecatedFunctionsCheck::operator() (const FSEntry & f) const
try
{
LineConfigFile deprecated_functions_file(FSEntry(getenv_with_default(
- "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "deprecated_functions.txt");
+ "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "deprecated_functions.txt", LineConfigFileOptions());
for (LineConfigFile::Iterator l(deprecated_functions_file.begin()),
l_end(deprecated_functions_file.end()) ; l != l_end ; ++l)
deprecated_functions.push_back(std::make_pair(*l, pcrepp::Pcre::Pcre("\\b" + *l + "\\b")));
diff --git a/paludis/qa/inherits_check.cc b/paludis/qa/inherits_check.cc
index 2b54a38..2d78105 100644
--- a/paludis/qa/inherits_check.cc
+++ b/paludis/qa/inherits_check.cc
@@ -62,7 +62,7 @@ InheritsCheck::operator() (const EbuildCheckData & e) const
try
{
LineConfigFile file(FSEntry(getenv_with_default(
- "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "inherits_blacklist.txt");
+ "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "inherits_blacklist.txt", LineConfigFileOptions());
std::copy(file.begin(), file.end(), std::inserter(
inherits_blacklist, inherits_blacklist.end()));
}
diff --git a/paludis/qa/iuse_check.cc b/paludis/qa/iuse_check.cc
index 63d1a42..bd27f44 100644
--- a/paludis/qa/iuse_check.cc
+++ b/paludis/qa/iuse_check.cc
@@ -68,7 +68,7 @@ IuseCheck::operator() (const EbuildCheckData & e) const
try
{
LineConfigFile iuse_blacklist_file(FSEntry(getenv_with_default(
- "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "iuse_blacklist.txt");
+ "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "iuse_blacklist.txt", LineConfigFileOptions());
std::copy(iuse_blacklist_file.begin(), iuse_blacklist_file.end(),
create_inserter<UseFlagName>(std::inserter(iuse_blacklist, iuse_blacklist.end())));
}
diff --git a/paludis/qa/profile_paths_exist_check.cc b/paludis/qa/profile_paths_exist_check.cc
index a952f24..cb2b839 100644
--- a/paludis/qa/profile_paths_exist_check.cc
+++ b/paludis/qa/profile_paths_exist_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -42,7 +42,7 @@ namespace
if ((dir / "parent").exists())
{
- LineConfigFile parent(dir / "parent");
+ LineConfigFile parent(dir / "parent", LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments);
for (LineConfigFile::Iterator line(parent.begin()), line_end(parent.end()) ;
line != line_end ; ++line)
{
diff --git a/paludis/qa/repo_name_check.cc b/paludis/qa/repo_name_check.cc
index 449ccdd..671d940 100644
--- a/paludis/qa/repo_name_check.cc
+++ b/paludis/qa/repo_name_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -42,7 +42,7 @@ RepoNameCheck::operator() (const FSEntry & d) const
result << Message(qal_major, "Repository name file '" + stringify(cats) + "' is not a regular file");
else
{
- LineConfigFile cf(cats);
+ LineConfigFile cf(cats, LineConfigFileOptions());
if (cf.begin() == cf.end())
result << Message(qal_major, "Repository name file '" + stringify(cats) + "' is empty");
else
diff --git a/paludis/repositories/cran/cran_description.cc b/paludis/repositories/cran/cran_description.cc
index a6f1dea..15a0f11 100644
--- a/paludis/repositories/cran/cran_description.cc
+++ b/paludis/repositories/cran/cran_description.cc
@@ -42,7 +42,7 @@ CRANDescription::CRANDescription(const std::string & n, const FSEntry & f, bool
return;
}
- LineConfigFile file(f);
+ LineConfigFile file(f, LineConfigFileOptions());
LineConfigFile::Iterator l(file.begin()), l_end(file.end());
// Fill in default values
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index ec79333..e6ecc49 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -570,7 +570,7 @@ CRANInstalledRepository::do_package_set(const SetName & s) const
if (_imp->world_file.exists())
{
- LineConfigFile world(_imp->world_file);
+ LineConfigFile world(_imp->world_file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
@@ -635,7 +635,7 @@ CRANInstalledRepository::add_string_to_world(const std::string & n) const
if (_imp->world_file.exists())
{
- LineConfigFile world(_imp->world_file);
+ LineConfigFile world(_imp->world_file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index cda4c1e..2a4f4c7 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -293,7 +293,7 @@ CRANRepository::need_packages() const
Context context("When loading category names for " + stringify(name()) + ":");
- LineConfigFile packages(FSEntry(_imp->location / "PACKAGES"));
+ LineConfigFile packages(FSEntry(_imp->location / "PACKAGES"), LineConfigFileOptions());
LineConfigFile::Iterator l(packages.begin()), l_end(packages.end());
std::string last_package_name;
bool skip_invalid_package = false;
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index 0d13734..bfc30e2 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -243,7 +243,7 @@ namespace paludis
found_one = true;
- LineConfigFile f(*p / "profiles.desc");
+ LineConfigFile f(*p / "profiles.desc", LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ; line != line_end ; ++line)
{
std::vector<std::string> tokens;
@@ -508,7 +508,7 @@ PortageRepository::need_category_names() const
if (! (*p / "categories").exists())
continue;
- LineConfigFile cats(*p / "categories");
+ LineConfigFile cats(*p / "categories", LineConfigFileOptions());
for (LineConfigFile::Iterator line(cats.begin()), line_end(cats.end()) ;
line != line_end ; ++line)
@@ -608,7 +608,7 @@ PortageRepository::fetch_repo_name(const std::string & location)
if (! name_file.is_regular_file())
break;
- LineConfigFile f(name_file);
+ LineConfigFile f(name_file, LineConfigFileOptions());
if (f.begin() == f.end())
break;
return RepositoryName(*f.begin());
@@ -664,7 +664,7 @@ PortageRepository::do_query_repository_masks(const QualifiedPackageName & q, con
if (fff.exists())
{
- LineConfigFile ff(fff);
+ LineConfigFile ff(fff, LineConfigFileOptions());
for (LineConfigFile::Iterator line(ff.begin()), line_end(ff.end()) ;
line != line_end ; ++line)
{
@@ -749,7 +749,7 @@ PortageRepository::do_arch_flags() const
if (! a.exists())
continue;
- LineConfigFile archs(a);
+ LineConfigFile archs(a, LineConfigFileOptions());
std::copy(archs.begin(), archs.end(), create_inserter<UseFlagName>(_imp->arch_flags->inserter()));
found_one = true;
}
@@ -795,7 +795,7 @@ PortageRepository::need_mirrors() const
{
if ((*p / "thirdpartymirrors").exists())
{
- LineConfigFile mirrors(*p / "thirdpartymirrors");
+ LineConfigFile mirrors(*p / "thirdpartymirrors", LineConfigFileOptions());
for (LineConfigFile::Iterator line(mirrors.begin()) ; line != mirrors.end() ; ++line)
{
std::vector<std::string> entries;
@@ -938,7 +938,7 @@ PortageRepository::info(bool verbose) const
std::set<std::string> info_pkgs;
if ((_imp->params.location / "profiles" / "info_pkgs").exists())
{
- LineConfigFile vars(_imp->params.location / "profiles" / "info_pkgs");
+ LineConfigFile vars(_imp->params.location / "profiles" / "info_pkgs", LineConfigFileOptions());
info_pkgs.insert(vars.begin(), vars.end());
}
@@ -973,7 +973,7 @@ PortageRepository::info(bool verbose) const
std::set<std::string> info_vars;
if ((_imp->params.location / "profiles" / "info_vars").exists())
{
- LineConfigFile vars(_imp->params.location / "profiles" / "info_vars");
+ LineConfigFile vars(_imp->params.location / "profiles" / "info_vars", LineConfigFileOptions());
info_vars.insert(vars.begin(), vars.end());
}
diff --git a/paludis/repositories/gentoo/portage_repository_news.cc b/paludis/repositories/gentoo/portage_repository_news.cc
index 15e9a31..339b652 100644
--- a/paludis/repositories/gentoo/portage_repository_news.cc
+++ b/paludis/repositories/gentoo/portage_repository_news.cc
@@ -92,7 +92,7 @@ PortageRepositoryNews::update_news() const
{
Context local_context("When handling news skip file '" + stringify(
_imp->skip_file) + "':");
- LineConfigFile s(_imp->skip_file);
+ LineConfigFile s(_imp->skip_file, LineConfigFileOptions());
std::copy(s.begin(), s.end(), std::inserter(skip, skip.end()));
}
@@ -212,13 +212,20 @@ NewsFile::NewsFile(const FSEntry & our_filename) :
{
Context context("When parsing GLEP 42 news file '" + stringify(our_filename) + "':");
- LineConfigFile line_file(our_filename);
+ LineConfigFile line_file(our_filename, LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_no_skip_blank_lines
+ + lcfo_disallow_comments);
for (LineConfigFile::Iterator line(line_file.begin()), line_end(line_file.end()) ;
line != line_end ; ++line)
{
+ if (line->empty())
+ break;
+
std::string::size_type p(line->find(':'));
if (std::string::npos == p)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Bad header line '" + *line + "'");
break;
+ }
else
{
std::string k(strip_leading(strip_trailing(line->substr(0, p), " \t\n"), " \t\n"));
diff --git a/paludis/repositories/gentoo/portage_repository_profile.cc b/paludis/repositories/gentoo/portage_repository_profile.cc
index 2c757f6..af748d8 100644
--- a/paludis/repositories/gentoo/portage_repository_profile.cc
+++ b/paludis/repositories/gentoo/portage_repository_profile.cc
@@ -222,7 +222,7 @@ Implementation<PortageRepositoryProfile>::load_profile_parent(const FSEntry & di
if (! (dir / "parent").exists())
return;
- LineConfigFile file(dir / "parent");
+ LineConfigFile file(dir / "parent", LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments);
LineConfigFile::Iterator i(file.begin()), i_end(file.end());
if (i == i_end)
@@ -435,7 +435,7 @@ Implementation<PortageRepositoryProfile>::load_basic_use_file(const FSEntry & fi
return;
Context context("When loading basic use file '" + stringify(file) + ":");
- LineConfigFile f(file);
+ LineConfigFile f(file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
@@ -470,7 +470,7 @@ Implementation<PortageRepositoryProfile>::load_spec_use_file(const FSEntry & fil
return;
Context context("When loading specised use file '" + stringify(file) + ":");
- LineConfigFile f(file);
+ LineConfigFile f(file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
diff --git a/paludis/repositories/gentoo/portage_repository_profile_file.cc b/paludis/repositories/gentoo/portage_repository_profile_file.cc
index 04fa13a..9ed1910 100644
--- a/paludis/repositories/gentoo/portage_repository_profile_file.cc
+++ b/paludis/repositories/gentoo/portage_repository_profile_file.cc
@@ -42,7 +42,7 @@ ProfileFile::add_file(const FSEntry & f)
if (! f.exists())
return;
- LineConfigFile file(f);
+ LineConfigFile file(f, LineConfigFileOptions());
for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ; line != line_end ; ++line)
{
if (0 == line->compare(0, 1, "-", 0, 1))
diff --git a/paludis/repositories/gentoo/portage_repository_sets.cc b/paludis/repositories/gentoo/portage_repository_sets.cc
index 69acc97..c351295 100644
--- a/paludis/repositories/gentoo/portage_repository_sets.cc
+++ b/paludis/repositories/gentoo/portage_repository_sets.cc
@@ -93,7 +93,7 @@ PortageRepositorySets::package_set(const SetName & s) const
Context context("When loading package set '" + stringify(s) + "' from '" + stringify(ff) + "':");
std::tr1::shared_ptr<AllDepSpec> result(new AllDepSpec);
- LineConfigFile f(ff);
+ LineConfigFile f(ff, LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
diff --git a/paludis/repositories/gentoo/use_desc.cc b/paludis/repositories/gentoo/use_desc.cc
index 1899d86..32a63fd 100644
--- a/paludis/repositories/gentoo/use_desc.cc
+++ b/paludis/repositories/gentoo/use_desc.cc
@@ -40,7 +40,7 @@ namespace paludis
{
if (f.is_regular_file())
{
- LineConfigFile ff(f);
+ LineConfigFile ff(f, LineConfigFileOptions());
for (LineConfigFile::Iterator line(ff.begin()), line_end(ff.end()) ;
line != line_end ; ++line)
{
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index 99dbd08..f202d20 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -1082,7 +1082,7 @@ VDBRepository::do_package_set(const SetName & s) const
if (_imp->world_file.exists())
{
- LineConfigFile world(_imp->world_file);
+ LineConfigFile world(_imp->world_file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
@@ -1153,7 +1153,7 @@ VDBRepository::add_string_to_world(const std::string & n) const
if (_imp->world_file.exists())
{
- LineConfigFile world(_imp->world_file);
+ LineConfigFile world(_imp->world_file, LineConfigFileOptions());
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 299162b..836230c 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -50,7 +50,7 @@ namespace
if (! (FSEntry(DATADIR) / "paludis" / "repository_blacklist.txt").exists())
return;
- LineConfigFile f(FSEntry(DATADIR) / "paludis" / "repository_blacklist.txt");
+ LineConfigFile f(FSEntry(DATADIR) / "paludis" / "repository_blacklist.txt", LineConfigFileOptions());
for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
line != line_end ; ++line)
{
diff --git a/src/clients/adjutrix/display_profiles_use.cc b/src/clients/adjutrix/display_profiles_use.cc
index 7d0bf0d..c40ac90 100644
--- a/src/clients/adjutrix/display_profiles_use.cc
+++ b/src/clients/adjutrix/display_profiles_use.cc
@@ -103,7 +103,7 @@ void do_display_profiles_use(NoConfigEnvironment & env)
std::set<UseFlagName> all_use_flags;
{
- LineConfigFile use_desc(env.main_repository_dir() / "profiles"/ "use.desc");
+ LineConfigFile use_desc(env.main_repository_dir() / "profiles"/ "use.desc", LineConfigFileOptions());
for (LineConfigFile::Iterator line(use_desc.begin()), line_end(use_desc.end()) ;
line != line_end ; ++line)
{
@@ -131,7 +131,7 @@ void do_display_profiles_use(NoConfigEnvironment & env)
std::string prefix(strip_trailing_string(d->basename(), ".desc"));
- LineConfigFile use_desc(*d);
+ LineConfigFile use_desc(*d, LineConfigFileOptions());
for (LineConfigFile::Iterator line(use_desc.begin()), line_end(use_desc.end()) ;
line != line_end ; ++line)
{
diff --git a/src/clients/contrarius/target_config.cc b/src/clients/contrarius/target_config.cc
index a3c578d..bc4fa24 100644
--- a/src/clients/contrarius/target_config.cc
+++ b/src/clients/contrarius/target_config.cc
@@ -34,7 +34,7 @@ TargetConfig::_parse_defaults()
{
Context c("While parsing default configuration:");
- LineConfigFile defaults(FSEntry(DATADIR "/paludis/contrarius/default_config.txt"));
+ LineConfigFile defaults(FSEntry(DATADIR "/paludis/contrarius/default_config.txt"), LineConfigFileOptions());
for (LineConfigFile::Iterator l(defaults.begin()), l_end(defaults.end()) ;
l != l_end ; ++l)
{