StrPurge(), see mailing list

This commit is contained in:
Dick Hollenbeck
2011-01-15 23:11:17 -06:00
parent 6e119c2bb8
commit c4722e0f39
3 changed files with 23 additions and 15 deletions
+9 -10
View File
@@ -42,18 +42,17 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
*/
char* StrPurge( char* text )
{
char* ptspace;
const char whitespace[] = " \t\n\r\f\v";
if( text == NULL )
return NULL;
while( ( *text <= ' ' ) && *text )
text++;
ptspace = text + strlen( text ) - 1;
while( ( *ptspace <= ' ' ) && *ptspace && ( ptspace >= text ) )
if( text )
{
*ptspace = 0; ptspace--;
while( strchr( whitespace, *text ) )
++text;
char* cp = text + strlen( text ) - 1;
while( cp >= text && strchr( whitespace, *cp ) )
*cp-- = '\0';
}
return text;