mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-31 17:10:09 +01:00
DIX: Add strncasecmp from FreeBSD, make strcasecmp args const
Add strncasecmp (as we're now using it) in case someone doesn't have it, and also change strncasecmp args to be const, in accordance with everything else.
This commit is contained in:
parent
ae38151ddd
commit
11f9e35202
2 changed files with 26 additions and 2 deletions
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#ifdef NEED_STRCASECMP
|
||||
int
|
||||
xstrcasecmp(char *str1,char *str2)
|
||||
xstrcasecmp(const char *str1, const char *str2)
|
||||
{
|
||||
const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2;
|
||||
|
||||
|
|
@ -46,3 +46,22 @@ xstrcasecmp(char *str1,char *str2)
|
|||
return (tolower(*us1) - tolower(*us2));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NEED_STRNCASECMP
|
||||
int
|
||||
xstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n != 0) {
|
||||
const u_char *us1 = (const u_char *)s1, *us2 = (const u_char *)s2;
|
||||
|
||||
do {
|
||||
if (tolower(*us1) != tolower(*us2++))
|
||||
return (tolower(*us1) - tolower(*--us2));
|
||||
if (*us1++ == '\0')
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -601,7 +601,12 @@ typedef struct {
|
|||
/* strcasecmp.c */
|
||||
#if NEED_STRCASECMP
|
||||
#define strcasecmp xstrcasecmp
|
||||
extern int xstrcasecmp(char *s1, char *s2);
|
||||
extern int xstrcasecmp(const char *s1, const char *s2);
|
||||
#endif
|
||||
|
||||
#if NEED_STRNCASECMP
|
||||
#define strncasecmp xstrncasecmp
|
||||
extern int xstrncasecmp(const char *s1, const char *s2, size_t n);
|
||||
#endif
|
||||
|
||||
extern int XItoCoreType(int xi_type);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue