Update wcsspn(3) to current coding conventions.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-09-24 21:24:52 +02:00
parent 7911b5c66c
commit 9d3bf0f164
1 changed files with 10 additions and 6 deletions

View File

@ -26,19 +26,23 @@
extern "C" size_t wcsspn(const wchar_t* str, const wchar_t* accept) extern "C" size_t wcsspn(const wchar_t* str, const wchar_t* accept)
{ {
size_t acceptlen = 0; size_t accept_length = 0;
while ( accept[acceptlen] ) { acceptlen++; } while ( accept[accept_length] )
accept_length++;
for ( size_t result = 0; true; result++ ) for ( size_t result = 0; true; result++ )
{ {
wchar_t c = str[result]; wchar_t c = str[result];
if ( !c ) { return result; } if ( !c )
return result;
bool matches = false; bool matches = false;
for ( size_t i = 0; i < acceptlen; i++ ) for ( size_t i = 0; i < accept_length; i++ )
{ {
if ( str[result] != accept[i] ) { continue; } if ( str[result] != accept[i] )
continue;
matches = true; matches = true;
break; break;
} }
if ( !matches ) { return result; } if ( !matches )
return result;
} }
} }