From ae88d9467c69884fc53a2e7822b4cbd867f85cc2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 9 Jun 2010 13:54:08 +0000 Subject: [PATCH] Fixed reading of wrapped strings that contain multiple " within the string --- src/osgPlugins/osg/AsciiStreamOperator.h | 60 ++++++++++++++---------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/src/osgPlugins/osg/AsciiStreamOperator.h b/src/osgPlugins/osg/AsciiStreamOperator.h index 4eab77afc..c57b092c5 100644 --- a/src/osgPlugins/osg/AsciiStreamOperator.h +++ b/src/osgPlugins/osg/AsciiStreamOperator.h @@ -102,6 +102,8 @@ public: virtual void writeWrappedString( const std::string& str ) { + OSG_NOTICE<<"writeWrappedString( "<get( ch ); checkStream(); + + // skip white space + while ( ch==' ' ) { - if ( str.size()==1 || (*str.rbegin())!='\"' ) + _in->get( ch ); checkStream(); + } + + if (ch=='"') + { + // we have an "wrapped string" + _in->get( ch ); checkStream(); + while ( ch!='"' ) { - char ch; - do + if (ch=='\\') { _in->get( ch ); checkStream(); - if ( ch=='\\' ) - { - _in->get( ch ); checkStream(); - if ( ch=='\"' ) - { - str += ch; ch = 0; - } - else if ( ch=='\\' ) - { - str += ch; - } - else - { - str += '\\'; str += ch; - } - } - else - str += ch; - } while ( ch!='\"' ); + str += ch; + } + else str += ch; + + _in->get( ch ); checkStream(); + } + } + else + { + // we have an unwrapped string, read to first space or end of line + while ( (ch!=' ') && (ch!=0) && (ch!='\n') ) + { + str += ch; + _in->get( ch ); checkStream(); } - str = str.substr(1, str.size()-2); } } - + virtual bool matchString( const std::string& str ) { std::string s; readString(s);