mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Update strcspn(3) to current coding conventions.
This commit is contained in:
parent
ba0d5b3a09
commit
8f30b923ee
1 changed files with 11 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2014.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -26,19 +26,23 @@
|
||||||
|
|
||||||
extern "C" size_t strcspn(const char* str, const char* reject)
|
extern "C" size_t strcspn(const char* str, const char* reject)
|
||||||
{
|
{
|
||||||
size_t rejectlen = 0;
|
size_t reject_length = 0;
|
||||||
while ( reject[rejectlen] ) { rejectlen++; }
|
while ( reject[reject_length] )
|
||||||
|
reject_length++;
|
||||||
for ( size_t result = 0; true; result++ )
|
for ( size_t result = 0; true; result++ )
|
||||||
{
|
{
|
||||||
char c = str[result];
|
char c = str[result];
|
||||||
if ( !c ) { return result; }
|
if ( !c )
|
||||||
|
return result;
|
||||||
bool matches = false;
|
bool matches = false;
|
||||||
for ( size_t i = 0; i < rejectlen; i++ )
|
for ( size_t i = 0; i < reject_length; i++ )
|
||||||
{
|
{
|
||||||
if ( str[result] != reject[i] ) { continue; }
|
if ( str[result] != reject[i] )
|
||||||
|
continue;
|
||||||
matches = true;
|
matches = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( matches ) { return result; }
|
if ( matches )
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue