From 3e25a2a2f1fb881debade053d4862f094614e24a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 25 Jul 2018 21:31:27 +0200 Subject: Remove obsolete SAXParser class and eXpat dependency. --- README | 5 +- configure.ac | 25 --------- drumgizmo/drumgizmoc.cc | 1 + plugin/Makefile.mingw32.in | Bin 6048 -> 5934 bytes plugingui/Makefile.am | 1 - src/Makefile.am | 8 +-- src/saxparser.cc | 132 --------------------------------------------- src/saxparser.h | 65 ---------------------- test/dgreftest/Makefile.am | 2 +- 9 files changed, 5 insertions(+), 234 deletions(-) delete mode 100644 src/saxparser.cc delete mode 100644 src/saxparser.h diff --git a/README b/README index 1b4e8a4..d4201fc 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ documentation for detailed instructions on how to do this. NOTE2: Be aware that if you are planning on running the LV2 plugin from within one of the binary releases of Ardour, you must make sure that drumgizmo is using -the same version of libpng, pthread and expat as Ardour was compiled with (or +the same version of pthread as Ardour was compiled with (or at least versions matching the ABI), otherwise the plugin will show strange behaviour or even crash upon load. @@ -22,13 +22,10 @@ Prerequisites * lv2-devel package >= 1.0 * libsndfile-devel >= 1.0.21 * zita-resampler-devel (no minimal version specified) -* libexpat-devel (no minimal version specified) * pkg-config >= 0.23 * Xlib >= 1.0 -* libpng >= 1.2 * libsmf (no minimal version specified) * pthread (no minimal version specified) -* libcppunit-dev (only necessary when compiling from git sources) Compiling source tarball ------------------------ diff --git a/configure.ac b/configure.ac index 0a671e6..6b4593c 100644 --- a/configure.ac +++ b/configure.ac @@ -605,31 +605,6 @@ AS_CASE([$host_os], AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_LIBS) -dnl ====================== -dnl Check for eXpat library -dnl ====================== -tmp_CXXFLAGS="$CXXFLAGS" -tmp_CPPFLAGS="$CPPFLAGS" -tmp_CFLAGS="$CFLAGS" -tmp_LDFLAGS="$LDFLAGS" -tmp_LIBS="$LIBS" -CXXFLAGS="" -CPPFLAGS="" -CFLAGS="$EXPAT_CFLAGS" -LDFLAGS="$EXPAT_LDFLAGS" -LIBS="" -AC_CHECK_HEADER(expat.h, , AC_MSG_ERROR([*** eXpat header file not found!])) -AC_CHECK_LIB(expat, XML_ParserCreate, , AC_MSG_ERROR([*** eXpat library not found!])) -EXPAT_CFLAGS="$CXXFLAGS $CPPFLAGS $CFLAGS" -EXPAT_LIBS="$LDFLAGS $LIBS" -CXXFLAGS="$tmp_CXXFLAGS" -CPPFLAGS="$tmp_CPPFLAGS" -CFLAGS="$tmp_CFLAGS" -LDFLAGS="$tmp_LDFLAGS" -LIBS="$tmp_LIBS" -AC_SUBST(EXPAT_CFLAGS) -AC_SUBST(EXPAT_LIBS) - dnl =========================== dnl Check for SSE instructions dnl =========================== diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index 0c3e190..42a5d9a 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -30,6 +30,7 @@ #include #include +#include #include #include #include diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in index 249ee52..df2dad3 100644 Binary files a/plugin/Makefile.mingw32.in and b/plugin/Makefile.mingw32.in differ diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index c726088..4da8ce9 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -164,7 +164,6 @@ plugingui_CXXFLAGS = \ $(GUI_CPPFLAGS) \ $(SNDFILE_CXXFLAGS) \ $(PTHREAD_CFLAGS) \ - $(EXPAT_CFLAGS) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ -I$(top_srcdir)/hugin diff --git a/src/Makefile.am b/src/Makefile.am index 14da4d6..3ecdc76 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,12 +4,10 @@ libdg_la_CPPFLAGS = \ -I$(top_srcdir)/include -I$(top_srcdir)/hugin \ -I$(top_srcdir)/hugin -I$(top_srcdir)/pugixml/src \ $(SSEFLAGS) \ - $(ZITA_CPPFLAGS) $(SNDFILE_CFLAGS) $(EXPAT_CFLAGS) \ - $(PTHREAD_CFLAGS) + $(ZITA_CPPFLAGS) $(SNDFILE_CFLAGS) $(PTHREAD_CFLAGS) libdg_la_LIBADD = \ - $(ZITA_LIBS) $(SNDFILE_LIBS) $(EXPAT_LIBS) \ - $(PTHREAD_LIBS) + $(ZITA_LIBS) $(SNDFILE_LIBS) $(PTHREAD_LIBS) # If you add a file here, remember to add it to plugin/Makefile.mingw32.in nodist_libdg_la_SOURCES = \ @@ -41,7 +39,6 @@ nodist_libdg_la_SOURCES = \ random.cc \ sample.cc \ semaphore.cc \ - saxparser.cc \ staminafilter.cc \ thread.cc \ versionstr.cc @@ -85,7 +82,6 @@ EXTRA_DIST = \ random.h \ rangemap.h \ sample.h \ - saxparser.h \ semaphore.h \ settings.h \ staminafilter.h \ diff --git a/src/saxparser.cc b/src/saxparser.cc deleted file mode 100644 index 280e608..0000000 --- a/src/saxparser.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * saxparser.cc - * - * Tue Jul 22 16:26:22 CEST 2008 - * Copyright 2008 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of DrumGizmo. - * - * DrumGizmo is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DrumGizmo 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with DrumGizmo; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include "saxparser.h" - -#include -#include - -#include - -SAXParser::SAXParser() -{ - parser = XML_ParserCreate(nullptr); - if(!parser) - { - ERR(sax, "Couldn't allocate memory for parser\n"); - // throw Exception(...); TODO - return; - } - - XML_SetUserData(parser, this); - XML_UseParserAsHandlerArg(parser); - XML_SetElementHandler(parser, SAXParser::startHandler, SAXParser::endHandler); - XML_SetCharacterDataHandler(parser, SAXParser::characterHandler); -} - -SAXParser::~SAXParser() -{ - XML_ParserFree(parser); -} - -int SAXParser::parseFile(const std::string& filename) -{ - if(filename.empty()) - { - return 0; - } - - std::ifstream file(filename, std::ifstream::in); - - if(!file.is_open()) - { - return 1; - } - - std::stringstream ss; - ss << file.rdbuf(); - std::string str = ss.str(); - - return parseString(str, filename); -} - -int SAXParser::parseString(const std::string& str, - const std::string& xml_source_name) -{ - DEBUG(sax, "parse(buffer %d bytes)\n", (int)str.length()); - - if(!XML_Parse(parser, str.c_str(), str.length(), true)) - { - parseError(str, XML_ErrorString(XML_GetErrorCode(parser)), - xml_source_name, (int)XML_GetCurrentLineNumber(parser)); - return 1; - } - - return 0; -} - -void SAXParser::parseError(const std::string& buf, const std::string& error, - const std::string& xml_source_name, - std::size_t lineno) -{ - std::cerr << "SAXParser error trying to parse from source: " << - xml_source_name << "\n"; - std::cerr << "At line " << lineno << ": " << error << "\n"; - std::cerr << "Buffer " << buf.size() << " bytes: \n[\n"; - std::cerr << buf; - std::cerr << "\n]" << std::endl; -} - -void SAXParser::characterHandler(void* parser, const XML_Char* cData, int len) -{ - SAXParser* sax_parser = (SAXParser*)XML_GetUserData(parser); - std::string chars(cData, len); - sax_parser->characterData(chars); -} - -void SAXParser::startHandler(void* parser, const char* el, const char** attr) -{ - SAXParser* sax_parser = (SAXParser*)XML_GetUserData(parser); - - // Convert to comfy C++ values... - attr_t attributes; - - while(*attr) - { - std::string at_name = *attr++; - std::string at_value = *attr++; - - attributes.emplace(at_name, at_value); - } - - sax_parser->startTag(std::string(el), attributes); -} - -void SAXParser::endHandler(void* parser, const char* el) -{ - SAXParser* sax_parser = (SAXParser*)XML_GetUserData(parser); - sax_parser->endTag(std::string(el)); -} diff --git a/src/saxparser.h b/src/saxparser.h deleted file mode 100644 index 4b1a273..0000000 --- a/src/saxparser.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * saxparser.h - * - * Tue Jul 22 16:26:21 CEST 2008 - * Copyright 2008 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of DrumGizmo. - * - * DrumGizmo is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DrumGizmo 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with DrumGizmo; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#pragma once - -#include -#include -#include -#include - -class SAXParser -{ -public: - SAXParser(); - virtual ~SAXParser(); - - //! Parses the data from the file. - virtual int parseFile(const std::string& filename); - - //! Parses all the data in the buffer. - virtual int parseString(const std::string& str, - const std::string& xml_source_name = ""); - -protected: - using attr_t = std::unordered_map; - - virtual void characterData(const std::string& data) {} - virtual void startTag(const std::string& name, const attr_t& attr) {} - virtual void endTag(const std::string& name) {} - virtual void parseError(const std::string& buf, - const std::string& error, - const std::string& xml_source_name, - std::size_t lineno); - -private: - XML_Parser parser; - std::string filename; - - static void characterHandler(void* parser, const XML_Char* cData, int len); - static void startHandler(void* parser, const char* el, const char** attr); - static void endHandler(void* parser, const char* el); -}; diff --git a/test/dgreftest/Makefile.am b/test/dgreftest/Makefile.am index 07b324d..3884250 100644 --- a/test/dgreftest/Makefile.am +++ b/test/dgreftest/Makefile.am @@ -8,7 +8,7 @@ dgreftest_LDADD = $(PTHREAD_LIBS) $(JACK_LIBS) \ dgreftest_LDFLAGS = -dgreftest_CXXFLAGS = $(SNDFILE_CXXFLAGS) $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) \ +dgreftest_CXXFLAGS = $(SNDFILE_CXXFLAGS) $(PTHREAD_CFLAGS) \ -I$(top_srcdir)/include -I$(top_srcdir)/src \ -I$(top_srcdir)/hugin -DWITH_HUG_MUTEX -DWITH_HUG_FILTER \ $(JACK_CFLAGS) $(SSEFLAGS) $(SMF_CFLAGS) $(FLOAT_STORE) -- cgit v1.2.3