cmText.h/c : Added cmTextLineCount().

This commit is contained in:
Kevin Larke 2016-04-17 17:28:38 -04:00
parent 9088a7bb22
commit 2945b1ac79
2 changed files with 31 additions and 0 deletions

View File

@ -798,6 +798,34 @@ cmChar_t* cmTextLine( cmChar_t* s, unsigned line )
const cmChar_t* cmTextLineC( const cmChar_t* s, unsigned line ) const cmChar_t* cmTextLineC( const cmChar_t* s, unsigned line )
{ return cmTextLine((cmChar_t*)s,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 ) cmChar_t* cmTextRemoveConsecutiveSpaces( cmChar_t* s )
{ {

View File

@ -234,6 +234,9 @@ extern "C" {
cmChar_t* cmTextLine( cmChar_t* s, unsigned line ); cmChar_t* cmTextLine( cmChar_t* s, unsigned line );
const cmChar_t* cmTextLineC( const 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. // Reduce all consecutive white spaces to a single space.
cmChar_t* cmTextRemoveConsecutiveSpaces( cmChar_t* s ); cmChar_t* cmTextRemoveConsecutiveSpaces( cmChar_t* s );