add strcspn implementation.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@533 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2010-03-24 07:51:53 +00:00
parent bc013f8a83
commit 781fd25bc9
2 changed files with 18 additions and 0 deletions

View File

@ -564,6 +564,21 @@ size_t strspn(const char *s, const char *accept)
return l;
}
size_t strcspn(const char *s, const char *reject)
{
size_t l=0;
int a=1,i,al=strlen(reject);
while((a)&&(*s))
{
for(i=0;(a)&&(i<al);i++)
if (*s==reject[i]) a=0;
if (a) l++;
s++;
}
return l;
}
char*strtok_r(char*s,const char*delim,char**ptrptr)
{
char*tmp=0;

View File

@ -70,6 +70,9 @@ char *strdup(const char *s);
char *strtok(char *s, const char *delim);
char*strtok_r(char*s, const char*delim, char**ptrptr);
size_t strcspn(const char *s, const char *reject);
size_t strspn (const char *s, const char *accept);
#endif
#endif