Temporary fix to work around bug in C++ front end.
[official-gcc.git] / libiberty / strncmp.c
blobb3b9de16b10c450f1869de56bd19385669215b76
1 /* strncmp -- compare two strings, stop after n bytes.
2 This function is in the public domain. */
4 #include <ansidecl.h>
5 #ifdef __STDC__
6 #include <stddef.h>
7 #else
8 #define size_t unsigned long
9 #endif
11 int
12 strncmp(s1, s2, n)
13 const char *s1, *s2;
14 register size_t n;
16 register unsigned char u1, u2;
18 while (n-- > 0)
20 u1 = (unsigned char) *s1++;
21 u2 = (unsigned char) *s2++;
22 if (u1 != u2)
23 return u1 - u2;
24 if (u1 == '\0')
25 return 0;
27 return 0;