From a5c1a0d417632f4f62af8a2f3151bc475fcb8345 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Wed, 30 May 2007 13:24:42 +0200 Subject: [PATCH] 2007-05-30 Tor Lillqvist * parse.c: Fix problem on Win32 where the automagic prefix replacement logic didn't work. I don't know what change had broken it. (pathnamecmp): New Win32-only function. Compares two file paths case insensitively and treating backslashes as equal to slashes. (parse_line): Use it instead of g_ascii_strcasecmp(). --- ChangeLog | 10 ++++++++++ parse.c | 26 ++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a9b69e..a313a24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-05-30 Tor Lillqvist + + * parse.c: Fix problem on Win32 where the automagic prefix + replacement logic didn't work. I don't know what change had + broken it. + (pathnamecmp): New Win32-only function. Compares two file + paths case insensitively and treating backslashes as equal to + slashes. + (parse_line): Use it instead of g_ascii_strcasecmp(). + 2007-05-29 Tollef Fog Heen * pkg.m4: Update URL to pkg-config website. Thanks to Peter diff --git a/parse.c b/parse.c index d91977a..9d996d4 100644 --- a/parse.c +++ b/parse.c @@ -39,6 +39,12 @@ char *prefix_variable = "prefix"; int msvc_syntax = FALSE; #endif +#ifdef G_OS_WIN32 +#ifndef G_IS_DIR_SEPARATOR +#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/') +#endif +#endif + /** * Read an entire line from a file into a buffer. Lines may * be delimited with '\n', '\r', '\n\r', or '\r\n'. The delimiter @@ -890,6 +896,22 @@ parse_url (Package *pkg, const char *str, const char *path) pkg->url = trim_and_sub (pkg, str, path); } +#ifdef G_OS_WIN32 +static int +pathnamecmp (const char *a, + const char *b) +{ + while (*a && *b && + ((G_IS_DIR_SEPARATOR (*a) && G_IS_DIR_SEPARATOR (*b)) || + g_ascii_toupper (*a) == g_ascii_toupper (*b))) + { + a++; + b++; + } + return g_ascii_toupper (*a) - g_ascii_toupper (*b); +} +#endif + static void parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean ignore_requires, gboolean ignore_private_libs) { @@ -992,8 +1014,8 @@ parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean igno const int lib_pkgconfig_len = strlen (lib_pkgconfig); if (strlen (prefix) > lib_pkgconfig_len && - g_ascii_strcasecmp (prefix + prefix_len - lib_pkgconfig_len, - lib_pkgconfig) == 0) + pathnamecmp (prefix + prefix_len - lib_pkgconfig_len, + lib_pkgconfig) == 0) { /* It ends in lib\pkgconfig. Good. */ -- 2.39.5