Return to string.c CVS log | Up to [local] / funnyos / libkern |
File: [local] / funnyos / libkern / string.c (download)
Revision 1.1.1.1 (vendor branch), Tue Oct 16 08:41:04 2007 UTC (16 years, 7 months ago) by init
Initial import of funnyos; still much more work to do |
/* * $Id: string.c,v 1.1.1.1 2007/10/16 08:41:04 init Exp $ */ #include <sys/types.h> #include <libkern/string.h> int strncmp(const char *s1, const char *s2, const uint32_t len) { /* * Compare len characters of string s1 with len characters of s2. * Return first difference's position or 0 if no differencies. */ uint32_t i; /* TODO ugly algorhitm; rewrite */ for(i = 0; i < len; i++) { if(s1[i] != s2[i]) return(i + 1); if(s1[i] == '\0') /* \0 encountered, but strings are identical */ return(0); } return(-1); }