Last change
on this file since 450 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.2 KB
|
Line | |
---|
1 | /* |
---|
2 | FUNCTION |
---|
3 | <<strcasecmp_l>>---case-insensitive character string compare |
---|
4 | |
---|
5 | INDEX |
---|
6 | strcasecmp_l |
---|
7 | |
---|
8 | SYNOPSIS |
---|
9 | #include <strings.h> |
---|
10 | int strcasecmp_l(const char *<[a]>, const char *<[b]>, |
---|
11 | locale_t <[locale]>); |
---|
12 | |
---|
13 | DESCRIPTION |
---|
14 | <<strcasecmp_l>> compares the string at <[a]> to |
---|
15 | the string at <[b]> in a case-insensitive manner. |
---|
16 | |
---|
17 | if <[locale]> is LC_GLOBAL_LOCALE or not a valid locale object, the |
---|
18 | behaviour is undefined. |
---|
19 | |
---|
20 | RETURNS |
---|
21 | |
---|
22 | If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after |
---|
23 | both are converted to lowercase), <<strcasecmp_l>> returns a |
---|
24 | number greater than zero. If the two strings match, |
---|
25 | <<strcasecmp_l>> returns zero. If <<*<[a]>>> sorts |
---|
26 | lexicographically before <<*<[b]>>>, <<strcasecmp_l>> returns a |
---|
27 | number less than zero. |
---|
28 | |
---|
29 | PORTABILITY |
---|
30 | <<strcasecmp_l>> is POSIX-1.2008. |
---|
31 | |
---|
32 | <<strcasecmp_l>> requires no supporting OS subroutines. It uses |
---|
33 | tolower_l() from elsewhere in this library. |
---|
34 | |
---|
35 | QUICKREF |
---|
36 | strcasecmp_l |
---|
37 | */ |
---|
38 | |
---|
39 | #include <strings.h> |
---|
40 | #include <ctype.h> |
---|
41 | |
---|
42 | int |
---|
43 | strcasecmp_l (const char *s1, const char *s2, struct __locale_t *locale) |
---|
44 | { |
---|
45 | int d = 0; |
---|
46 | for ( ; ; ) |
---|
47 | { |
---|
48 | const int c1 = tolower_l (*s1++, locale); |
---|
49 | const int c2 = tolower_l (*s2++, locale); |
---|
50 | if (((d = c1 - c2) != 0) || (c2 == '\0')) |
---|
51 | break; |
---|
52 | } |
---|
53 | return d; |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.