aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-30 06:09:03 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-30 06:09:03 +0000
commitf07cb644b42d3fa140cfed89049e73265a70ec51 (patch)
treef39455da49edb630c88ad16d72ccc9732da8488e
parent34d8622d7d5843cb0691adf7627b954314e2b644 (diff)
downloadpaludis-f07cb644b42d3fa140cfed89049e73265a70ec51.tar.gz
paludis-f07cb644b42d3fa140cfed89049e73265a70ec51.tar.xz
Kill off xml pointer holders in favour of tr1:: shared_ptr. Fixes: ticket:41
-rw-r--r--configure.ac1
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/libxml/Makefile.am56
-rw-r--r--paludis/libxml/libxml.cc41
-rw-r--r--paludis/libxml/libxml.hh90
-rw-r--r--paludis/qa/Makefile.am.m42
-rw-r--r--paludis/qa/metadata_check.cc15
-rw-r--r--paludis/qa/metadata_file.cc24
-rw-r--r--paludis/repositories/portage/Makefile.am6
-rw-r--r--paludis/repositories/portage/xml_things.cc19
10 files changed, 44 insertions, 212 deletions
diff --git a/configure.ac b/configure.ac
index bdd547b..2be5f29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -878,7 +878,6 @@ AC_OUTPUT(
paludis/environment/no_config/Makefile
paludis/environment/test/Makefile
paludis/hashed_containers.hh
- paludis/libxml/Makefile
paludis/qa/Makefile
paludis/repositories/Makefile
paludis/repositories/cran/Makefile
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 073949e..e777aa6 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -64,7 +64,7 @@ DEFS= \
-DLIBDIR=\"$(libdir)\"
EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \
hashed_containers.hh.in testscriptlist srlist srcleanlist
-SUBDIRS = digests util libxml . dep_list repositories environment args qa selinux tasks
+SUBDIRS = digests util . dep_list repositories environment args qa selinux tasks
BUILT_SOURCES = srcleanlist
libpaludis_la_SOURCES = filelist
diff --git a/paludis/libxml/Makefile.am b/paludis/libxml/Makefile.am
deleted file mode 100644
index 9471a63..0000000
--- a/paludis/libxml/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
-MAINTAINERCLEANFILES = Makefile.in
-AM_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
-DEFS= \
- -DSYSCONFDIR=\"$(sysconfdir)\" \
- -DLIBEXECDIR=\"$(libexecdir)\" \
- -DDATADIR=\"$(datadir)\"
-SUBDIRS = .
-
-TESTS =
-
-TESTS_ENVIRONMENT = env \
- PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
- PALUDIS_SKIP_CONFIG="yes" \
- TEST_SCRIPT_DIR="$(srcdir)/" \
- bash $(top_srcdir)/test/run_test.sh
-
-check_PROGRAMS = $(TESTS)
-check_SCRIPTS =
-
-if NEED_XML
-
-if MONOLITHIC
-
-noinst_LTLIBRARIES = libpaludislibxml.la
-
-else
-
-lib_LTLIBRARIES = libpaludislibxml.la
-
-endif
-
-paludis_libxml_includedir = $(includedir)/paludis/libxml
-paludis_libxml_include_HEADERS = \
- libxml.hh
-libpaludislibxml_la_SOURCES = $(paludis_libxml_include_HEADERS) \
- libxml.cc
-libpaludislibxml_la_CXXFLAGS = $(AM_CXXFLAGS) @LIBXML2DEPS_CFLAGS@
-
-if ! MONOLITHIC
-
-libpaludislibxml_la_LIBADD = \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- @LIBXML2DEPS_LIBS@
-
-endif
-
-libpaludislibxml_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
-
-endif
-
-EXTRA_DIST = libxml.hh libxml.cc
-
-built-sources : $(BUILT_SOURCES)
- for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
-
diff --git a/paludis/libxml/libxml.cc b/paludis/libxml/libxml.cc
deleted file mode 100644
index 74c6461..0000000
--- a/paludis/libxml/libxml.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 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
- * 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/libxml/libxml.hh>
-#include <list>
-#include <paludis/util/join.hh>
-#include <paludis/util/tokeniser.hh>
-
-std::string
-paludis::retarded_libxml_string_to_string(const xmlChar * s)
-{
- if (s)
- return std::string(reinterpret_cast<const char *>(s));
- else
- return "";
-}
-
-std::string
-paludis::normalise(const std::string & s)
-{
- std::list<std::string> words;
- WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(words));
- return join(words.begin(), words.end(), " ");
-}
-
diff --git a/paludis/libxml/libxml.hh b/paludis/libxml/libxml.hh
deleted file mode 100644
index 7ae7078..0000000
--- a/paludis/libxml/libxml.hh
+++ /dev/null
@@ -1,90 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 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
- * 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_QA_LIBXML_UTILS_HH
-#define PALUDIS_GUARD_PALUDIS_QA_LIBXML_UTILS_HH 1
-
-#include <libxml/parser.h>
-#include <paludis/util/attributes.hh>
-#include <string>
-
-namespace paludis
-{
- /**
- * Wrapper around libxml pointers.
- *
- * RAII, the specified function is used to free the pointer.
- *
- * \ingroup grpxml
- */
- template <typename PtrType_>
- class LibXmlPtrHolder
- {
- private:
- PtrType_ _ptr;
- void (* _free_func) (PtrType_);
-
- LibXmlPtrHolder(const LibXmlPtrHolder &);
- void operator= (const LibXmlPtrHolder &);
-
- public:
- ///\name Basic operations
- ///\{
-
- LibXmlPtrHolder(PtrType_ ptr, void (* free_func) (PtrType_)) :
- _ptr(ptr),
- _free_func(free_func)
- {
- }
-
- ~LibXmlPtrHolder()
- {
- if (0 != _ptr)
- _free_func(_ptr);
- }
-
- ///\}
-
- /**
- * Cast to our pointer type.
- */
- operator PtrType_ () const
- {
- return _ptr;
- }
- };
-
- /**
- * Turn a retarded libxml string into a std::string.
- *
- * \ingroup grpxml
- */
- std::string
- retarded_libxml_string_to_string(const xmlChar * s) PALUDIS_VISIBLE;
-
- /**
- * Remove leading and trailing whitespace, and normalise internal whitespace.
- *
- * \ingroup grpxml
- */
- std::string normalise(const std::string & s) PALUDIS_VISIBLE;
-}
-
-
-#endif
diff --git a/paludis/qa/Makefile.am.m4 b/paludis/qa/Makefile.am.m4
index 4e08cc2..81ba4ec 100644
--- a/paludis/qa/Makefile.am.m4
+++ b/paludis/qa/Makefile.am.m4
@@ -20,7 +20,6 @@ $1_TEST_LDADD = \
$(top_builddir)/paludis/environment/no_config/libpaludisnoconfigenvironment.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
- $(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(DYNAMIC_LD_LIBS) \
$(PCREPLUSPLUS_LIBS) \
@@ -67,7 +66,6 @@ if ! MONOLITHIC
libpaludisqa_la_LIBADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
- $(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(top_builddir)/paludis/environment/no_config/libpaludisnoconfigenvironment.la \
$(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
diff --git a/paludis/qa/metadata_check.cc b/paludis/qa/metadata_check.cc
index 36c90fc..f084ec0 100644
--- a/paludis/qa/metadata_check.cc
+++ b/paludis/qa/metadata_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
@@ -20,7 +20,6 @@
#include <ctime>
#include <fstream>
#include <paludis/qa/metadata_check.hh>
-#include <paludis/libxml/libxml.hh>
#include <paludis/util/pstream.hh>
#include <paludis/util/system.hh>
#include <paludis/util/log.hh>
@@ -82,22 +81,22 @@ MetadataCheck::operator() (const FSEntry & f) const
"' -- you should remove this file manually before continuing");
}
- LibXmlPtrHolder<xmlParserCtxtPtr> xml_parser_context(xmlNewParserCtxt(), &xmlFreeParserCtxt);
- LibXmlPtrHolder<xmlDtdPtr> xml_dtd(
+ std::tr1::shared_ptr<xmlParserCtxt> xml_parser_context(xmlNewParserCtxt(), &xmlFreeParserCtxt);
+ std::tr1::shared_ptr<xmlDtd> xml_dtd(
xmlParseDTD(0, reinterpret_cast<const xmlChar *>(stringify(dtd).c_str())), &xmlFreeDtd);
if (! xml_dtd)
result << Message(qal_major, "Unable to parse DTD '" + stringify(dtd) + "'");
else
{
- LibXmlPtrHolder<xmlDocPtr> xml_doc(xmlCtxtReadFile(
- xml_parser_context, stringify(f).c_str(), 0, XML_PARSE_NONET), &xmlFreeDoc);
+ std::tr1::shared_ptr<xmlDoc> xml_doc(xmlCtxtReadFile(
+ xml_parser_context.get(), stringify(f).c_str(), 0, XML_PARSE_NONET), &xmlFreeDoc);
if (! xml_doc)
result << Message(qal_major, "Unable to parse '" + stringify(f) + "'");
else
{
- LibXmlPtrHolder<xmlValidCtxtPtr> xml_valid_context(xmlNewValidCtxt(), &xmlFreeValidCtxt);
- if (! xmlValidateDtd(xml_valid_context, xml_doc, xml_dtd))
+ std::tr1::shared_ptr<xmlValidCtxt> xml_valid_context(xmlNewValidCtxt(), &xmlFreeValidCtxt);
+ if (! xmlValidateDtd(xml_valid_context.get(), xml_doc.get(), xml_dtd.get()))
result << Message(qal_major, "Validation of '" + stringify(f) + "' against '"
+ stringify(dtd) + "' failed");
}
diff --git a/paludis/qa/metadata_file.cc b/paludis/qa/metadata_file.cc
index f880a58..848a0b6 100644
--- a/paludis/qa/metadata_file.cc
+++ b/paludis/qa/metadata_file.cc
@@ -18,7 +18,6 @@
*/
#include "metadata_file.hh"
-#include <paludis/libxml/libxml.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
@@ -32,6 +31,21 @@
using namespace paludis;
using namespace paludis::qa;
+namespace
+{
+ std::string retarded_libxml_string_to_string(const xmlChar * const s)
+ {
+ return s ? stringify(reinterpret_cast<const char *>(s)) : "";
+ }
+
+ std::string normalise(const std::string & s)
+ {
+ std::list<std::string> words;
+ WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(words));
+ return join(words.begin(), words.end(), " ");
+ }
+}
+
namespace paludis
{
template<>
@@ -80,7 +94,7 @@ namespace paludis
MetadataFile::MetadataFile(const FSEntry & f) :
PrivateImplementationPattern<MetadataFile>(new Implementation<MetadataFile>)
{
- LibXmlPtrHolder<xmlDocPtr> xml_doc(xmlReadFile(stringify(f).c_str(), 0, 0), &xmlFreeDoc);
+ std::tr1::shared_ptr<xmlDoc> xml_doc(xmlReadFile(stringify(f).c_str(), 0, 0), &xmlFreeDoc);
if (! xml_doc)
{
Log::get_instance()->message(ll_warning, lc_no_context, "Couldn't parse xml file '" +
@@ -88,13 +102,13 @@ MetadataFile::MetadataFile(const FSEntry & f) :
return;
}
- _imp->handle_node(xml_doc, xmlDocGetRootElement(xml_doc));
+ _imp->handle_node(xml_doc.get(), xmlDocGetRootElement(xml_doc.get()));
}
MetadataFile::MetadataFile(const std::string & text) :
PrivateImplementationPattern<MetadataFile>(new Implementation<MetadataFile>)
{
- LibXmlPtrHolder<xmlDocPtr> xml_doc(xmlReadDoc(reinterpret_cast<const xmlChar *>(text.c_str()),
+ std::tr1::shared_ptr<xmlDoc> xml_doc(xmlReadDoc(reinterpret_cast<const xmlChar *>(text.c_str()),
"file:///var/empty/", 0, 0), &xmlFreeDoc);
if (! xml_doc)
{
@@ -102,7 +116,7 @@ MetadataFile::MetadataFile(const std::string & text) :
return;
}
- _imp->handle_node(xml_doc, xmlDocGetRootElement(xml_doc));
+ _imp->handle_node(xml_doc.get(), xmlDocGetRootElement(xml_doc.get()));
}
MetadataFile::MetadataFile(const MetadataFile & other) :
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 22e7850..225039c 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -104,7 +104,6 @@ if MONOLITHIC
portage_repository_TEST_LDADD = \
libpaludisportagerepository.la \
- $(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/paludis/libpaludis.la \
@@ -186,15 +185,13 @@ libpaludisportagerepositoryxmlthings_la_CXXFLAGS = $(AM_CXXFLAGS) @LIBXML2DEPS_C
if MONOLITHIC
libpaludisportagerepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \
- $(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(DYNAMIC_LD_LIBS)
else
libpaludisportagerepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \
$(top_builddir)/paludis/util/libpaludisutil.la \
- $(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/libxml/libpaludislibxml.la
+ $(top_builddir)/paludis/libpaludis.la
endif
@@ -215,7 +212,6 @@ xml_things_TEST_LDADD = \
$(top_builddir)/paludis/environment/test/libpaludistestenvironment.la \
$(top_builddir)/test/libtest.a \
$(top_builddir)/paludis/repositories/portage/libpaludisportagerepositoryxmlthings.la \
- $(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(DYNAMIC_LD_LIBS)
diff --git a/paludis/repositories/portage/xml_things.cc b/paludis/repositories/portage/xml_things.cc
index 624a46e..50ba256 100644
--- a/paludis/repositories/portage/xml_things.cc
+++ b/paludis/repositories/portage/xml_things.cc
@@ -21,9 +21,10 @@
#include <libxml/parser.h>
#include <paludis/repositories/portage/glsa.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/join.hh>
#include <paludis/config_file.hh>
-#include <paludis/libxml/libxml.hh>
#include <set>
+#include <list>
using namespace paludis;
@@ -34,6 +35,18 @@ extern "C"
namespace
{
+ std::string retarded_libxml_string_to_string(const xmlChar * const s)
+ {
+ return s ? stringify(reinterpret_cast<const char *>(s)) : "";
+ }
+
+ std::string normalise(const std::string & s)
+ {
+ std::list<std::string> words;
+ WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(words));
+ return join(words.begin(), words.end(), " ");
+ }
+
class Handler
{
private:
@@ -177,12 +190,12 @@ namespace
std::tr1::shared_ptr<GLSA>
create_glsa_from_xml_file(const std::string & filename)
{
- LibXmlPtrHolder<xmlDocPtr> xml_doc(xmlReadFile(filename.c_str(), 0, 0), &xmlFreeDoc);
+ std::tr1::shared_ptr<xmlDoc> xml_doc(xmlReadFile(filename.c_str(), 0, 0), &xmlFreeDoc);
if (! xml_doc)
throw GLSAError("Could not parse GLSA", filename);
Handler h;
- h.handle_node(xml_doc, xmlDocGetRootElement(xml_doc));
+ h.handle_node(xml_doc.get(), xmlDocGetRootElement(xml_doc.get()));
return h.glsa();
}