OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / string / strncmp.c
1 /*
2  * Copyright (C) 2002     Manuel Novoa III
3  * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7
8 #include "_string.h"
9
10 #ifdef WANT_WIDE
11 # define Wstrncmp wcsncmp
12 #else
13 libc_hidden_proto(strncmp)
14 # define Wstrncmp strncmp
15 #endif
16
17 int Wstrncmp(register const Wchar *s1, register const Wchar *s2, size_t n)
18 {
19 #ifdef WANT_WIDE
20         while (n && (*((Wuchar *)s1) == *((Wuchar *)s2))) {
21                 if (!*s1++) {
22                         return 0;
23                 }
24                 ++s2;
25                 --n;
26         }
27
28         return (n == 0) ? 0 : ((*((Wuchar *)s1) < *((Wuchar *)s2)) ? -1 : 1);
29 #else
30         int r = 0;
31
32         while (n--
33                    && ((r = ((int)(*((unsigned char *)s1))) - *((unsigned char *)s2++))
34                         == 0)
35                    && *s1++);
36
37         return r;
38 #endif
39 }
40 libc_hidden_def(strncmp)