summaryrefslogtreecommitdiff
path: root/Build/source/utils/dialog/strcasecmp.c
blob: 24cae771aafc2dbe7ee7295b1ef660e2ed4692d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "dialogconfig.h"

/* GNU Library doesn't have toupper().  Until GNU gets this fixed, I will
   have to do it. */
#ifndef toupper
#define toupper(c) ((c) - 32)
#endif

#define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c)))

#if !defined (HAVE_STRCASECMP)
int strcasecmp (char *string1, char * string2)
{
  char ch1, ch2;

  for (;;)
    {
      ch1 = *string1++;
      ch2 = *string2++;

      if (!(ch1 | ch2))
        return (0);

      ch1 = coerce_to_upper (ch1);
      ch2 = coerce_to_upper (ch2);

      if (ch1 != ch2)
        return (ch1 - ch2);
    }
}
#endif /* !HAVE_STRCASECMP */