Fix GPL boilerplate. Add locked_sstream dependency. Remove
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Jul 2016 08:17:06 +0000 (09:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Jul 2016 08:17:06 +0000 (09:17 +0100)
Document::read_stream; improve Document::read_string efficiency.
Use locked_stringstream instead of plain one to try to fix
DCP-o-matic crashes on OS X.

cscript
src/cxml.cc
src/cxml.h
src/wscript
test/tests.cc
test/wscript
wscript

diff --git a/cscript b/cscript
index 7857c40b1719c29431e7e0b41a7ad29daa36c31d..a95e66811a4b0e8e0d4fbcc4e12c1833b8012606 100644 (file)
--- a/cscript
+++ b/cscript
@@ -1,5 +1,28 @@
+# -*- mode: python -*-
+#
+#    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+#
+#    This file is part of libcxml.
+#
+#    libcxml is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    libcxml 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 libcxml.  If not, see <http://www.gnu.org/licenses/>.
+#
+
 import os
 
+def dependencies(target):
+    return (('locked_sstream', None))
+
 def build(target, options):
     cmd = './waf configure --prefix=%s' % target.directory
     if target.platform == 'linux':
index 567dc503d53f4f7b200c2f6c9ebf8863bfd7ef64..3248324bb8b8c6e69e0e9d864182e508e4f02145 100644 (file)
@@ -1,32 +1,29 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of libcxml.
+
+    libcxml is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    libcxml 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with libcxml.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
-#include <sstream>
-#include <iostream>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
 #include <libxml++/libxml++.h>
 #include "cxml.h"
 
 using std::string;
-using std::stringstream;
-using std::istream;
 using std::list;
 using boost::shared_ptr;
 using boost::optional;
@@ -264,18 +261,10 @@ cxml::Document::read_file (boost::filesystem::path file)
        take_root_node ();
 }
 
-void
-cxml::Document::read_stream (istream& stream)
-{
-       _parser->parse_stream (stream);
-       take_root_node ();
-}
-
 void
 cxml::Document::read_string (string s)
 {
-       stringstream t (s);
-       _parser->parse_stream (t);
+       _parser->parse_memory (s);
        take_root_node ();
 }
 
index bb1179b98b10c6a24634f5e4fc6a6cffe47637ef..2636ca093ceed762b20f6e9b79f841b17e96b50e 100644 (file)
@@ -1,32 +1,33 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of libcxml.
+
+    libcxml is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    libcxml 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with libcxml.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
 #ifndef LIBCXML_CXML_H
 #define LIBCXML_CXML_H
 
+#include <locked_sstream.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/optional.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string/erase.hpp>
 #include <stdint.h>
 #include <string>
-#include <sstream>
 #include <list>
 
 /* Hack for OS X compile failure; see https://bugs.launchpad.net/hugin/+bug/910160 */
@@ -112,7 +113,7 @@ public:
        {
                std::string s = string_child (c);
                boost::erase_all (s, " ");
-               std::stringstream t;
+               locked_stringstream t;
                t.imbue (std::locale::classic ());
                t << s;
                T n;
@@ -130,7 +131,7 @@ public:
 
                std::string t = s.get ();
                boost::erase_all (t, " ");
-               std::stringstream u;
+               locked_stringstream u;
                u.imbue (std::locale::classic ());
                u << t;
                T n;
@@ -161,7 +162,7 @@ public:
        {
                std::string s = string_attribute (c);
                boost::erase_all (s, " ");
-               std::stringstream t;
+               locked_stringstream t;
                t.imbue (std::locale::classic ());
                t << s;
                T n;
@@ -179,7 +180,7 @@ public:
 
                std::string t = s.get ();
                boost::erase_all (t, " ");
-               std::stringstream u;
+               locked_stringstream u;
                u.imbue (std::locale::classic ());
                u << t;
                T n;
@@ -225,7 +226,6 @@ public:
        virtual ~Document ();
 
        void read_file (boost::filesystem::path);
-       void read_stream (std::istream &);
        void read_string (std::string);
 
        std::string root_name () const {
index 1d5c3f30e5fa65e09a8cae6e10d96f87d87abdf5..5d24f84a4248ccfb4f68624d5711990f7a6bbd84 100644 (file)
@@ -1,3 +1,23 @@
+# -*- mode: python -*-
+#
+#    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+#
+#    This file is part of libcxml.
+#
+#    libcxml is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    libcxml 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 libcxml.  If not, see <http://www.gnu.org/licenses/>.
+#
+
 def build(bld):
     if bld.env.STATIC:
         obj = bld(features='cxx cxxstlib')
@@ -13,4 +33,3 @@ def build(bld):
     bld.install_files('${PREFIX}/include/libcxml', "cxml.h")
     if bld.env.STATIC:
         bld.install_files('${PREFIX}/lib', 'libcxml.a')
-
index 9d07e7c19a7e6be7772327f344b4d317d6abb01c..ad5cc724fc22f5cec7f708d1a198a164a9c42fd6 100644 (file)
@@ -1,23 +1,23 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of libcxml.
+
+    libcxml is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    libcxml 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with libcxml.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
-#include <iostream>
 #include <cmath>
 #include <boost/filesystem.hpp>
 #include <libxml++/libxml++.h>
@@ -28,7 +28,6 @@
 #include <boost/test/unit_test.hpp>
 
 using std::string;
-using std::cout;
 using std::vector;
 using std::list;
 using boost::shared_ptr;
index 7133792b331dff8c587026e7512f97c07a37ce21..ecf4d47643cc918093e7efd638465b11944b8d00 100644 (file)
@@ -1,3 +1,23 @@
+# -*- mode: python -*-
+#
+#    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+#
+#    This file is part of libcxml.
+#
+#    libcxml is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    libcxml 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 libcxml.  If not, see <http://www.gnu.org/licenses/>.
+#
+
 def configure(conf):
     conf.env.prepend_value('LINKFLAGS', '-Lsrc')
 
diff --git a/wscript b/wscript
index 94a20c040a52ea5c3ecc69775dd80543c8fb968b..2c5f3898ac3501e7179f2bb69fcbf85b456566ff 100644 (file)
--- a/wscript
+++ b/wscript
@@ -1,3 +1,23 @@
+# -*- mode: python -*-
+#
+#    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+#
+#    This file is part of libcxml.
+#
+#    libcxml is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    libcxml 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 libcxml.  If not, see <http://www.gnu.org/licenses/>.
+#
+
 from waflib import Context
 
 APPNAME = 'libcxml'
@@ -53,7 +73,7 @@ def configure(conf):
     v = (int(s[0]) << 16) | (int(s[1]) << 8) | int(s[2])
     if v >= 0x022701:
         conf.env.append_value('CXXFLAGS', '-std=c++11')
-        
+
 def build(bld):
 
     bld(source='libcxml.pc.in',