forked from xamidev/pepperOS
Kernel debug shell
This commit is contained in:
@@ -69,4 +69,33 @@ void strncpy(char* dst, const char* src, size_t n)
|
||||
{
|
||||
size_t i = 0;
|
||||
while(i++ != n && (*dst++ = *src++));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* strncmp - compare two strings up to n characters
|
||||
* @s1: first string
|
||||
* @s2: second string
|
||||
* @n: number of bytes to compare
|
||||
*
|
||||
* Taken from: https://github.com/DevSolar/pdclib/blob/master/functions/string/strncmp.c
|
||||
*
|
||||
* Return:
|
||||
* $0 - @s1 and @s2 are equal
|
||||
* $<0 - @s1 is less than @s2
|
||||
* $>0 - @s1 is greater than @s2
|
||||
*/
|
||||
int strncmp(const char* s1, const char* s2, size_t n)
|
||||
{
|
||||
while ( n && *s1 && ( *s1 == *s2 ) ) {
|
||||
++s1;
|
||||
++s2;
|
||||
--n;
|
||||
}
|
||||
if ( n == 0 ) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return ( *(unsigned char *)s1 - *(unsigned char *)s2 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user