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 ) {