From d5a989875bf71e6972ae75b264b9ccbb9a6f4b07 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 1 Aug 2005 19:17:35 +0000 Subject: [PATCH] Make it pass on Win32. (from_uri_tests[]): Take into consideration that on 2005-08-01 Tor Lillqvist * tests/uri-test.c: Make it pass on Win32. (from_uri_tests[]): Take into consideration that on Win32 we don't return "localhost" hostnames. (safe_strcmp_filename): New function that considers slash and backslash equal on Win32. (run_roundtrip_tests): Use safe_strcmp_filename(). --- ChangeLog | 9 +++++++++ ChangeLog.pre-2-10 | 9 +++++++++ ChangeLog.pre-2-12 | 9 +++++++++ ChangeLog.pre-2-8 | 9 +++++++++ tests/uri-test.c | 32 +++++++++++++++++++++++++++++--- 5 files changed, 65 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 691ea63ba..b79d7e73c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-08-01 Tor Lillqvist + + * tests/uri-test.c: Make it pass on Win32. + (from_uri_tests[]): Take into consideration that on Win32 we don't + return "localhost" hostnames. + (safe_strcmp_filename): New function that considers slash and + backslash equal on Win32. + (run_roundtrip_tests): Use safe_strcmp_filename(). + Sun Jul 31 01:50:20 2005 Tim Janik * glib/gdataset.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 691ea63ba..b79d7e73c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +2005-08-01 Tor Lillqvist + + * tests/uri-test.c: Make it pass on Win32. + (from_uri_tests[]): Take into consideration that on Win32 we don't + return "localhost" hostnames. + (safe_strcmp_filename): New function that considers slash and + backslash equal on Win32. + (run_roundtrip_tests): Use safe_strcmp_filename(). + Sun Jul 31 01:50:20 2005 Tim Janik * glib/gdataset.c: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 691ea63ba..b79d7e73c 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,12 @@ +2005-08-01 Tor Lillqvist + + * tests/uri-test.c: Make it pass on Win32. + (from_uri_tests[]): Take into consideration that on Win32 we don't + return "localhost" hostnames. + (safe_strcmp_filename): New function that considers slash and + backslash equal on Win32. + (run_roundtrip_tests): Use safe_strcmp_filename(). + Sun Jul 31 01:50:20 2005 Tim Janik * glib/gdataset.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 691ea63ba..b79d7e73c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +2005-08-01 Tor Lillqvist + + * tests/uri-test.c: Make it pass on Win32. + (from_uri_tests[]): Take into consideration that on Win32 we don't + return "localhost" hostnames. + (safe_strcmp_filename): New function that considers slash and + backslash equal on Win32. + (run_roundtrip_tests): Use safe_strcmp_filename(). + Sun Jul 31 01:50:20 2005 Tim Janik * glib/gdataset.c: diff --git a/tests/uri-test.c b/tests/uri-test.c index 414b8bfa2..6f4e6dabc 100644 --- a/tests/uri-test.c +++ b/tests/uri-test.c @@ -120,17 +120,19 @@ from_uri_tests[] = { */ { "file://localhost/etc", "/etc", NULL}, { "file://localhost/etc/%23%25%20file", "/etc/#% file", NULL}, + { "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", NULL}, + { "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", NULL}, #else { "file://localhost/etc", "/etc", "localhost"}, { "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost"}, + { "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost"}, + { "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost"}, #endif { "file://otherhost/etc", "/etc", "otherhost"}, { "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"}, { "file://%C3%B6%C3%A4%C3%A5/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file:////etc/%C3%B6%C3%C3%C3%A5", "//etc/\xc3\xb6\xc3\xc3\xc3\xa5", NULL}, - { "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost"}, { "file://\xE5\xE4\xF6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, - { "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost"}, { "file://%E5%E4%F6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file://some", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, @@ -309,6 +311,30 @@ safe_strcmp (const gchar *a, const gchar *b) return strcmp (a ? a : "", b ? b : ""); } +static gint +safe_strcmp_filename (const gchar *a, const gchar *b) +{ +#ifdef G_OS_WIN32 + return safe_strcmp (a, b); +#else + if (!a) + return safe_strcmp ("", b); + else if (!b) + return safe_strcmp (a, ""); + else + { + while (*a && *b) + { + if ((G_IS_DIR_SEPARATOR (*a) && G_IS_DIR_SEPARATOR (*b)) || + *a == *b) + a++, b++; + else + return (*a - *b); + } + } +#endif +} + static void run_roundtrip_tests (void) { @@ -344,7 +370,7 @@ run_roundtrip_tests (void) continue; } - if (safe_strcmp (to_uri_tests[i].filename, res)) + if (safe_strcmp_filename (to_uri_tests[i].filename, res)) { g_print ("roundtrip test %d failed, filename modified: " " expected \"%s\", but got \"%s\"\n",