Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/strcasecmp.c
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static u_char charmap[] = { | ||||
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', | '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', | ||||
'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337', | '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337', | ||||
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', | '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', | ||||
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', | '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', | ||||
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', | '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', | ||||
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', | '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', | ||||
}; | }; | ||||
strcasecmp(s1, s2) | strcasecmp(char *s1, char *s2) | ||||
char *s1, *s2; | |||||
{ | { | ||||
register u_char *cm = charmap, | register u_char *cm = charmap, | ||||
*us1 = (u_char *)s1, | *us1 = (u_char *)s1, | ||||
*us2 = (u_char *)s2; | *us2 = (u_char *)s2; | ||||
while (cm[*us1] == cm[*us2++]) | while (cm[*us1] == cm[*us2++]) | ||||
if (*us1++ == '\0') | if (*us1++ == '\0') | ||||
return(0); | return(0); | ||||
return(cm[*us1] - cm[*--us2]); | return(cm[*us1] - cm[*--us2]); | ||||
} | } | ||||
strncasecmp(s1, s2, n) | strncasecmp(char *s1, char *s2, register int n) | ||||
char *s1, *s2; | |||||
register int n; | |||||
{ | { | ||||
register u_char *cm = charmap, | register u_char *cm = charmap, | ||||
*us1 = (u_char *)s1, | *us1 = (u_char *)s1, | ||||
*us2 = (u_char *)s2; | *us2 = (u_char *)s2; | ||||
while (--n >= 0 && cm[*us1] == cm[*us2++]) | while (--n >= 0 && cm[*us1] == cm[*us2++]) | ||||
if (*us1++ == '\0') | if (*us1++ == '\0') | ||||
return(0); | return(0); | ||||
return(n < 0 ? 0 : cm[*us1] - cm[*--us2]); | return(n < 0 ? 0 : cm[*us1] - cm[*--us2]); | ||||
} | } |