rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

strcasecmp.c
Go to the documentation of this file.
1
5 #include "system.h"
6 #include <rpmiotypes.h>
7 #include "debug.h"
8
9 int xstrcasecmp(const char * s1, const char * s2)
10 {
11 const char * p1 = s1;
12 const char * p2 = s2;
13 char c1, c2;
14
15 if (p1 == p2)
16 return 0;
17
18 do
19 {
20 c1 = (char) xtolower ((int)*p1++);
21 c2 = (char) xtolower ((int)*p2++);
22 if (c1 == '\0')
23 break;
24 }
25 while (c1 == c2);
26
27 return ((int)c1 - (int)c2);
28 }
29
30 int xstrncasecmp(const char *s1, const char *s2, size_t n)
31 {
32 const char * p1 = s1;
33 const char * p2 = s2;
34 char c1, c2;
35
36 if (p1 == p2 || n == 0)
37 return 0;
38
39 do
40 {
41 c1 = (char) xtolower ((int)*p1++);
42 c2 = (char) xtolower ((int)*p2++);
43 if (c1 == '\0' || c1 != c2)
44 break;
45 } while (--n > 0);
46
47 return ((int)c1 - (int)c2);
48 }