This repository has been archived on 2021-03-01. You can view files and clone it, but cannot push or open issues or pull requests.
kaneton/kaneton/library/strncmp.c
Mercier Pierre-Olivier fee4dd4e6d Initial snapshot
2013-02-11 22:04:30 +01:00

41 lines
792 B
C

/*
* licence kaneton licence
*
* project kaneton
*
* file /home/buckman/kaneton/libs/klibrary/libstring/strncmp.c
*
* created julien quintard [fri feb 11 02:56:44 2005]
* updated matthieu bucchianeri [sat may 5 19:20:22 2007]
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <library/library.h>
/*
* ---------- functions -------------------------------------------------------
*/
int strncmp(const char* s1,
const char* s2,
size_t n)
{
u_int i;
u_int j;
for (i = 0, j = 0; s1[i] && s2[j] && i < n; i++, j++)
if (s1[i] != s2[j])
return (s1[i] - s2[j]);
if (i == n)
return (0);
if (s1[i] != s2[j])
return (s1[i] - s2[j]);
return (0);
}