Module: wine Branch: master Commit: 62f9966fdc8e37720d9ad60a87592b0a593a03a9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=62f9966fdc8e37720d9ad60a87...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Oct 28 11:45:05 2010 +0200
winegcc: Fix the lib dir detection.
Spotted by André Hentschel.
---
tools/winegcc/winegcc.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index bec4be3..dcfe778 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -340,28 +340,36 @@ static int check_platform( struct options *opts, const char *file ) static char *get_lib_dir( struct options *opts ) { static const char *stdlibpath[] = { LIBDIR, "/usr/lib", "/usr/local/lib", "/lib" }; + static const char libwine[] = "/libwine.so"; unsigned int i;
for (i = 0; i < sizeof(stdlibpath)/sizeof(stdlibpath[0]); i++) { - char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + sizeof("32/libwine.so") ); + char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + strlen(libwine) + 3 ); strcpy( buffer, stdlibpath[i] ); p = buffer + strlen(buffer); while (p > buffer && p[-1] == '/') p--; - strcpy( p, "/libwine.so" ); - if (check_platform( opts, buffer )) return buffer; + strcpy( p, libwine ); + if (check_platform( opts, buffer )) goto found; if (p > buffer + 2 && (!memcmp( p - 2, "32", 2 ) || !memcmp( p - 2, "64", 2 ))) p -= 2; if (opts->force_pointer_size == 4 || (!opts->force_pointer_size && opts->target_cpu != CPU_x86_64)) { - strcpy( p, "32/libwine.so" ); - if (check_platform( opts, buffer )) return buffer; + strcpy( p, "32" ); + strcat( p, libwine ); + if (check_platform( opts, buffer )) goto found; } if (opts->force_pointer_size == 8 || (!opts->force_pointer_size && opts->target_cpu == CPU_x86_64)) { - strcpy( p, "64/libwine.so" ); - if (check_platform( opts, buffer )) return buffer; + strcpy( p, "64" ); + strcat( p, libwine ); + if (check_platform( opts, buffer )) goto found; } free( buffer ); + continue; + + found: + buffer[strlen(buffer) - strlen(libwine)] = 0; + return buffer; } return xstrdup( LIBDIR ); }