g_strncasecmp() function is deprecated.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-05-22 11:42:26 +04:00
parent 8b4124dfa5
commit 0cb04aec3b
3 changed files with 36 additions and 3 deletions

View File

@ -161,6 +161,7 @@ AC_CHECK_FUNCS([\
setreuid statfs sysconf \ setreuid statfs sysconf \
tcgetattr tcsetattr truncate \ tcgetattr tcsetattr truncate \
strverscmp \ strverscmp \
strncasecmp \
realpath realpath
]) ])

View File

@ -692,9 +692,41 @@ str_8bit_casecmp (const char *s1, const char *s2)
} }
static int static int
str_8bit_ncasecmp (const char *t1, const char *t2) str_8bit_ncasecmp (const char *s1, const char *s2)
{ {
return g_strncasecmp (t1, t2, min (strlen (t1), strlen (t2))); size_t n;
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
n = min (strlen (s1), strlen (s2));
/* code from GLib */
#ifdef HAVE_STRNCASECMP
return strncasecmp (s1, s2, n);
#else
gint c1, c2;
while (n != 0 && *s1 != '\0' && *s2 != '\0')
{
n -= 1;
/* According to A. Cox, some platforms have islower's that
* don't work right on non-uppercase
*/
c1 = isupper ((guchar) *s1) ? tolower ((guchar) *s1) : *s1;
c2 = isupper ((guchar) *s2) ? tolower ((guchar) *s2) : *s2;
if (c1 != c2)
return (c1 - c2);
s1++;
s2++;
}
if (n != 0)
return (((gint) (guchar) *s1) - ((gint) (guchar) *s2));
else
return 0;
#endif
} }
static int static int

View File

@ -2169,7 +2169,7 @@ ftpfs_find_machine (const char *host, const char *domain)
continue; continue;
/* Compare local part */ /* Compare local part */
if (g_strncasecmp (host, buffer, host_domain - host)) if (g_ascii_strncasecmp (host, buffer, host_domain - host) != 0)
continue; continue;
} }