diff --git a/common/string.cpp b/common/string.cpp index ca630ada3d..39971d0562 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -13,10 +13,10 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize ) if( aDestSize <= 0 ) return 0; - bool inside = false; - char* start = aDest; - char* limit = aDest + aDestSize - 1; - char cc; + bool inside = false; + const char* start = aSource; + char* limit = aDest + aDestSize - 1; + char cc; while( (cc = *aSource++) != 0 && aDest < limit ) { @@ -48,7 +48,7 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize ) *aDest = 0; - return aDest - start; + return aSource - start; } diff --git a/include/kicad_string.h b/include/kicad_string.h index efbefc53ee..8e90fb5e04 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -24,7 +24,8 @@ char* strlower( char* Text ); * @param aDest is the destination byte buffer. * @param aSource is the source bytes as a C string. * @param aDestSize is the size of the destination byte buffer. - * @return int - the number of bytes extracted. + * @return int - the number of bytes read from source, which may be more than + * the number copied, due to escaping of double quotes and the escape byte itself. */ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize );