From f9428e9f4504d87b6104f5a9a3a0367efbb8d4d4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 26 Jan 2011 16:45:36 +0000 Subject: [PATCH] From Mathias Froehlich, build fix for Solaris --- include/osgDB/StreamOperator | 14 ++++++++++++++ src/osgPlugins/osg/AsciiStreamOperator.h | 2 +- src/osgPlugins/osg/XmlStreamOperator.h | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/osgDB/StreamOperator b/include/osgDB/StreamOperator index de3c1e516..f808d2d7d 100644 --- a/include/osgDB/StreamOperator +++ b/include/osgDB/StreamOperator @@ -44,6 +44,20 @@ public: virtual void flush() { _out->flush(); } protected: + // Return true if the manipulator is std::endl + bool isEndl( std::ostream& (*fn)(std::ostream&) ) + { +#ifdef __sun + // What a mess, but solaris does not like taking the address below + std::stringstream ss; + ss << fn; + std::string s = ss.str(); + return !s.empty() && s[0] == '\n'; +#else + return fn==static_cast(std::endl); +#endif + } + std::ostream* _out; }; diff --git a/src/osgPlugins/osg/AsciiStreamOperator.h b/src/osgPlugins/osg/AsciiStreamOperator.h index ddaa8d797..e9013f4e6 100644 --- a/src/osgPlugins/osg/AsciiStreamOperator.h +++ b/src/osgPlugins/osg/AsciiStreamOperator.h @@ -57,7 +57,7 @@ public: virtual void writeStream( std::ostream& (*fn)(std::ostream&) ) { indentIfRequired(); *_out << fn; - if ( fn==static_cast(std::endl) ) + if ( isEndl( fn ) ) { _readyForIndent = true; } diff --git a/src/osgPlugins/osg/XmlStreamOperator.h b/src/osgPlugins/osg/XmlStreamOperator.h index d45c019bb..8ecaacd56 100644 --- a/src/osgPlugins/osg/XmlStreamOperator.h +++ b/src/osgPlugins/osg/XmlStreamOperator.h @@ -66,10 +66,10 @@ public: virtual void writeString( const std::string& s ) { addToCurrentNode( s, true ); } - + virtual void writeStream( std::ostream& (*fn)(std::ostream&) ) { - if ( fn==static_cast(std::endl) ) + if ( isEndl( fn ) ) { if ( _readLineType==PROP_LINE || _readLineType==END_BRACKET_LINE ) {