mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
Fix Win32 behaviour in some cases where a drive letter is present. For
2004-03-21 Tor Lillqvist <tml@iki.fi> * glib/gutils.c (g_path_get_dirname): Fix Win32 behaviour in some cases where a drive letter is present. For 'a:' or 'a:foo', return 'a:.'. This is mostly just for consistency with the behaviour without a drive letter. But very important is to for 'a:\foo' or 'a:\', return 'a:\', and not 'a:'. (Ditto for forward slashes instead of backslashes.) (#137316) * tests/dirname-test.c (main): More complete testing on Win32. If a test fails, include expected and actual result in error message.
This commit is contained in:
committed by
Tor Lillqvist
parent
000085ffa7
commit
421e7fdfad
@@ -60,7 +60,6 @@ main (int argc,
|
||||
gchar *filename;
|
||||
gchar *dirname;
|
||||
} dirname_checks[] = {
|
||||
#ifndef G_OS_WIN32
|
||||
{ "/", "/" },
|
||||
{ "////", "/" },
|
||||
{ ".////", "." },
|
||||
@@ -72,17 +71,35 @@ main (int argc,
|
||||
{ "a/b", "a" },
|
||||
{ "a/b/", "a/b" },
|
||||
{ "c///", "c" },
|
||||
#else
|
||||
{ "/a/b", "/a" },
|
||||
{ "/a/b/", "/a/b" },
|
||||
#ifdef G_OS_WIN32
|
||||
{ "\\", "\\" },
|
||||
{ ".\\\\\\\\", "." },
|
||||
{ ".\\/\\/", "." },
|
||||
{ ".", "." },
|
||||
{ "..", "." },
|
||||
{ "..\\", ".." },
|
||||
{ "..\\\\\\\\", ".." },
|
||||
{ "..\\//\\", ".." },
|
||||
{ "", "." },
|
||||
{ "a\\b", "a" },
|
||||
{ "a\\b\\", "a\\b" },
|
||||
{ "\\a\\b", "\\a" },
|
||||
{ "\\a\\b\\", "\\a\\b" },
|
||||
{ "c\\\\\\", "c" },
|
||||
{ "c/\\\\", "c" },
|
||||
{ "a:", "a:." },
|
||||
{ "a:foo", "a:." },
|
||||
{ "a:foo\\bar", "a:foo" },
|
||||
{ "a:/foo", "a:/" },
|
||||
{ "a:/foo/bar", "a:/foo" },
|
||||
{ "a:/", "a:/" },
|
||||
{ "a://", "a:/" },
|
||||
{ "a:\\foo", "a:\\" },
|
||||
{ "a:\\", "a:\\" },
|
||||
{ "a:\\\\", "a:\\" },
|
||||
{ "a:\\/", "a:\\" },
|
||||
#endif
|
||||
};
|
||||
guint n_dirname_checks = sizeof (dirname_checks) / sizeof (dirname_checks[0]);
|
||||
@@ -92,7 +109,10 @@ main (int argc,
|
||||
gchar *dirname;
|
||||
|
||||
dirname = g_path_get_dirname (dirname_checks[i].filename);
|
||||
g_assert (strcmp (dirname, dirname_checks[i].dirname) == 0);
|
||||
if (strcmp (dirname, dirname_checks[i].dirname) != 0)
|
||||
g_error ("%s returned %s, should return %s",
|
||||
dirname_checks[i].filename, dirname,
|
||||
dirname_checks[i].dirname);
|
||||
g_free (dirname);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user