~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to rpmio/strcasecmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** \ingroup rpmio
 
2
 * \file rpmio/strcasecmp.c
 
3
 */
 
4
 
 
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
      c1 = xtolower (*p1++);
 
21
      c2 = xtolower (*p2++);
 
22
      if (c1 == '\0')
 
23
        break;
 
24
    }
 
25
  while (c1 == c2);
 
26
 
 
27
  return (int)(c1 - 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 = xtolower (*p1++);
 
42
      c2 = xtolower (*p2++);
 
43
      if (c1 == '\0' || c1 != c2)
 
44
        break;
 
45
    } while (--n > 0);
 
46
 
 
47
  return (int)(c1 - c2);
 
48
}