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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include "sys-defines.h"
#include "plot.h"
#include "extern.h"
#ifndef HAVE_STRCASECMP
int
#ifdef _HAVE_PROTOS
strcasecmp(const char *s1, const char *s2)
#else
strcasecmp(s1, s2)
const char *s1, *s2;
#endif
{
bool retval_set = false;
int retval = 0;
char *t1, *t2, *t1_base, *t2_base;
t1 = t1_base = (char *)_plot_xmalloc (strlen (s1) + 1);
t2 = t2_base = (char *)_plot_xmalloc (strlen (s2) + 1);
strcpy (t1, s1);
strcpy (t2, s2);
while (*t1 && *t2)
{
unsigned int c1 = tolower ((int)(unsigned char)*t1);
unsigned int c2 = tolower ((int)(unsigned char)*t2);
if (c1 > c2)
{
retval = 1;
retval_set = true;
break;
}
else if (c1 < c2)
{
retval = -1;
retval_set = true;
break;
}
else
{
t1++;
t2++;
}
}
if (!retval_set)
{
if (*t1)
retval = 1;
else if (*t2)
retval = -1;
else
retval = 0;
}
free (t1_base);
free (t2_base);
return retval;
}
#endif /* HAVE_STRCASECMP */
|