From b08e6b4c723efef245903caca49c2dafb11f8722 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 22 Jul 2016 09:17:06 +0100 Subject: [PATCH] Fix GPL boilerplate. Add locked_sstream dependency. Remove 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 | 23 +++++++++++++++++++++++ src/cxml.cc | 25 +++++++------------------ src/cxml.h | 22 +++++++++++----------- src/wscript | 21 ++++++++++++++++++++- test/tests.cc | 13 ++++++------- test/wscript | 20 ++++++++++++++++++++ wscript | 22 +++++++++++++++++++++- 7 files changed, 108 insertions(+), 38 deletions(-) diff --git a/cscript b/cscript index 7857c40..a95e668 100644 --- a/cscript +++ b/cscript @@ -1,5 +1,28 @@ +# -*- mode: python -*- +# +# Copyright (C) 2016 Carl Hetherington +# +# 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 . +# + import os +def dependencies(target): + return (('locked_sstream', None)) + def build(target, options): cmd = './waf configure --prefix=%s' % target.directory if target.platform == 'linux': diff --git a/src/cxml.cc b/src/cxml.cc index 567dc50..3248324 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -1,32 +1,29 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington - 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 . */ -#include -#include #include #include #include #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 (); } diff --git a/src/cxml.h b/src/cxml.h index bb1179b..2636ca0 100644 --- a/src/cxml.h +++ b/src/cxml.h @@ -1,32 +1,33 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington - 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 . */ #ifndef LIBCXML_CXML_H #define LIBCXML_CXML_H +#include #include #include #include #include #include #include -#include #include /* 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 { diff --git a/src/wscript b/src/wscript index 1d5c3f3..5d24f84 100644 --- a/src/wscript +++ b/src/wscript @@ -1,3 +1,23 @@ +# -*- mode: python -*- +# +# Copyright (C) 2016 Carl Hetherington +# +# 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 . +# + 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') - diff --git a/test/tests.cc b/test/tests.cc index 9d07e7c..ad5cc72 100644 --- a/test/tests.cc +++ b/test/tests.cc @@ -1,23 +1,23 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington - 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 . */ -#include #include #include #include @@ -28,7 +28,6 @@ #include using std::string; -using std::cout; using std::vector; using std::list; using boost::shared_ptr; diff --git a/test/wscript b/test/wscript index 7133792..ecf4d47 100644 --- a/test/wscript +++ b/test/wscript @@ -1,3 +1,23 @@ +# -*- mode: python -*- +# +# Copyright (C) 2016 Carl Hetherington +# +# 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 . +# + def configure(conf): conf.env.prepend_value('LINKFLAGS', '-Lsrc') diff --git a/wscript b/wscript index 94a20c0..2c5f389 100644 --- a/wscript +++ b/wscript @@ -1,3 +1,23 @@ +# -*- mode: python -*- +# +# Copyright (C) 2016 Carl Hetherington +# +# 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 . +# + 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', -- 2.30.2