Browse Source

g_strcasecmp() function is deprecated.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 15 years ago
parent
commit
3ddec0f89d
3 changed files with 35 additions and 8 deletions
  1. 29 2
      lib/strutil/strutil8bit.c
  2. 3 3
      lib/vfs/mc-vfs/ftpfs.c
  3. 3 3
      src/setup.c

+ 29 - 2
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

+ 3 - 3
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 */

+ 3 - 3
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;