rpm  4.5
strcasecmp.c
Go to the documentation of this file.
1 
5 #include "system.h"
6 #include "rpmio.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 /*@-boundsread@*/
21  c1 = xtolower (*p1++);
22  c2 = xtolower (*p2++);
23 /*@=boundsread@*/
24  if (c1 == '\0')
25  break;
26  }
27  while (c1 == c2);
28 
29  return (int)(c1 - c2);
30 }
31 
32 int xstrncasecmp(const char *s1, const char *s2, size_t n)
33 {
34  const char * p1 = s1;
35  const char * p2 = s2;
36  char c1, c2;
37 
38  if (p1 == p2 || n == 0)
39  return 0;
40 
41  do
42  {
43 /*@-boundsread@*/
44  c1 = xtolower (*p1++);
45  c2 = xtolower (*p2++);
46 /*@=boundsread@*/
47  if (c1 == '\0' || c1 != c2)
48  break;
49  } while (--n > 0);
50 
51  return (int)(c1 - c2);
52 }