aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-07 04:06:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-07 04:06:38 +0000
commit47c420215e8ebd8575b5a2675ebf82536f775926 (patch)
tree3b017ed61ae418e860a3a80da3300d9509fd0210
parentbe4cc6db0db9b2d374ac19a94c9665e3b95aaf27 (diff)
downloadpaludis-47c420215e8ebd8575b5a2675ebf82536f775926.tar.gz
paludis-47c420215e8ebd8575b5a2675ebf82536f775926.tar.xz
Fix up .so usage. Merge config_file source files.
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/args/Makefile.am28
-rw-r--r--paludis/config_file.cc131
-rw-r--r--paludis/config_file.hh137
-rw-r--r--paludis/config_file_TEST.cc117
-rw-r--r--paludis/default_config.cc4
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/key_value_config_file.cc135
-rw-r--r--paludis/key_value_config_file.hh124
-rw-r--r--paludis/key_value_config_file_TEST.cc118
-rw-r--r--paludis/line_config_file.cc41
-rw-r--r--paludis/line_config_file.hh82
-rw-r--r--paludis/line_config_file_TEST.cc73
-rw-r--r--paludis/portage_repository.cc13
-rw-r--r--paludis/qa/Makefile.am.m49
-rw-r--r--paludis/util/Makefile.am.m47
-rw-r--r--src/Makefile.am4
-rw-r--r--src/qualudis/Makefile.am6
18 files changed, 422 insertions, 611 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 1d48765..431c097 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -11,7 +11,7 @@ $1_TEST_SOURCES = $1_TEST.cc
$1_TEST_LDADD = $(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/test/libtest.a \
libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.a
+ $(top_builddir)/paludis/util/libpaludisutil.la
$1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
diff --git a/paludis/args/Makefile.am b/paludis/args/Makefile.am
index f602acf..bd65763 100644
--- a/paludis/args/Makefile.am
+++ b/paludis/args/Makefile.am
@@ -5,27 +5,29 @@ AM_CXXFLAGS = -I$(top_srcdir)
TESTS = \
args_TEST
-libpaludisargs_a_SOURCES = \
- args.hh args.cc \
- args_error.hh args_error.cc \
- args_group.hh args_group.cc \
- args_handler.hh args_handler.cc \
- args_option.hh args_option.cc \
- bad_argument.hh bad_argument.cc \
- args_visitor.hh args_visitor.cc \
- bad_value.hh bad_value.cc \
+libpaludisargs_la_SOURCES = \
+ args.hh args.cc \
+ args_error.hh args_error.cc \
+ args_group.hh args_group.cc \
+ args_handler.hh args_handler.cc \
+ args_option.hh args_option.cc \
+ bad_argument.hh bad_argument.cc \
+ args_visitor.hh args_visitor.cc \
+ bad_value.hh bad_value.cc \
missing_value.hh missing_value.cc \
- args_dumper.hh args_dumper.cc
+ args_dumper.hh args_dumper.cc
+
+libpaludisargs_la_LDFLAGS = -version-info 0:0:0
TESTS_ENVIRONMENT = env -u PALUDIS_OPTIONS TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh
-noinst_LIBRARIES = libpaludisargs.a
+lib_LTLIBRARIES = libpaludisargs.la
check_PROGRAMS = $(TESTS)
test_ldadd = \
$(top_builddir)/test/libtest.a \
- libpaludisargs.a \
+ libpaludisargs.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.a
+ $(top_builddir)/paludis/util/libpaludisutil.la
args_TEST_SOURCES = args_TEST.cc
args_TEST_LDADD = $(test_ldadd)
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 2438682..f915614 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -106,3 +106,134 @@ ConfigFile::skip_line(const std::string & s) const
return (s.empty() || '#' == s.at(0));
}
+LineConfigFile::LineConfigFile(std::istream * const s) :
+ ConfigFile(s)
+{
+ need_lines();
+}
+
+LineConfigFile::LineConfigFile(const std::string & filename) :
+ ConfigFile(filename)
+{
+ need_lines();
+}
+
+void
+LineConfigFile::accept_line(const std::string & s) const
+{
+ _lines.push_back(s);
+}
+
+KeyValueConfigFileError::KeyValueConfigFileError(const std::string & msg,
+ const std::string & filename) throw () :
+ ConfigurationError("Key/Value config file error" +
+ (filename.empty() ? ": " : "in file '" + filename + "': ") + msg)
+{
+}
+
+KeyValueConfigFile::KeyValueConfigFile(std::istream * const s) :
+ ConfigFile(s)
+{
+ need_lines();
+}
+
+KeyValueConfigFile::KeyValueConfigFile(const std::string & filename) :
+ ConfigFile(filename)
+{
+ need_lines();
+}
+
+KeyValueConfigFile::~KeyValueConfigFile()
+{
+}
+
+void
+KeyValueConfigFile::accept_line(const std::string & line) const
+{
+ std::string::size_type p(line.find('='));
+ if (std::string::npos == p)
+ _entries[line] = "";
+ else
+ {
+ std::string key(line.substr(0, p)), value(line.substr(p + 1));
+ normalise_line(key);
+ normalise_line(value);
+ _entries[key] = replace_variables(strip_quotes(value));
+ }
+}
+
+std::string
+KeyValueConfigFile::replace_variables(const std::string & s) const
+{
+ std::string r;
+ std::string::size_type p(0), old_p(0);
+
+ while (p < s.length())
+ {
+ old_p = p;
+
+ if ('\\' == s[p])
+ {
+ if (++p >= s.length())
+ throw KeyValueConfigFileError("Backslash not followed by a character", filename());
+ r += s[p++];
+ }
+ else if ('$' != s[p])
+ r += s[p++];
+ else
+ {
+ std::string name;
+ if (++p >= s.length())
+ throw KeyValueConfigFileError("Dollar not followed by a character", filename());
+
+ if ('{' == s[p])
+ {
+ std::string::size_type q;
+ if (std::string::npos == ((q = s.find("}", p))))
+ throw KeyValueConfigFileError("Closing } not found", filename());
+
+ name = s.substr(p + 1, q - p - 1);
+ p = q + 1;
+ }
+ else
+ {
+ std::string::size_type q;
+ if (std::string::npos == ((q = s.find_first_not_of(
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "_0123456789", p))))
+ q = s.length();
+
+ name = s.substr(p, q - p);
+ p = q;
+ }
+
+ if (name.empty())
+ throw KeyValueConfigFileError("Empty variable name", filename());
+ r += get(name);
+ }
+
+ if (p <= old_p)
+ throw InternalError(PALUDIS_HERE, "Infinite loop");
+ }
+
+ return r;
+}
+
+std::string
+KeyValueConfigFile::strip_quotes(const std::string & s) const
+{
+ if (s.empty())
+ return s;
+ if (std::string::npos != std::string("'\"").find(s[0]))
+ {
+ if (s.length() < 2)
+ throw KeyValueConfigFileError("Unterminated quote", filename());
+ if (s[s.length() - 1] != s[0])
+ throw KeyValueConfigFileError("Mismatched quote", filename());
+ return s.substr(1, s.length() - 2);
+ }
+ else
+ return s;
+}
+
diff --git a/paludis/config_file.hh b/paludis/config_file.hh
index dfd5913..aeb617e 100644
--- a/paludis/config_file.hh
+++ b/paludis/config_file.hh
@@ -24,10 +24,11 @@
#include <paludis/util/exception.hh>
#include <istream>
#include <list>
+#include <map>
#include <string>
/** \file
- * Declarations for the ConfigFile class.
+ * Declarations for the ConfigFile classes.
*
* \ingroup ConfigFile
* \ingroup Exception
@@ -120,6 +121,140 @@ namespace paludis
*/
virtual ~ConfigFile();
};
+
+ /**
+ * A LineConfigFile is a ConfigFile that provides access to the
+ * normalised lines. Do not subclass.
+ *
+ * \ingroup ConfigFile
+ */
+ class LineConfigFile : protected ConfigFile
+ {
+ private:
+ mutable std::list<std::string> _lines;
+
+ protected:
+ void accept_line(const std::string &) const;
+
+ public:
+ /**
+ * Constructor, from a stream.
+ */
+ LineConfigFile(std::istream * const);
+
+ /**
+ * Constructor, from a filename.
+ */
+ LineConfigFile(const std::string & filename);
+
+ /**
+ * Iterator over our lines.
+ */
+ typedef std::list<std::string>::const_iterator Iterator;
+
+ /**
+ * Iterator to the start of our lines.
+ */
+ Iterator begin() const
+ {
+ return _lines.begin();
+ }
+
+ /**
+ * Iterator to past the end of our lines.
+ */
+ Iterator end() const
+ {
+ return _lines.end();
+ }
+ };
+
+ /**
+ * A KeyValueConfigFileError is thrown if bad data is encountered in
+ * a ConfigFile.
+ *
+ * \ingroup ConfigFile
+ * \ingroup Exception
+ */
+ class KeyValueConfigFileError : public ConfigurationError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ KeyValueConfigFileError(const std::string & message,
+ const std::string & filename = "") throw ();
+ };
+
+ /**
+ * A KeyValueConfigFile is a ConfigFile that provides access to the
+ * normalised lines. Do not subclass.
+ *
+ * \ingroup ConfigFile
+ */
+ class KeyValueConfigFile : protected ConfigFile
+ {
+ private:
+ mutable std::map<std::string, std::string> _entries;
+
+ protected:
+ void accept_line(const std::string &) const;
+
+ /**
+ * Handle variable replacement.
+ */
+ std::string replace_variables(const std::string &) const;
+
+ /**
+ * Handle quote removal.
+ */
+ std::string strip_quotes(const std::string &) const;
+
+ public:
+ /**
+ * Constructor, from a stream.
+ */
+ KeyValueConfigFile(std::istream * const);
+
+ /**
+ * Constructor, from a filename.
+ */
+ KeyValueConfigFile(const std::string & filename);
+
+ /**
+ * Destructor.
+ */
+ ~KeyValueConfigFile();
+
+ /**
+ * Iterator over our key/values.
+ */
+ typedef std::map<std::string, std::string>::const_iterator Iterator;
+
+ /**
+ * Start of our key/values.
+ */
+ Iterator begin() const
+ {
+ return _entries.begin();
+ }
+
+ /**
+ * Past the end of our key/values.
+ */
+ Iterator end() const
+ {
+ return _entries.end();
+ }
+
+ /**
+ * Fetch the specified key, or a blank string.
+ */
+ std::string get(const std::string & key) const
+ {
+ return _entries[key];
+ }
+ };
}
#endif
diff --git a/paludis/config_file_TEST.cc b/paludis/config_file_TEST.cc
index a6027d4..e1ce1fd 100644
--- a/paludis/config_file_TEST.cc
+++ b/paludis/config_file_TEST.cc
@@ -122,5 +122,122 @@ namespace test_cases
TEST_CHECK_THROWS(f3 = new TestFile(ff3), ConfigFileError);
}
} test_config_file_open_file;
+
+ /**
+ * \test Test LineConfigFile.
+ *
+ * \ingroup Test
+ */
+ struct LineConfigFileTest : TestCase
+ {
+ LineConfigFileTest() : TestCase("line config file") { }
+
+ void run()
+ {
+ std::stringstream s;
+ s << "one" << std::endl;
+ s << " two \t " << std::endl;
+ s << " \t " << std::endl;
+ s << "" << std::endl;
+ s << "three" << std::endl;
+ s << "# blah" << std::endl;
+ s << " # blah" << std::endl;
+ s << "#" << std::endl;
+ s << " # \t " << std::endl;
+ s << "four four" << std::endl;
+ LineConfigFile ff(&s);
+ std::vector<std::string> f(ff.begin(), ff.end());
+
+ TEST_CHECK_EQUAL(f.size(), 4);
+ TEST_CHECK_EQUAL(f.at(0), "one");
+ TEST_CHECK_EQUAL(f.at(1), "two");
+ TEST_CHECK_EQUAL(f.at(2), "three");
+ TEST_CHECK_EQUAL(f.at(3), "four four");
+ }
+ } test_line_config_file;
+
+ /**
+ * \test Test KeyValueConfigFile basics.
+ *
+ * \ingroup Test
+ */
+ struct KeyValueConfigFileTest : TestCase
+ {
+ KeyValueConfigFileTest() : TestCase("key value config file") { }
+
+ void run()
+ {
+ std::stringstream s;
+ s << "one=first" << std::endl;
+ s << "two = second" << std::endl;
+ s << "three" << std::endl;
+ s << "four = \"fourth\" " << std::endl;
+ s << "five = ''" << std::endl;
+ KeyValueConfigFile ff(&s);
+
+ TEST_CHECK_EQUAL(ff.get("one"), "first");
+ TEST_CHECK_EQUAL(ff.get("two"), "second");
+ TEST_CHECK_EQUAL(ff.get("three"), "");
+ TEST_CHECK_EQUAL(ff.get("four"), "fourth");
+ TEST_CHECK_EQUAL(ff.get("five"), "");
+ TEST_CHECK_EQUAL(ff.get("six"), "");
+ }
+ } test_key_value_config_file;
+
+ /**
+ * \test Test KeyValueConfigFile variables.
+ *
+ * \ingroup Test
+ */
+ struct KeyValueConfigFileVarsTest : TestCase
+ {
+ KeyValueConfigFileVarsTest() : TestCase("key value config file with vars") { }
+
+ void run()
+ {
+ std::stringstream s;
+ s << "x=foo" << std::endl;
+ s << "y = \"${x}\\\\${y}\\$${z}\"" << std::endl;
+ s << "z = $x$y$z" << std::endl;
+ KeyValueConfigFile ff(&s);
+
+ TEST_CHECK_EQUAL(ff.get("x"), "foo");
+ TEST_CHECK_EQUAL(ff.get("y"), "foo\\$");
+ TEST_CHECK_EQUAL(ff.get("z"), "foofoo\\$");
+ }
+ } test_key_value_config_file_vars;
+
+ /**
+ * \test Test KeyValueConfigFile errors.
+ *
+ * \ingroup Test
+ */
+ struct KeyValueConfigFileErrorsTest : TestCase
+ {
+ KeyValueConfigFileErrorsTest() : TestCase("key value config file with errors") { }
+
+ void run()
+ {
+ std::stringstream s1;
+ s1 << "x='" << std::endl;
+ TEST_CHECK_THROWS(KeyValueConfigFile ff(&s1), ConfigurationError);
+
+ std::stringstream s2;
+ s2 << "x='moo\"" << std::endl;
+ TEST_CHECK_THROWS(KeyValueConfigFile ff(&s2), ConfigurationError);
+
+ std::stringstream s3;
+ s3 << "x=${foo" << std::endl;
+ TEST_CHECK_THROWS(KeyValueConfigFile ff(&s3), ConfigurationError);
+
+ std::stringstream s4;
+ s4 << "x=$~" << std::endl;
+ TEST_CHECK_THROWS(KeyValueConfigFile ff(&s4), ConfigurationError);
+
+ std::stringstream s5;
+ s5 << "x=abc\\" << std::endl;
+ TEST_CHECK_THROWS(KeyValueConfigFile ff(&s5), ConfigurationError);
+ }
+ } test_key_value_config_file_errors;
}
diff --git a/paludis/default_config.cc b/paludis/default_config.cc
index b7dcf71..82b54d6 100644
--- a/paludis/default_config.cc
+++ b/paludis/default_config.cc
@@ -17,9 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <paludis/config_file.hh>
#include <paludis/default_config.hh>
-#include <paludis/key_value_config_file.hh>
-#include <paludis/line_config_file.hh>
#include <paludis/util/create_insert_iterator.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/dir_iterator.hh>
@@ -30,6 +29,7 @@
#include <paludis/util/iterator_utilities.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
+
#include <fstream>
#include <algorithm>
#include <sstream>
diff --git a/paludis/files.m4 b/paludis/files.m4
index e73d758..838b42e 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -23,9 +23,7 @@ add(`dep_parser', `hh', `cc', `test')
add(`environment', `hh', `cc')
add(`fake_repository', `hh', `cc')
add(`hashed_containers', `hh', `cc', `test')
-add(`key_value_config_file', `hh', `cc', `test')
add(`keyword_name', `hh', `cc')
-add(`line_config_file', `hh', `cc', `test')
add(`mask_reasons', `hh', `cc')
add(`match_package', `hh', `cc')
add(`match_sequence', `hh', `cc', `test')
diff --git a/paludis/key_value_config_file.cc b/paludis/key_value_config_file.cc
deleted file mode 100644
index 9203315..0000000
--- a/paludis/key_value_config_file.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/key_value_config_file.hh>
-
-using namespace paludis;
-
-KeyValueConfigFileError::KeyValueConfigFileError(const std::string & msg,
- const std::string & filename) throw () :
- ConfigurationError("Key/Value config file error" +
- (filename.empty() ? ": " : "in file '" + filename + "': ") + msg)
-{
-}
-
-KeyValueConfigFile::KeyValueConfigFile(std::istream * const s) :
- ConfigFile(s)
-{
- need_lines();
-}
-
-KeyValueConfigFile::KeyValueConfigFile(const std::string & filename) :
- ConfigFile(filename)
-{
- need_lines();
-}
-
-KeyValueConfigFile::~KeyValueConfigFile()
-{
-}
-
-void
-KeyValueConfigFile::accept_line(const std::string & line) const
-{
- std::string::size_type p(line.find('='));
- if (std::string::npos == p)
- _entries[line] = "";
- else
- {
- std::string key(line.substr(0, p)), value(line.substr(p + 1));
- normalise_line(key);
- normalise_line(value);
- _entries[key] = replace_variables(strip_quotes(value));
- }
-}
-
-std::string
-KeyValueConfigFile::replace_variables(const std::string & s) const
-{
- std::string r;
- std::string::size_type p(0), old_p(0);
-
- while (p < s.length())
- {
- old_p = p;
-
- if ('\\' == s[p])
- {
- if (++p >= s.length())
- throw KeyValueConfigFileError("Backslash not followed by a character", filename());
- r += s[p++];
- }
- else if ('$' != s[p])
- r += s[p++];
- else
- {
- std::string name;
- if (++p >= s.length())
- throw KeyValueConfigFileError("Dollar not followed by a character", filename());
-
- if ('{' == s[p])
- {
- std::string::size_type q;
- if (std::string::npos == ((q = s.find("}", p))))
- throw KeyValueConfigFileError("Closing } not found", filename());
-
- name = s.substr(p + 1, q - p - 1);
- p = q + 1;
- }
- else
- {
- std::string::size_type q;
- if (std::string::npos == ((q = s.find_first_not_of(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "_0123456789", p))))
- q = s.length();
-
- name = s.substr(p, q - p);
- p = q;
- }
-
- if (name.empty())
- throw KeyValueConfigFileError("Empty variable name", filename());
- r += get(name);
- }
-
- if (p <= old_p)
- throw InternalError(PALUDIS_HERE, "Infinite loop");
- }
-
- return r;
-}
-
-std::string
-KeyValueConfigFile::strip_quotes(const std::string & s) const
-{
- if (s.empty())
- return s;
- if (std::string::npos != std::string("'\"").find(s[0]))
- {
- if (s.length() < 2)
- throw KeyValueConfigFileError("Unterminated quote", filename());
- if (s[s.length() - 1] != s[0])
- throw KeyValueConfigFileError("Mismatched quote", filename());
- return s.substr(1, s.length() - 2);
- }
- else
- return s;
-}
diff --git a/paludis/key_value_config_file.hh b/paludis/key_value_config_file.hh
deleted file mode 100644
index a512750..0000000
--- a/paludis/key_value_config_file.hh
+++ /dev/null
@@ -1,124 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_KEY_VALUE_CONFIG_FILE_HH
-#define PALUDIS_GUARD_PALUDIS_KEY_VALUE_CONFIG_FILE_HH 1
-
-#include <paludis/config_file.hh>
-#include <map>
-
-/** \file
- * Declarations for the KeyValueConfigFile class.
- *
- * \ingroup ConfigFile
- */
-
-
-namespace paludis
-{
- /**
- * A KeyValueConfigFileError is thrown if bad data is encountered in
- * a ConfigFile.
- *
- * \ingroup ConfigFile
- * \ingroup Exception
- */
- class KeyValueConfigFileError : public ConfigurationError
- {
- public:
- /**
- * Constructor.
- */
- KeyValueConfigFileError(const std::string & message,
- const std::string & filename = "") throw ();
- };
-
- /**
- * A KeyValueConfigFile is a ConfigFile that provides access to the
- * normalised lines. Do not subclass.
- *
- * \ingroup ConfigFile
- */
- class KeyValueConfigFile : protected ConfigFile
- {
- private:
- mutable std::map<std::string, std::string> _entries;
-
- protected:
- void accept_line(const std::string &) const;
-
- /**
- * Handle variable replacement.
- */
- std::string replace_variables(const std::string &) const;
-
- /**
- * Handle quote removal.
- */
- std::string strip_quotes(const std::string &) const;
-
- public:
- /**
- * Constructor, from a stream.
- */
- KeyValueConfigFile(std::istream * const);
-
- /**
- * Constructor, from a filename.
- */
- KeyValueConfigFile(const std::string & filename);
-
- /**
- * Destructor.
- */
- ~KeyValueConfigFile();
-
- /**
- * Iterator over our key/values.
- */
- typedef std::map<std::string, std::string>::const_iterator Iterator;
-
- /**
- * Start of our key/values.
- */
- Iterator begin() const
- {
- return _entries.begin();
- }
-
- /**
- * Past the end of our key/values.
- */
- Iterator end() const
- {
- return _entries.end();
- }
-
- /**
- * Fetch the specified key, or a blank string.
- */
- std::string get(const std::string & key) const
- {
- return _entries[key];
- }
- };
-
-}
-
-#endif
diff --git a/paludis/key_value_config_file_TEST.cc b/paludis/key_value_config_file_TEST.cc
deleted file mode 100644
index db4428e..0000000
--- a/paludis/key_value_config_file_TEST.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/stringify.hh>
-#include <paludis/key_value_config_file.hh>
-#include <paludis/util/exception.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <vector>
-#include <algorithm>
-#include <sstream>
-
-using namespace paludis;
-using namespace test;
-
-namespace test_cases
-{
- /**
- * \test Test KeyValueConfigFile basics.
- *
- * \ingroup Test
- */
- struct KeyValueConfigFileTest : TestCase
- {
- KeyValueConfigFileTest() : TestCase("key value config file") { }
-
- void run()
- {
- std::stringstream s;
- s << "one=first" << std::endl;
- s << "two = second" << std::endl;
- s << "three" << std::endl;
- s << "four = \"fourth\" " << std::endl;
- s << "five = ''" << std::endl;
- KeyValueConfigFile ff(&s);
-
- TEST_CHECK_EQUAL(ff.get("one"), "first");
- TEST_CHECK_EQUAL(ff.get("two"), "second");
- TEST_CHECK_EQUAL(ff.get("three"), "");
- TEST_CHECK_EQUAL(ff.get("four"), "fourth");
- TEST_CHECK_EQUAL(ff.get("five"), "");
- TEST_CHECK_EQUAL(ff.get("six"), "");
- }
- } test_key_value_config_file;
-
- /**
- * \test Test KeyValueConfigFile variables.
- *
- * \ingroup Test
- */
- struct KeyValueConfigFileVarsTest : TestCase
- {
- KeyValueConfigFileVarsTest() : TestCase("key value config file with vars") { }
-
- void run()
- {
- std::stringstream s;
- s << "x=foo" << std::endl;
- s << "y = \"${x}\\\\${y}\\$${z}\"" << std::endl;
- s << "z = $x$y$z" << std::endl;
- KeyValueConfigFile ff(&s);
-
- TEST_CHECK_EQUAL(ff.get("x"), "foo");
- TEST_CHECK_EQUAL(ff.get("y"), "foo\\$");
- TEST_CHECK_EQUAL(ff.get("z"), "foofoo\\$");
- }
- } test_key_value_config_file_vars;
-
- /**
- * \test Test KeyValueConfigFile errors.
- *
- * \ingroup Test
- */
- struct KeyValueConfigFileErrorsTest : TestCase
- {
- KeyValueConfigFileErrorsTest() : TestCase("key value config file with errors") { }
-
- void run()
- {
- std::stringstream s1;
- s1 << "x='" << std::endl;
- TEST_CHECK_THROWS(KeyValueConfigFile ff(&s1), ConfigurationError);
-
- std::stringstream s2;
- s2 << "x='moo\"" << std::endl;
- TEST_CHECK_THROWS(KeyValueConfigFile ff(&s2), ConfigurationError);
-
- std::stringstream s3;
- s3 << "x=${foo" << std::endl;
- TEST_CHECK_THROWS(KeyValueConfigFile ff(&s3), ConfigurationError);
-
- std::stringstream s4;
- s4 << "x=$~" << std::endl;
- TEST_CHECK_THROWS(KeyValueConfigFile ff(&s4), ConfigurationError);
-
- std::stringstream s5;
- s5 << "x=abc\\" << std::endl;
- TEST_CHECK_THROWS(KeyValueConfigFile ff(&s5), ConfigurationError);
- }
- } test_key_value_config_file_errors;
-}
-
diff --git a/paludis/line_config_file.cc b/paludis/line_config_file.cc
deleted file mode 100644
index 8525d59..0000000
--- a/paludis/line_config_file.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/line_config_file.hh>
-
-using namespace paludis;
-
-LineConfigFile::LineConfigFile(std::istream * const s) :
- ConfigFile(s)
-{
- need_lines();
-}
-
-LineConfigFile::LineConfigFile(const std::string & filename) :
- ConfigFile(filename)
-{
- need_lines();
-}
-
-void
-LineConfigFile::accept_line(const std::string & s) const
-{
- _lines.push_back(s);
-}
-
diff --git a/paludis/line_config_file.hh b/paludis/line_config_file.hh
deleted file mode 100644
index dffdc9e..0000000
--- a/paludis/line_config_file.hh
+++ /dev/null
@@ -1,82 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_LINE_CONFIG_FILE_HH
-#define PALUDIS_GUARD_PALUDIS_LINE_CONFIG_FILE_HH 1
-
-#include <paludis/config_file.hh>
-#include <list>
-
-/** \file
- * Declarations for the LineConfigFile class.
- *
- * \ingroup ConfigFile
- */
-
-namespace paludis
-{
- /**
- * A LineConfigFile is a ConfigFile that provides access to the
- * normalised lines. Do not subclass.
- *
- * \ingroup ConfigFile
- */
- class LineConfigFile : protected ConfigFile
- {
- private:
- mutable std::list<std::string> _lines;
-
- protected:
- void accept_line(const std::string &) const;
-
- public:
- /**
- * Constructor, from a stream.
- */
- LineConfigFile(std::istream * const);
-
- /**
- * Constructor, from a filename.
- */
- LineConfigFile(const std::string & filename);
-
- /**
- * Iterator over our lines.
- */
- typedef std::list<std::string>::const_iterator Iterator;
-
- /**
- * Iterator to the start of our lines.
- */
- Iterator begin() const
- {
- return _lines.begin();
- }
-
- /**
- * Iterator to past the end of our lines.
- */
- Iterator end() const
- {
- return _lines.end();
- }
- };
-}
-
-#endif
diff --git a/paludis/line_config_file_TEST.cc b/paludis/line_config_file_TEST.cc
deleted file mode 100644
index 9ea8b3a..0000000
--- a/paludis/line_config_file_TEST.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/line_config_file.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <sstream>
-#include <vector>
-#include <iterator>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for line_config_file.hh .
- *
- * \ingroup Test
- * \ingroup ConfigFile
- */
-
-namespace test_cases
-{
- /**
- * \test Test LineConfigFile.
- *
- * \ingroup Test
- */
- struct LineConfigFileTest : TestCase
- {
- LineConfigFileTest() : TestCase("line config file") { }
-
- void run()
- {
- std::stringstream s;
- s << "one" << std::endl;
- s << " two \t " << std::endl;
- s << " \t " << std::endl;
- s << "" << std::endl;
- s << "three" << std::endl;
- s << "# blah" << std::endl;
- s << " # blah" << std::endl;
- s << "#" << std::endl;
- s << " # \t " << std::endl;
- s << "four four" << std::endl;
- LineConfigFile ff(&s);
- std::vector<std::string> f(ff.begin(), ff.end());
-
- TEST_CHECK_EQUAL(f.size(), 4);
- TEST_CHECK_EQUAL(f.at(0), "one");
- TEST_CHECK_EQUAL(f.at(1), "two");
- TEST_CHECK_EQUAL(f.at(2), "three");
- TEST_CHECK_EQUAL(f.at(3), "four four");
- }
- } test_line_config_file;
-}
-
-
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 33dbc12..6faf2b5 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -19,21 +19,20 @@
#include "config.h"
+#include <paludis/dep_atom.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/config_file.hh>
+#include <paludis/match_package.hh>
+#include <paludis/package_database.hh>
+#include <paludis/portage_repository.hh>
#include <paludis/util/create_insert_iterator.hh>
#include <paludis/util/dir_iterator.hh>
-#include <paludis/dep_atom.hh>
#include <paludis/util/filter_insert_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/getenv.hh>
-#include <paludis/hashed_containers.hh>
#include <paludis/util/indirect_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
-#include <paludis/line_config_file.hh>
-#include <paludis/key_value_config_file.hh>
#include <paludis/util/log.hh>
-#include <paludis/match_package.hh>
-#include <paludis/package_database.hh>
-#include <paludis/portage_repository.hh>
#include <paludis/util/pstream.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/strip.hh>
diff --git a/paludis/qa/Makefile.am.m4 b/paludis/qa/Makefile.am.m4
index 09e2469..e02c9c6 100644
--- a/paludis/qa/Makefile.am.m4
+++ b/paludis/qa/Makefile.am.m4
@@ -11,9 +11,9 @@ $1_TEST_SOURCES = $1_TEST.cc
$1_TEST_LDADD = \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/test/libtest.a \
- libpaludisqa.a \
+ libpaludisqa.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.a
+ $(top_builddir)/paludis/util/libpaludisutil.la
$1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
@@ -37,7 +37,8 @@ AM_CXXFLAGS = -I$(top_srcdir)
DEFS=-DSYSCONFDIR=\"$(sysconfdir)\" -DLIBEXECDIR=\"$(libexecdir)\"
EXTRA_DIST = Makefile.am.m4 files.m4 qa.hh.m4 testscriptlist
-libpaludisqa_a_SOURCES = filelist
+libpaludisqa_la_SOURCES = filelist
+libpaludisqa_la_LDFLAGS = -version-info 0:0:0
TESTS = testlist
@@ -48,7 +49,7 @@ TESTS_ENVIRONMENT = env \
check_PROGRAMS = $(TESTS)
check_SCRIPTS = testscriptlist
-noinst_LIBRARIES = libpaludisqa.a
+lib_LTLIBRARIES = libpaludisqa.la
Makefile.am : Makefile.am.m4 files.m4
$(top_srcdir)/misc/do_m4.bash Makefile.am
diff --git a/paludis/util/Makefile.am.m4 b/paludis/util/Makefile.am.m4
index e0180e3..9057fa4 100644
--- a/paludis/util/Makefile.am.m4
+++ b/paludis/util/Makefile.am.m4
@@ -8,7 +8,7 @@ define(`testlist', `')dnl
define(`testscriptlist', `')dnl
define(`addtest', `define(`testlist', testlist `$1_TEST')dnl
$1_TEST_SOURCES = $1_TEST.cc
-$1_TEST_LDADD = test_extras.o $(top_builddir)/test/libtest.a libpaludisutil.a
+$1_TEST_LDADD = test_extras.o $(top_builddir)/test/libtest.a libpaludisutil.la
$1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
@@ -35,7 +35,8 @@ EXTRA_DIST = util.hh.m4 Makefile.am.m4 files.m4 smart_record.hh.m4 \
comparison_policy.hh.m4 testscriptlist test_extras.cc
SUBDIRS = .
-libpaludisutil_a_SOURCES = filelist
+libpaludisutil_la_SOURCES = filelist
+libpaludisutil_la_LDFLAGS = -version-info 0:0:0
TESTS = testlist
@@ -46,7 +47,7 @@ TESTS_ENVIRONMENT = env \
check_PROGRAMS = $(TESTS)
check_SCRIPTS = testscriptlist
-noinst_LIBRARIES = libpaludisutil.a
+lib_LTLIBRARIES = libpaludisutil.la
Makefile.am : Makefile.am.m4 files.m4
$(top_srcdir)/misc/do_m4.bash Makefile.am
diff --git a/src/Makefile.am b/src/Makefile.am
index 73bc026..1d8d2d7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,8 +16,8 @@ paludis_SOURCES = \
paludis_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/args/libpaludisargs.a \
- $(top_builddir)/paludis/util/libpaludisutil.a
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la
TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh bash
TESTS = version_TEST
diff --git a/src/qualudis/Makefile.am b/src/qualudis/Makefile.am
index 1a386ab..f47a8bf 100644
--- a/src/qualudis/Makefile.am
+++ b/src/qualudis/Makefile.am
@@ -11,9 +11,9 @@ qualudis_SOURCES = \
qualudis.cc
qualudis_LDADD = \
- $(top_builddir)/paludis/args/libpaludisargs.a \
- $(top_builddir)/paludis/qa/libpaludisqa.a \
- $(top_builddir)/paludis/util/libpaludisutil.a \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/qa/libpaludisqa.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/libpaludis.la
TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh bash