winewrap: fix uuid support

Dimitrie O. Paun dpaun at rogers.com
Fri Feb 13 00:33:31 CST 2004


On February 12, 2004 04:16 pm, Alexandre Julliard wrote:
> I think it's the search algorithm that's broken. We should check every
> lib path directory for both .so and .a before moving on to the next
> one.

Good point. What about this (for each dir, we check for .so, .def, .a).

ChangeLog
    For each lib dir, look for .so, .def. and .a files, instead
    of the other way around.

Index: tools/winegcc/winewrap.c
===================================================================
RCS file: /var/cvs/wine/tools/winegcc/winewrap.c,v
retrieving revision 1.14
diff -u -r1.14 winewrap.c
--- tools/winegcc/winewrap.c	9 Jan 2004 20:08:22 -0000	1.14
+++ tools/winegcc/winewrap.c	13 Feb 2004 06:27:25 -0000
@@ -123,6 +123,12 @@
     return !memcmp(buf, res_sig, sizeof(buf));
 }
 
+static void add_lib_path(const char* path)
+{
+    strarray_add(lib_paths, strdup(path));
+    strarray_add(llib_paths, strmake("-L%s", path));
+}
+
 /* open the file for a given name, in a specified path, with the given extension */
 static char *try_path( const char *path, const char *name, const char *ext )
 {
@@ -144,81 +150,54 @@
     return NULL;
 }
 
-
-static char* find_in_path(const strarray* path, const char* name, const char* ext)
-{
-    int i;
-    for (i = 0; i < path->size; i++)
-    {
-	char* fullname;
-        if ((fullname = try_path( path->base[i], name, ext )))
-	    return fullname;
-    }
-    return NULL;
-}
-    
-/* find the .def library for a given dll */
-static char *find_dll(const char *name)
-{
-    return find_in_path(lib_paths, name, "def");
-}
-
-/* find a unix library */
-static char *find_unix_lib(const char *name, const char* ext)
-{
-    char* fullname;
-    static strarray *std_paths;
-    if (!std_paths)
-    {
-        std_paths = strarray_alloc();
-	strarray_add(std_paths, "/usr/lib");
-	strarray_add(std_paths, "/usr/local/lib");
-    }
-
-    if ((fullname = find_in_path( lib_paths, name, ext )))
-	return fullname;
-
-    return find_in_path( std_paths, name, ext );
-}
-
-static void add_lib_path(const char* path)
-{
-    strarray_add(lib_paths, strdup(path));
-    strarray_add(llib_paths, strmake("-L%s", path));
-}
-
-static void identify_lib_file(const char* library)
+static int identify_lib_file(const char *path, const char* library)
 {
     char *lib;
 
-    if (find_unix_lib(library, "so"))
+    if (try_path(path, library, "so"))
     {
 	/* Unix shared object */
         strarray_add(so_files, strmake("-l%s", library));
     }
-    else if (find_dll(library))
+    else if (try_path(path, library, "def"))
     {
 	/* Windows DLL */
 	strarray_add(dll_files, strmake("-l%s", library));
     }
-    else if ((lib = find_unix_lib(library, "a")))
+    else if ((lib = try_path(path, library, "a")))
     {
 	/* winebuild needs the full path for .a files */
         strarray_add(arh_files, lib);
     }
     else
     {
-        fprintf(stderr, "cannot find %s.{so,def,a} in library search path\n",
-		library);
+	/* failed to find the library */
+	return 0;
     }
+    return 1;
 }
  
 static void identify_lib_files(strarray *lib_files)
 {
-    int i;
+    static const char* std_paths[] = { "/usr/lib", "/usr/local/lib" };
+    int i, j;
+
     for (i = 0; i < lib_files->size; i++)
     {
-        identify_lib_file( lib_files->base[i]);
+        for (j = 0; j < lib_paths->size; j++)
+        {
+            if (identify_lib_file(lib_paths->base[i], lib_files->base[i])) 
+		break;
+	}
+	if (j < lib_paths->size) continue;
+	for (j = 0; j < sizeof(std_paths)/sizeof(std_paths[0]); j++)
+	{
+            if (identify_lib_file(std_paths[i], lib_files->base[i])) 
+		break;
+	}
+	if (j < sizeof(std_paths)/sizeof(std_paths[0])) continue;
+	fprintf(stderr, "cannot find %s.{so,def,a} in library search path\n", 
+		lib_files->base[i]);
     }
 }
 


-- 
Dimi.




More information about the wine-patches mailing list