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);
|
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 )
|
bool cw::isInteger( const char* s )
|
||||||
{
|
{
|
||||||
for(; *s; ++s)
|
for(; *s; ++s)
|
||||||
|
2
cwText.h
2
cwText.h
@ -72,6 +72,8 @@ namespace cw
|
|||||||
char* lastMatchChar( char* s, char c );
|
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 isInteger( const char* ); // text contains only [0-9]
|
||||||
bool isReal( const char* ); // text contains only [0-9] with one decimal place
|
bool isReal( const char* ); // text contains only [0-9] with one decimal place
|
||||||
bool isIdentifier( const char* ); // text is a legal id [0-9,A-Z,a-z,_] w/o leading number
|
bool isIdentifier( const char* ); // text is a legal id [0-9,A-Z,a-z,_] w/o leading number
|
||||||
|
Loading…
Reference in New Issue
Block a user