public: simplify Q_colorstr and Q_strnlwr
This commit is contained in:
parent
bb6e2d6885
commit
844af709c0
1 changed files with 10 additions and 17 deletions
|
@ -25,36 +25,29 @@ GNU General Public License for more details.
|
||||||
|
|
||||||
void Q_strnlwr( const char *in, char *out, size_t size_out )
|
void Q_strnlwr( const char *in, char *out, size_t size_out )
|
||||||
{
|
{
|
||||||
if( size_out == 0 ) return;
|
size_t len, i;
|
||||||
|
|
||||||
while( *in && size_out > 1 )
|
len = Q_strncpy( out, in, size_out );
|
||||||
{
|
|
||||||
if( *in >= 'A' && *in <= 'Z' )
|
for( i = 0; i < len; i++ )
|
||||||
*out++ = *in++ + 'a' - 'A';
|
out[i] = Q_tolower( out[i] );
|
||||||
else *out++ = *in++;
|
|
||||||
size_out--;
|
|
||||||
}
|
|
||||||
*out = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Q_colorstr( const char *string )
|
size_t Q_colorstr( const char *string )
|
||||||
{
|
{
|
||||||
size_t len;
|
const char *p = string;
|
||||||
const char *p;
|
size_t len = 0;
|
||||||
|
|
||||||
if( !string ) return 0;
|
if( !string )
|
||||||
|
return len;
|
||||||
|
|
||||||
len = 0;
|
while(( p = Q_strchr( p, '^' )))
|
||||||
p = string;
|
|
||||||
while( *p )
|
|
||||||
{
|
{
|
||||||
if( IsColorString( p ))
|
if( IsColorString( p ))
|
||||||
{
|
{
|
||||||
len += 2;
|
len += 2;
|
||||||
p += 2;
|
p += 2;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|
Loading…
Add table
Reference in a new issue