r2400: make ms_fnmatch() case insensitive. This is much more efficient than
authorAndrew Tridgell <tridge@samba.org>
Sat, 18 Sep 2004 08:12:55 +0000 (08:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:58:48 +0000 (12:58 -0500)
uppercasing the two whole strings before the call is made, is less
error-prone, and also copes with strings where the upper case version
is longer than the lower case version due to different multi-byte lengths.
(This used to be commit e227ac1edfd48596a9d5096b6965ddd0beb969a5)

source4/lib/ms_fnmatch.c

index 1c4b3d1806b7221d5abbc38d65d085bf8a613a6f..5a9edc2c8798e5d77a0928e7e91cad2f6cd5d492 100644 (file)
@@ -94,7 +94,8 @@ static int ms_fnmatch_lanman_core(const smb_ucs2_t *pattern,
                        break;
 
                default:
-                       if (c != *n) goto nomatch;
+                       if (c != *n &&
+                           toupper_w(c) != toupper_w(*n)) goto nomatch;
                        n++;
                }
        }
@@ -198,7 +199,8 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string,
                        break;
 
                default:
-                       if (c != *n) return -1;
+                       if (c != *n &&
+                           toupper_w(c) != toupper_w(*n)) return -1;
                        n++;
                }
        }