From 5f0679bf6e3ca4dc9f24713c0cf083b3450b3799 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 26 Sep 2013 10:02:46 -0500 Subject: [PATCH] comment/doc cleanups --- common/richio.cpp | 6 +++--- include/richio.h | 45 +++++++++++++++++------------------------ pcbnew/kicad_plugin.cpp | 20 +++++++++--------- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/common/richio.cpp b/common/richio.cpp index 08b3ffcfad..5ce7ed2af3 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -40,7 +40,7 @@ -int vprint( std::string* result, const char* format, va_list ap ) +static int vprint( std::string* result, const char* format, va_list ap ) { char msg[512]; size_t len = vsnprintf( msg, sizeof(msg), format, ap ); @@ -67,7 +67,7 @@ int vprint( std::string* result, const char* format, va_list ap ) } -int strprintf( std::string* result, const char* format, ... ) +int StrPrintf( std::string* result, const char* format, ... ) { va_list args; @@ -79,7 +79,7 @@ int strprintf( std::string* result, const char* format, ... ) } -std::string strprintf( const char* format, ... ) +std::string StrPrintf( const char* format, ... ) { std::string ret; va_list args; diff --git a/include/richio.h b/include/richio.h index 17d3851793..675c747772 100644 --- a/include/richio.h +++ b/include/richio.h @@ -39,41 +39,34 @@ /** - * Function vprint - * is like vsprintf() but the output is appended to a std::string instead of to a - * character array. - * @param result is the string to append to, previous text is not clear()ed. - * @param format is a printf() style format string. - * @param ap is a va_list argument stack pointer which gives the - * modifying data for the format string. - */ -int vprint( std::string* result, const char* format, va_list ap ); - - -/** - * Function strprintf + * Function StrPrintf * is like sprintf() but the output is appended to a std::string instead of to a * character array. - * @param result is the string to append to, previous text is not clear()ed. - * @param format is a printf() style format string. - * @param ap is a va_list argument stack pointer which gives the - * modifying data for the format string. - * - * @return int - the count of bytes appended to the result string, no terminating nul is included. + * @param aResult is the string to append to, previous text is not clear()ed. + * @param aFormat is a printf() style format string. + * @return int - the count of bytes appended to the result string, no terminating + * nul is included. */ -int strprintf( std::string* result, const char* format, ... ); +int +#if defined(__GNUG__) + __attribute__ ((format (printf, 2, 3))) +#endif + StrPrintf( std::string* aResult, const char* aFormat, ... ); /** - * Function strprintf + * Function StrPrintf * is like sprintf() but the output is returned in a std::string instead of to a * character array. - * @param result is the string to append to, previous text is not clear()ed. - * @param format is a printf() style format string. - * @param ap is a va_list argument stack pointer which gives the - * modifying data for the format string. + * @param aResult is the string to append to, previous text is not clear()ed. + * @param aFormat is a printf() style format string. + * @return std::string - the result of the sprintf(). */ -std::string strprintf( const char* format, ... ); +std::string +#if defined(__GNUG__) + __attribute__ ((format (printf, 1, 2))) +#endif + StrPrintf( const char* format, ... ); /** diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 98af5080f2..0993d1c16a 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1215,37 +1215,37 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const // Unconnected pad is default net so don't save it. if( !(m_ctl & CTL_OMIT_NETS) && aPad->GetNet() != 0 ) - strprintf( &output, " (net %d %s)", aPad->GetNet(), m_out->Quotew( aPad->GetNetname() ).c_str() ); + StrPrintf( &output, " (net %d %s)", aPad->GetNet(), m_out->Quotew( aPad->GetNetname() ).c_str() ); if( aPad->GetPadToDieLength() != 0 ) - strprintf( &output, " (die_length %s)", FMT_IU( aPad->GetPadToDieLength() ).c_str() ); + StrPrintf( &output, " (die_length %s)", FMT_IU( aPad->GetPadToDieLength() ).c_str() ); if( aPad->GetLocalSolderMaskMargin() != 0 ) - strprintf( &output, " (solder_mask_margin %s)", FMT_IU( aPad->GetLocalSolderMaskMargin() ).c_str() ); + StrPrintf( &output, " (solder_mask_margin %s)", FMT_IU( aPad->GetLocalSolderMaskMargin() ).c_str() ); if( aPad->GetLocalSolderPasteMargin() != 0 ) - strprintf( &output, " (solder_paste_margin %s)", FMT_IU( aPad->GetLocalSolderPasteMargin() ).c_str() ); + StrPrintf( &output, " (solder_paste_margin %s)", FMT_IU( aPad->GetLocalSolderPasteMargin() ).c_str() ); if( aPad->GetLocalSolderPasteMarginRatio() != 0 ) - strprintf( &output, " (solder_paste_margin_ratio %s)", + StrPrintf( &output, " (solder_paste_margin_ratio %s)", Double2Str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() ); if( aPad->GetLocalClearance() != 0 ) - strprintf( &output, " (clearance %s)", FMT_IU( aPad->GetLocalClearance() ).c_str() ); + StrPrintf( &output, " (clearance %s)", FMT_IU( aPad->GetLocalClearance() ).c_str() ); if( aPad->GetZoneConnection() != UNDEFINED_CONNECTION ) - strprintf( &output, " (zone_connect %d)", aPad->GetZoneConnection() ); + StrPrintf( &output, " (zone_connect %d)", aPad->GetZoneConnection() ); if( aPad->GetThermalWidth() != 0 ) - strprintf( &output, " (thermal_width %s)", FMT_IU( aPad->GetThermalWidth() ).c_str() ); + StrPrintf( &output, " (thermal_width %s)", FMT_IU( aPad->GetThermalWidth() ).c_str() ); if( aPad->GetThermalGap() != 0 ) - strprintf( &output, " (thermal_gap %s)", FMT_IU( aPad->GetThermalGap() ).c_str() ); + StrPrintf( &output, " (thermal_gap %s)", FMT_IU( aPad->GetThermalGap() ).c_str() ); if( output.size() ) { m_out->Print( 0, "\n" ); - m_out->Print( aNestLevel+1, "%s", output.c_str() + 1 ); // +1 skips initial space on first element + m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element } m_out->Print( 0, ")\n" );