server: Case-sensitivity final step: Use OBJ_CASE_INSENSITIVE in object lookup

Vitaliy Margolen wine-patch at kievinfo.com
Sat Oct 29 10:34:18 CDT 2005


Vitaliy Margolen

changelog:
  server:
  - Use OBJ_CASE_INSENSITIVE in object lookup
  - Remove case_sensitive flag from namespace.
  - Remove todo_wine from now succeeding tests
-------------- next part --------------
Index: server/main.c
===================================================================
RCS file: /home/wine/wine/server/main.c,v
retrieving revision 1.34
diff -u -p -r1.34 main.c
--- server/main.c	25 May 2005 18:41:09 -0000	1.34
+++ server/main.c	29 Oct 2005 15:20:18 -0000
@@ -130,7 +130,7 @@ int main( int argc, char *argv[] )
 
     sock_init();
     open_master_socket();
-    sync_namespace = create_namespace( 37, TRUE );
+    sync_namespace = create_namespace( 37 );
     setvbuf( stderr, NULL, _IOLBF, 0 );
 
     if (debug_level) fprintf( stderr, "wineserver: starting (pid=%ld)\n", (long) getpid() );
Index: server/object.c
===================================================================
RCS file: /home/wine/wine/server/object.c,v
retrieving revision 1.35
diff -u -p -r1.35 object.c
--- server/object.c	29 Oct 2005 12:38:23 -0000	1.35
+++ server/object.c	29 Oct 2005 15:20:18 -0000
@@ -28,6 +28,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "winternl.h"
+
 #include "file.h"
 #include "thread.h"
 #include "unicode.h"
@@ -44,7 +46,6 @@ struct object_name
 struct namespace
 {
     unsigned int        hash_size;       /* size of hash table */
-    int                 case_sensitive;  /* are names case sensitive? */
     struct list         names[1];        /* array of hash entry lists */
 };
 
@@ -92,8 +93,7 @@ static int get_name_hash( const struct n
 {
     WCHAR hash = 0;
     len /= sizeof(WCHAR);
-    if (namespace->case_sensitive) while (len--) hash ^= *name++;
-    else while (len--) hash ^= tolowerW(*name++);
+    while (len--) hash ^= tolowerW(*name++);
     return hash % namespace->hash_size;
 }
 
@@ -233,29 +233,24 @@ struct object *find_object( const struct
     if (!name || !len) return NULL;
 
     list = &namespace->names[ get_name_hash( namespace, name, len ) ];
-    if (namespace->case_sensitive)
+    LIST_FOR_EACH( p, list )
     {
-        LIST_FOR_EACH( p, list )
+        const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry );
+        if (ptr->len != len) continue;
+        if (attributes & OBJ_CASE_INSENSITIVE)
         {
-            const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry );
-            if (ptr->len != len) continue;
-            if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj );
+            if (!strncmpiW( ptr->name, name, len/sizeof(WCHAR) )) return grab_object( ptr->obj );
         }
-    }
-    else
-    {
-        LIST_FOR_EACH( p, list )
+        else
         {
-            const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry );
-            if (ptr->len != len) continue;
-            if (!strncmpiW( ptr->name, name, len/sizeof(WCHAR) )) return grab_object( ptr->obj );
+            if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj );
         }
     }
     return NULL;
 }
 
 /* allocate a namespace */
-struct namespace *create_namespace( unsigned int hash_size, int case_sensitive )
+struct namespace *create_namespace( unsigned int hash_size )
 {
     struct namespace *namespace;
     unsigned int i;
@@ -264,7 +259,6 @@ struct namespace *create_namespace( unsi
     if (namespace)
     {
         namespace->hash_size      = hash_size;
-        namespace->case_sensitive = case_sensitive;
         for (i = 0; i < hash_size; i++) list_init( &namespace->names[i] );
     }
     return namespace;
Index: server/object.h
===================================================================
RCS file: /home/wine/wine/server/object.h,v
retrieving revision 1.67
diff -u -p -r1.67 object.h
--- server/object.h	29 Oct 2005 12:38:23 -0000	1.67
+++ server/object.h	29 Oct 2005 15:20:18 -0000
@@ -95,7 +95,7 @@ extern const WCHAR *get_object_name( str
 extern void dump_object_name( struct object *obj );
 extern void *create_named_object( struct namespace *namespace, const struct object_ops *ops,
                                   const WCHAR *name, size_t len, unsigned int attributes );
-extern struct namespace *create_namespace( unsigned int hash_size, int case_sensitive );
+extern struct namespace *create_namespace( unsigned int hash_size );
 /* grab/release_object can take any pointer, but you better make sure */
 /* that the thing pointed to starts with a struct object... */
 extern struct object *grab_object( void *obj );
Index: server/winstation.c
===================================================================
RCS file: /home/wine/wine/server/winstation.c,v
retrieving revision 1.12
diff -u -p -r1.12 winstation.c
--- server/winstation.c	29 Oct 2005 12:38:23 -0000	1.12
+++ server/winstation.c	29 Oct 2005 15:20:19 -0000
@@ -84,7 +84,7 @@ static struct winstation *create_winstat
 {
     struct winstation *winstation;
 
-    if (!winstation_namespace && !(winstation_namespace = create_namespace( 7, FALSE )))
+    if (!winstation_namespace && !(winstation_namespace = create_namespace( 7 )))
         return NULL;
 
     if (memchrW( name, '\\', len / sizeof(WCHAR) ))  /* no backslash allowed in name */
Index: dlls/ntdll/tests/om.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/tests/om.c,v
retrieving revision 1.1
diff -u -p -r1.1 om.c
--- dlls/ntdll/tests/om.c	30 Sep 2005 10:33:54 -0000	1.1
+++ dlls/ntdll/tests/om.c	29 Oct 2005 15:26:39 -0000
@@ -63,7 +63,7 @@ void test_case_sensitive (void)
     pRtlInitUnicodeString(&str, buffer3);
     InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
     status = pNtOpenMutant(&h, GENERIC_ALL, &attr);
-    todo_wine ok(status == STATUS_OBJECT_TYPE_MISMATCH,
+    ok(status == STATUS_OBJECT_TYPE_MISMATCH,
         "NtOpenMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
 
     pNtClose(Mutant);
@@ -71,7 +71,7 @@ void test_case_sensitive (void)
     pRtlInitUnicodeString(&str, buffer4);
     InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
     status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
-    todo_wine ok(status == STATUS_OBJECT_NAME_COLLISION,
+    ok(status == STATUS_OBJECT_NAME_COLLISION,
         "NtCreateMutant should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status);
 
     status = pNtCreateEvent(&h, GENERIC_ALL, &attr, FALSE, FALSE);


More information about the wine-patches mailing list