kern

diff src/klibc/string.c @ 91:f83f50c17c3b

continuing with the fs added strtol and strstr to klibc
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 09 Dec 2011 15:29:54 +0200
parents ebca81749ef5
children
line diff
     1.1 --- a/src/klibc/string.c	Fri Dec 09 13:44:15 2011 +0200
     1.2 +++ b/src/klibc/string.c	Fri Dec 09 15:29:54 2011 +0200
     1.3 @@ -89,6 +89,24 @@
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 +char *strstr(const char *str, const char *substr)
     1.8 +{
     1.9 +	while(*str) {
    1.10 +		const char *s1 = str;
    1.11 +		const char *s2 = substr;
    1.12 +
    1.13 +		while(*s1 && *s1 == *s2) {
    1.14 +			s1++;
    1.15 +			s2++;
    1.16 +		}
    1.17 +		if(!*s2) {
    1.18 +			return (char*)str;
    1.19 +		}
    1.20 +		str++;
    1.21 +	}
    1.22 +	return 0;
    1.23 +}
    1.24 +
    1.25  int strcmp(const char *s1, const char *s2)
    1.26  {
    1.27  	while(*s1 && *s1 == *s2) {