00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <ansidecl.h>
00016 #ifdef ANSI_PROTOTYPES
00017 #include <stddef.h>
00018 #else
00019 #define size_t unsigned long
00020 #endif
00021
00022 int
00023 strncmp(s1, s2, n)
00024 const char *s1, *s2;
00025 register size_t n;
00026 {
00027 register unsigned char u1, u2;
00028
00029 while (n-- > 0)
00030 {
00031 u1 = (unsigned char) *s1++;
00032 u2 = (unsigned char) *s2++;
00033 if (u1 != u2)
00034 return u1 - u2;
00035 if (u1 == '\0')
00036 return 0;
00037 }
00038 return 0;
00039 }