From: <vac...@us...> - 2010-02-11 23:13:33
|
Revision: 168 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=168&view=rev Author: vaclavslavik Date: 2010-02-11 23:13:26 +0000 (Thu, 11 Feb 2010) Log Message: ----------- Fix compilation with Sun Studio. When not using -library=stlport4 option, the ancient standard library doesn't conform to the standard. In particular, it doesn't provide std::distance() with correct signature. Work around this by implementing it ourselves. Modified Paths: -------------- trunk/NEWS trunk/src/libxml/document.cxx trunk/src/libxml/node.cxx trunk/src/libxml/utility.h trunk/tests/document/test_document.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-02-11 23:12:20 UTC (rev 167) +++ trunk/NEWS 2010-02-11 23:13:26 UTC (rev 168) @@ -1,4 +1,6 @@ + Fixed compilation with Sun Studio compiler. + Version 0.6.2 Fixed xml::tree_parser to fail on non-fatal parser errors. Modified: trunk/src/libxml/document.cxx =================================================================== --- trunk/src/libxml/document.cxx 2010-02-11 23:12:20 UTC (rev 167) +++ trunk/src/libxml/document.cxx 2010-02-11 23:13:26 UTC (rev 168) @@ -335,7 +335,8 @@ document::size_type document::size() const { - return std::distance(begin(), end()); + using namespace std; + return distance(begin(), end()); } Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2010-02-11 23:12:20 UTC (rev 167) +++ trunk/src/libxml/node.cxx 2010-02-11 23:13:26 UTC (rev 168) @@ -519,7 +519,8 @@ node::size_type node::size() const { - return std::distance(begin(), end()); + using namespace std; + return distance(begin(), end()); } Modified: trunk/src/libxml/utility.h =================================================================== --- trunk/src/libxml/utility.h 2010-02-11 23:12:20 UTC (rev 167) +++ trunk/src/libxml/utility.h 2010-02-11 23:13:26 UTC (rev 168) @@ -33,6 +33,8 @@ #ifndef _xmlwrapp_utility_h_ #define _xmlwrapp_utility_h_ +#include <xmlwrapp/node.h> + // standard includes #include <string> #include <cstdarg> @@ -65,8 +67,21 @@ void printf2string(std::string& s, const char *message, va_list ap); +// Sun CC uses ancient C++ standard library that doesn't have standard +// std::distance(). Work around it here +#if defined(__SUNPRO_CC) && !defined(_STLPORT_VERSION) +inline size_t distance(xml::node::const_iterator a, xml::node::const_iterator b) +{ + size_t n = 0; + for ( ; a != b; ++a ) + ++n; + return n; +} +#endif // defined(__SUNPRO_CC) && !defined(_STLPORT_VERSION) + } // namespace impl } // namespace xml + #endif // _xmlwrapp_utility_h_ Modified: trunk/tests/document/test_document.cxx =================================================================== --- trunk/tests/document/test_document.cxx 2010-02-11 23:12:20 UTC (rev 167) +++ trunk/tests/document/test_document.cxx 2010-02-11 23:13:26 UTC (rev 168) @@ -413,6 +413,7 @@ } +#ifndef __SUNPRO_CC // SunCC can't compile gzip_decompressor BOOST_AUTO_TEST_CASE( save_to_file_gzip ) { xml::document doc("root"); @@ -432,6 +433,7 @@ remove(TEST_FILE); } +#endif // !__SUNPRO_CC BOOST_AUTO_TEST_SUITE_END() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |