diff options
Diffstat (limited to 'src/libs/utils.c')
| -rw-r--r-- | src/libs/utils.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/libs/utils.c b/src/libs/utils.c index 75b5661..b6500ef 100644 --- a/src/libs/utils.c +++ b/src/libs/utils.c @@ -12,6 +12,7 @@ void memset(u8 *start, u8 value, u32 size){ } } +// The following implementation is incomplete int modulo(int dividend, int divisor){ while((dividend-divisor)>0){dividend-=divisor;} return dividend; @@ -21,14 +22,7 @@ int strlen(char * cp) { int len=0; while( cp[len++]) ; - return len - 1 ; //because it counted the zero which we don't want. -} - -int wordlen(char *s) -{ - int len=0; - while( *s!='\n' && *s!='\0' && *s!=' '){ s++; } - return len - 1 ; //because it counted the zero which we don't want. + return len - 1 ; } u8 strcmp(char *str1, char*str2){ @@ -43,11 +37,11 @@ u8 strcmp(char *str1, char*str2){ u8 strncmp(char *str1, char *str2, int n){ for(int i=0;i<n;i++){ - if(str1[i] == '\0' || str2[i] == '\0') - break; + if(str1[i] == '\0' || str2[i] == '\0'){ + return str1[i] != str2[i]; + } if(str1[i] != str2[i]) return 1; } - - return *str1 != *str2; + return 0; } |
