commit dff73d26f3a6c9d7011ad98a6752129a37625a10
Merge: fc08422 b86c562
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Thu May 31 16:21:54 2012 -0400
Merge remote-tracking branch 'public/bug5089'
Conflicts:
src/test/test_util.c
Merge the unit tests; I added some when I did this branch against
0.2.2, and then the test format changed and master added more tests.
changes/bug5089 | 5 +++++
src/common/compat.c | 13 +++++++++++--
src/test/test_util.c | 16 ++++++----------
3 files changed, 22 insertions(+), 12 deletions(-)
diff --cc src/common/compat.c
index 59c7ca4,ffd9724..0931061
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@@ -1678,9 -1507,9 +1682,9 @@@ get_parent_directory(char *fname
*/
cp = fname + strlen(fname);
at_end = 1;
- while (--cp > fname) {
+ while (--cp >= fname) {
int is_sep = (*cp == '/'
-#ifdef MS_WINDOWS
+#ifdef _WIN32
|| *cp == '\\'
#endif
);
diff --cc src/test/test_util.c
index 99c5544,a393079..e052692
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@@ -2080,35 -1297,17 +2080,31 @@@ test_util_parent_dir(void *ptr
tor_free(cp); \
} while (0);
- T("/home/wombat/knish", 0, "/home/wombat");
- T("/home/wombat/knish/", 0, "/home/wombat");
- T("/home", 0, "/");
- T("./home/wombat/knish/", 0, "./home/wombat");
- T("./wombat", 0, ".");
+ T("/home/wombat", 0, "/home/wombat/knish");
+ T("/home/wombat", 0, "/home/wombat/knish/");
+ T("/home/wombat", 0, "/home/wombat/knish///");
+ T("./home/wombat", 0, "./home/wombat/knish/");
- #if 0
+ T("/", 0, "/home");
+ T("/", 0, "/home//");
- #endif
+ T(".", 0, "./wombat");
+ T(".", 0, "./wombat/");
+ T(".", 0, "./wombat//");
+ T("wombat", 0, "wombat/foo");
+ T("wombat/..", 0, "wombat/../foo");
+ T("wombat/../", 0, "wombat/..//foo"); /* Is this correct? */
+ T("wombat/.", 0, "wombat/./foo");
+ T("wombat/./", 0, "wombat/.//foo"); /* Is this correct? */
+ T("wombat", 0, "wombat/..//");
+ T("wombat", 0, "wombat/foo/");
+ T("wombat", 0, "wombat/.foo");
+ T("wombat", 0, "wombat/.foo/");
+
- T("", -1, "");
- T("", -1, ".");
- T("", -1, "..");
- T("", -1, "../");
- T("", -1, "/");
- T("", -1, "////");
- T("", -1, "wombat");
- T("", -1, "wombat/");
+ T("wombat", -1, "");
+ T("w", -1, "");
- T("wombat/knish", 0, "wombat");
- T("", -1, "");
++ T("wombat", 0, "wombat/knish");
++
+ T("/", 0, "/");
- T("////", 0, "/");
++ T("/", 0, "////");
done:
tor_free(cp);