cwText.h/cpp : Added removeTrailingWhitespace()
This commit is contained in:
parent
49b4a1430f
commit
05d0c316f4
24
cwText.cpp
24
cwText.cpp
@ -185,6 +185,30 @@ const char* cw::lastMatchChar( const char* s, char c )
|
||||
return lastMatchChar((char*)s,c);
|
||||
}
|
||||
|
||||
char* cw::removeTrailingWhitespace( char* s )
|
||||
{
|
||||
char* s0;
|
||||
unsigned sn;
|
||||
|
||||
if( s == nullptr )
|
||||
return nullptr;
|
||||
|
||||
if((sn = textLength(s)) == 0 )
|
||||
return s;
|
||||
|
||||
s0 = s + (sn-1);
|
||||
|
||||
for(; s0>=s; --s0)
|
||||
{
|
||||
if( !isspace(*s0) )
|
||||
break;
|
||||
*s0 = 0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
bool cw::isInteger( const char* s )
|
||||
{
|
||||
for(; *s; ++s)
|
||||
|
4
cwText.h
4
cwText.h
@ -70,7 +70,9 @@ namespace cw
|
||||
|
||||
// Find the last occurrent of 'c' in s[].
|
||||
char* lastMatchChar( char* s, char c );
|
||||
const char* lastMatchChar( const char* s, char c );
|
||||
const char* lastMatchChar( const char* s, char c );
|
||||
|
||||
char* removeTrailingWhitespace( char* s );
|
||||
|
||||
bool isInteger( const char* ); // text contains only [0-9]
|
||||
bool isReal( const char* ); // text contains only [0-9] with one decimal place
|
||||
|
Loading…
Reference in New Issue
Block a user