SCP: Add missing sim_strcasecmp() for host platforms without strcasecmp()

sim_strncasecmp() was previously provided.  Now both forms are available.
This commit is contained in:
Mark Pizzolato 2017-01-17 21:54:01 -08:00
parent e9b51150b0
commit af1603f000
2 changed files with 28 additions and 0 deletions

27
scp.c
View file

@ -7644,6 +7644,33 @@ for (i=0; i<len; i++) {
return 0;
}
/* strcasecmp() is not available on all platforms */
int sim_strcasecmp (const char* string1, const char* string2)
{
size_t i = 0;
unsigned char s1, s2;
while (1) {
s1 = (unsigned char)string1[i];
s2 = (unsigned char)string2[i];
if (sim_islower (s1))
s1 = (unsigned char)toupper (s1);
if (sim_islower (s2))
s2 = (unsigned char)toupper (s2);
if (s1 == s2) {
if (s1 == 0)
return 0;
i++;
continue;
}
if (s1 < s2)
return -1;
if (s1 > s2)
return 1;
}
return 0;
}
/* get_yn yes/no question
Inputs:

1
scp.h
View file

@ -152,6 +152,7 @@ int sim_isdigit (char c);
int sim_isgraph (char c);
int sim_isalnum (char c);
int sim_strncasecmp (const char *string1, const char *string2, size_t len);
int sim_strcasecmp (const char *string1, const char *string2);
CONST char *get_sim_opt (int32 opt, CONST char *cptr, t_stat *st);
const char *put_switches (char *buf, size_t bufsize, uint32 sw);
CONST char *get_glyph (const char *iptr, char *optr, char mchar);