cmText.h/c : Added cmTextLastWhiteChar().

This commit is contained in:
kevin 2014-01-21 22:37:18 -05:00
parent 72a4c2f3dd
commit a4020934ee
2 changed files with 25 additions and 0 deletions

View File

@ -498,6 +498,26 @@ const cmChar_t* cmTextLastNonWhiteCharC( const cmChar_t* s )
{ return cmTextLastNonWhiteChar(s); } { return cmTextLastNonWhiteChar(s); }
cmChar_t* cmTextLastWhiteChar( const cmChar_t* s )
{
unsigned n;
if(s==NULL || (n = strlen(s)) == 0 )
return NULL;
cmChar_t* s0 = (cmChar_t*)s + n-1;
for(; s0>=s; --s0)
if( isspace(*s0) )
return s0;
return NULL;
}
const cmChar_t* cmTextLastWhiteCharC( const cmChar_t* s )
{ return cmTextLastWhiteChar(s); }
void cmTextShrinkS( cmChar_t* s, const cmChar_t* t, unsigned tn ) void cmTextShrinkS( cmChar_t* s, const cmChar_t* t, unsigned tn )
{ cmVOC_Shrink(s,strlen(s)+1,t,tn); } { cmVOC_Shrink(s,strlen(s)+1,t,tn); }

View File

@ -146,9 +146,14 @@ extern "C" {
const cmChar_t* cmTextEndOfLineC( const cmChar_t* s ); const cmChar_t* cmTextEndOfLineC( const cmChar_t* s );
// Return a pointer to the last non-white character in the string // Return a pointer to the last non-white character in the string
// or NULL if s is NULL or empty.
cmChar_t* cmTextLastNonWhiteChar( const cmChar_t* s ); cmChar_t* cmTextLastNonWhiteChar( const cmChar_t* s );
const cmChar_t* cmTextLastNonWhiteCharC( const cmChar_t* s ); const cmChar_t* cmTextLastNonWhiteCharC( const cmChar_t* s );
// Return a pointer to the last white character in the string
// or NULL if s is NULL or empty.
cmChar_t* cmTextLastWhiteChar( const cmChar_t* s );
const cmChar_t* cmTextLastWhiteCharC( const cmChar_t* s );