Re: [GNOME VFS] [PATCH] gnome_vfs_uri_extract_dirname misses some cases.
David Emory Watson <[email protected]>
| Newsgroups | gmane.comp.gnome.vfs |
|---|---|
| Message-ID | <1020526090.1794.6.camel@galois> |
I applied the following patch, which includes the test-uri.c changes you mentioned. On Fri, 2002-05-03 at 22:56, Darin Adler wrote: > My opinion on this is that there should be a test of this added to test-uri.c also as part of the check-in. > > On the other hand, the patch looks good to me. > > -- Darin >
dirname-patch
(text/x-patch, 2.8 KB)
Index: ChangeLog =================================================================== RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v retrieving revision 1.1282 diff -p -u -r1.1282 ChangeLog --- ChangeLog 2 May 2002 21:07:27 -0000 1.1282 +++ ChangeLog 4 May 2002 15:25:01 -0000 @@ -1,3 +1,13 @@ +2002-05-03 David Emory Watson <[email protected]> + + * libgnomevfs/gnome-vfs-uri.c: + (gnome_vfs_uri_extract_dirname): Should return URI_PATH_STR whenever + there is only one URI_PATH_CHR in the uri (and it occurs at the + begining), not just when the string equals URI_PATH_CHR. + * test/test-uri.c: + (test_uri_extract_dirname): New. + (main): Update. + 2002-05-02 Bastien Nocera <[email protected]> * test/test-directory.c: (show_result): Index: libgnomevfs/gnome-vfs-uri.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-uri.c,v retrieving revision 1.102 diff -p -u -r1.102 gnome-vfs-uri.c --- libgnomevfs/gnome-vfs-uri.c 5 Nov 2001 08:06:59 -0000 1.102 +++ libgnomevfs/gnome-vfs-uri.c 4 May 2002 15:25:01 -0000 @@ -1644,7 +1644,7 @@ gnome_vfs_uri_extract_dirname (const Gno base = strrchr (uri->text, GNOME_VFS_URI_PATH_CHR); - if (base == NULL || base[1] == '\0') { + if (base == NULL || base == uri->text) { return g_strdup (GNOME_VFS_URI_PATH_STR); } Index: test/test-uri.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/test/test-uri.c,v retrieving revision 1.34 diff -p -u -r1.34 test-uri.c --- test/test-uri.c 3 Aug 2001 19:04:43 -0000 1.34 +++ test/test-uri.c 4 May 2002 15:25:01 -0000 @@ -206,6 +206,29 @@ test_uri_has_fragment_id (const char *in } static void +test_uri_extract_dirname (const char *input, + const char *expected_output) +{ + GnomeVFSURI *uri; + char *output; + + uri = gnome_vfs_uri_new (input); + if (uri == NULL) { + output = g_strdup ("NULL"); + } else { + output = gnome_vfs_uri_extract_dirname (uri); + } + + if (strcmp (output, expected_output) != 0) { + test_failed ("test_uri_extract_dirname (%s) resulted in %s instead of %s", + input, output, expected_output); + } + + g_free (output); + gnome_vfs_uri_unref (uri); +} + +static void test_uri_parent (const char *input, const char *expected_output) { @@ -584,6 +607,11 @@ main (int argc, char **argv) test_uri_to_string ("/tmp/#junk#", "file:///tmp/#junk#", GNOME_VFS_URI_HIDE_NONE); test_uri_has_fragment_id ("/tmp/#junk", "junk"); test_uri_has_fragment_id ("/tmp/#junk#", "junk#"); + + /* Test gnome_vfs_uri_extract_dirname (). */ + test_uri_extract_dirname ("/", "/"); + test_uri_extract_dirname ("/usr", "/"); + test_uri_extract_dirname ("/usr/bin", "/usr"); /* test a escaping->unescaping round trip for funny characters */ test_file_path_to_uri_string ("/tmp/#backup_file#", "file:///tmp/#backup_file#", GNOME_VFS_URI_HIDE_NONE);