Pristine Ack-5.5
[Ack-5.5.git] / modules / src / string / strncmp.c
1 /* $Id: strncmp.c,v 1.5 1994/06/24 11:23:10 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /*      return negative, zero or positive value if
7         resp. s < t, s == t or s > t; compare at most n characters
8 */
9
10 #include "ack_string.h"
11
12 int
13 strncmp(s, t, n)
14         register _CONST char *s, *t;
15         register _SIZET n;
16 {
17         while (n-- > 0) {
18                 if (*s == *t++) {
19                         if (*s++ == '\0')
20                                 return 0;
21                 }
22                 else
23                         return *s - *--t;
24         }
25         return 0;
26 }