From 3ddec0f89d45827308892a23b518c9cba742034d Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 25 Apr 2010 18:56:14 +0400 Subject: [PATCH] g_strcasecmp() function is deprecated. Signed-off-by: Andrew Borodin --- lib/strutil/strutil8bit.c | 31 +++++++++++++++++++++++++++++-- lib/vfs/mc-vfs/ftpfs.c | 6 +++--- src/setup.c | 6 +++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/lib/strutil/strutil8bit.c b/lib/strutil/strutil8bit.c index aed8c3af3..b47a08e26 100644 --- a/lib/strutil/strutil8bit.c +++ b/lib/strutil/strutil8bit.c @@ -659,9 +659,36 @@ str_8bit_ncompare (const char *t1, const char *t2) } static int -str_8bit_casecmp (const char *t1, const char *t2) +str_8bit_casecmp (const char *s1, const char *s2) { - return g_strcasecmp (t1, t2); + /* code from GLib */ + +#ifdef HAVE_STRCASECMP + g_return_val_if_fail (s1 != NULL, 0); + g_return_val_if_fail (s2 != NULL, 0); + + return strcasecmp (s1, s2); +#else + gint c1, c2; + + g_return_val_if_fail (s1 != NULL, 0); + g_return_val_if_fail (s2 != NULL, 0); + + while (*s1 != '\0' && *s2 != '\0') + { + /* 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++; + } + + return (((gint)(guchar) *s1) - ((gint)(guchar) *s2)); +#endif } static int diff --git a/lib/vfs/mc-vfs/ftpfs.c b/lib/vfs/mc-vfs/ftpfs.c index 502010424..8487214a2 100644 --- a/lib/vfs/mc-vfs/ftpfs.c +++ b/lib/vfs/mc-vfs/ftpfs.c @@ -682,7 +682,7 @@ ftpfs_check_proxy (const char *host) if (!ld) return 0; } - else if (!g_strcasecmp (host, domain)) + else if (g_ascii_strcasecmp (host, domain) == 0) return 0; } @@ -2153,7 +2153,7 @@ ftpfs_find_machine (const char *host, const char *domain) if (ftpfs_netrc_next () == NETRC_NONE) break; - if (g_strcasecmp (host, buffer)) + if (g_ascii_strcasecmp (host, buffer) != 0) { /* Try adding our domain to short names in .netrc */ const char *host_domain = strchr (host, '.'); @@ -2161,7 +2161,7 @@ ftpfs_find_machine (const char *host, const char *domain) continue; /* Compare domain part */ - if (g_strcasecmp (host_domain, domain)) + if (g_ascii_strcasecmp (host_domain, domain) != 0) continue; /* Compare local part */ diff --git a/src/setup.c b/src/setup.c index f6dc1d70f..7e0c0c584 100644 --- a/src/setup.c +++ b/src/setup.c @@ -485,7 +485,7 @@ load_keys_from_section (const char *terminal, mc_config_t * cfg) while (*profile_keys != NULL) { /* copy=other causes all keys from [terminal:other] to be loaded. */ - if (g_strcasecmp (*profile_keys, "copy") == 0) + if (g_ascii_strcasecmp (*profile_keys, "copy") == 0) { valcopy = mc_config_get_string (cfg, section_name, *profile_keys, ""); load_keys_from_section (valcopy, cfg); @@ -647,7 +647,7 @@ setup__load_panel_state (const char *section) buffer = mc_config_get_string (mc_panels_config, section, "display", "listing"); for (i = 0; panel_types[i].opt_name != NULL; i++) - if (g_strcasecmp (panel_types[i].opt_name, buffer) == 0) + if (g_ascii_strcasecmp (panel_types[i].opt_name, buffer) == 0) { mode = panel_types[i].opt_type; break; @@ -1123,7 +1123,7 @@ panel_load_setup (WPanel * panel, const char *section) buffer = mc_config_get_string (mc_panels_config, section, "list_mode", "full"); panel->list_type = list_full; for (i = 0; list_types[i].key != NULL; i++) - if (g_strcasecmp (list_types[i].key, buffer) == 0) + if (g_ascii_strcasecmp (list_types[i].key, buffer) == 0) { panel->list_type = list_types[i].list_type; break;