diff --git a/common/richio.cpp b/common/richio.cpp index 92a543f105..95183c499a 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -280,7 +280,7 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IO_ERRO } -std::string OUTPUTFORMATTER::Quoted( const std::string& aWrapee ) throw( IO_ERROR ) +std::string OUTPUTFORMATTER::Quotes( const std::string& aWrapee ) throw( IO_ERROR ) { static const char quoteThese[] = "\t ()\n\r"; @@ -329,6 +329,17 @@ std::string OUTPUTFORMATTER::Quoted( const std::string& aWrapee ) throw( IO_ERRO } +std::string OUTPUTFORMATTER::Quotew( const wxString& aWrapee ) throw( IO_ERROR ) +{ + // s-expressions atoms are always encoded as UTF-8. + // The non-virutal function calls the virtual workhorse function, and if + // a different quoting or escaping strategy is desired from the standard, + // a derived class can overload Quotes() above, but + // should never be a reason to overload this Quotew() here. + return Quotes( (const char*) aWrapee.utf8_str() ); +} + + //--------------------------------------------------------- void STRING_FORMATTER::write( const char* aOutBuf, int aCount ) throw( IO_ERROR ) diff --git a/common/xnode.cpp b/common/xnode.cpp index a89c6fb6a2..cb5e2f566a 100644 --- a/common/xnode.cpp +++ b/common/xnode.cpp @@ -34,7 +34,7 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) switch( GetType() ) { case wxXML_ELEMENT_NODE: - out->Print( nestLevel, "(%s", out->Quoted( GetName() ).c_str() ); + out->Print( nestLevel, "(%s", out->Quotew( GetName() ).c_str() ); FormatContents( out, nestLevel ); if( GetNext() ) out->Print( 0, ")\n" ); @@ -55,8 +55,8 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERRO { out->Print( 0, " (%s %s)", // attr names should never need quoting, no spaces, we designed the file. - out->Quoted( attr->GetName() ).c_str(), - out->Quoted( attr->GetValue() ).c_str() + out->Quotew( attr->GetName() ).c_str(), + out->Quotew( attr->GetValue() ).c_str() ); } @@ -82,7 +82,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERRO break; case wxXML_TEXT_NODE: - out->Print( 0, " %s", out->Quoted( GetContent() ).c_str() ); + out->Print( 0, " %s", out->Quotew( GetContent() ).c_str() ); break; default: diff --git a/eeschema/template_fieldnames.cpp b/eeschema/template_fieldnames.cpp index 780a64e404..bee3ebce1e 100644 --- a/eeschema/template_fieldnames.cpp +++ b/eeschema/template_fieldnames.cpp @@ -32,10 +32,10 @@ wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx ) void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ) { - out->Print( nestLevel, "(field (name %s)", out->Quoted( m_Name ).c_str() ); + out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() ); if( !m_Value.IsEmpty() ) - out->Print( 0, "(value %s)", out->Quoted( m_Value ).c_str() ); + out->Print( 0, "(value %s)", out->Quotew( m_Value ).c_str() ); if( m_Visible ) out->Print( 0, " visible" ); diff --git a/include/richio.h b/include/richio.h index 5f48571a98..1fea45f284 100644 --- a/include/richio.h +++ b/include/richio.h @@ -486,7 +486,7 @@ public: } /** - * Function Quoted + * Function Quotes * checks \a aWrapee input string for a need to be quoted * (e.g. contains a ')' character or a space), and for \" double quotes * within the string that need to be escaped such that the DSNLEXER @@ -500,13 +500,9 @@ public: * * @throw IO_ERROR, if there is any kind of problem with the input string. */ - virtual std::string Quoted( const std::string& aWrapee ) throw( IO_ERROR ); + virtual std::string Quotes( const std::string& aWrapee ) throw( IO_ERROR ); - std::string Quoted( const wxString& aWrapee ) throw( IO_ERROR ) - { - // s-expressions atoms are always encoded as UTF-8 - return Quoted( (const char*) aWrapee.utf8_str() ); - } + std::string Quotew( const wxString& aWrapee ) throw( IO_ERROR ); //---------------------------------------------- }; diff --git a/new/sch_lib_table.cpp b/new/sch_lib_table.cpp index c17ba2d698..d8dfdf030b 100644 --- a/new/sch_lib_table.cpp +++ b/new/sch_lib_table.cpp @@ -157,10 +157,10 @@ void LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ) { out->Print( nestLevel, "(lib (logical %s)(type %s)(full_uri %s)(options %s))\n", - out->Quoted( logicalName ).c_str(), - out->Quoted( libType ).c_str(), - out->Quoted( fullURI ).c_str(), - out->Quoted( options ).c_str() + out->Quotes( logicalName ).c_str(), + out->Quotes( libType ).c_str(), + out->Quotes( fullURI ).c_str(), + out->Quotes( options ).c_str() ); } diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 3421892c90..f4707f1803 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -134,7 +134,7 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, aFormatter->Print( aNestLevel+1, "(%s %d)\n", GetTokenName( T_scaleselection ), scaleSelection ); aFormatter->Print( aNestLevel+1, "(%s %s)\n", GetTokenName( T_outputdirectory ), - aFormatter->Quoted( CONV_TO_UTF8( outputDirectory ) ).c_str() ); + aFormatter->Quotew( outputDirectory ).c_str() ); aFormatter->Print( 0, ")\n" ); }