diff --git a/pub/src/file_out.cpp b/pub/src/file_out.cpp index c355cdcbc2b86242f0d3ebdec880da1286f41584..dfaad26e640692b702a3261202ea781cc326fdad 100644 --- a/pub/src/file_out.cpp +++ b/pub/src/file_out.cpp @@ -76,7 +76,7 @@ void NFileOut::Save_y08( FILE *file, POlo f ) { POld fd = P2D( f ); POlc fc = P2C( f ); - string out; + fprintf( file, "Meta:\n" " format: frida/y08 for yaml1\n" " type: %s\n", @@ -85,7 +85,6 @@ void NFileOut::Save_y08( FILE *file, POlo f ) fprintf( file, "History:\n" ); for ( uint i=0; i<f->lDoc.size(); i++ ) fprintf( file, "- %s\n", yaml(f->lDoc[i]).c_str() ); - fprintf( file, "- \%s\n", yaml( out ).c_str() ); fprintf( file, "Coord:\n" ); fprintf( file, " x:\n name: %s\n unit: %s\n", diff --git a/pub/src/mystd.cpp b/pub/src/mystd.cpp index f847e6ba9ae462cb379db7811a4c98b48dfc533b..10e28bb071f726a307a11d2702a9ec82f23ca0f0 100644 --- a/pub/src/mystd.cpp +++ b/pub/src/mystd.cpp @@ -75,21 +75,30 @@ string strg( char val ) string yaml( const string s ) // string -> yaml-output-string { + if ( s=="" ) + return "\"\""; string out = s; uint i = 0; // escape " while( i < out.size() ){ - if( out[i]=='"' && (i==0 || out[i-1]!='\\') ) + if( ( out[i]=='"' || out[i]=='\'' ) && (i==0 || out[i-1]!='\\') ) out.insert( i, "\\" ); ++i; } // if there are special characters, put "" around if( s.find( '"' )!=string::npos || + s.find( '\'' )!=string::npos || + s.find( '\\' )!=string::npos || s.find( ':' )!=string::npos || s.find( '*' )!=string::npos || s.find( '&' )!=string::npos || + s.find( '#' )!=string::npos || s.find( '>' )!=string::npos || - s.find( '<' )!=string::npos + s.find( '<' )!=string::npos || + s.find( '[' )!=string::npos || + s.find( ']' )!=string::npos || + s.find( '{' )!=string::npos || + s.find( '}' )!=string::npos ) out = '"' + out + '"'; return out;