cmText.h/c : Added cmTextLineCount().
This commit is contained in:
parent
9088a7bb22
commit
2945b1ac79
28
cmText.c
28
cmText.c
@ -798,6 +798,34 @@ cmChar_t* cmTextLine( cmChar_t* s, unsigned line )
|
||||
const cmChar_t* cmTextLineC( const cmChar_t* s, unsigned line )
|
||||
{ return cmTextLine((cmChar_t*)s,line); }
|
||||
|
||||
unsigned cmTextLineCount( const cmChar_t* s )
|
||||
{
|
||||
unsigned n = *s ? 1 : 0;
|
||||
|
||||
while( *s )
|
||||
{
|
||||
s = cmTextEndOfLineC(s);
|
||||
|
||||
switch( *s )
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
s += 1;
|
||||
n += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
{ assert(0); }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return n;
|
||||
|
||||
}
|
||||
|
||||
|
||||
cmChar_t* cmTextRemoveConsecutiveSpaces( cmChar_t* s )
|
||||
{
|
||||
|
3
cmText.h
3
cmText.h
@ -234,6 +234,9 @@ extern "C" {
|
||||
cmChar_t* cmTextLine( cmChar_t* s, unsigned line );
|
||||
const cmChar_t* cmTextLineC( const cmChar_t* s, unsigned line );
|
||||
|
||||
// Return the count of lines begining with s.
|
||||
unsigned cmTextLineCount( const cmChar_t* s );
|
||||
|
||||
// Reduce all consecutive white spaces to a single space.
|
||||
cmChar_t* cmTextRemoveConsecutiveSpaces( cmChar_t* s );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user