Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Test cwd_and_chdir: don't chdir to "" or "c:"

It should not strip the trailing (back)slash from a root directory.
  • Loading branch information...
commit 09a0d61e7bd4965f0a2d9219943b7eff9c3d9944 1 parent 422a898
@piscisaureus piscisaureus authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 test/test-cwd-and-chdir.c
View
21 test/test-cwd-and-chdir.c
@@ -37,17 +37,20 @@ TEST_IMPL(cwd_and_chdir) {
err = uv_cwd(buffer_orig, size);
ASSERT(err.code == UV_OK);
- last_slash = strrchr(buffer_orig,
+ /* Remove trailing slash unless at a root directory. */
#ifdef _WIN32
- '\\'
-#else
- '/'
-#endif
- );
-
+ last_slash = strrchr(buffer_orig, '\\');
ASSERT(last_slash);
-
- *last_slash = '\0';
+ if (last_slash > buffer_orig && *(last_slash - 1) != ':') {
+ *last_slash = '\0';
+ }
+#else /* Unix */
+ last_slash = strrchr(buffer_orig, '/');
+ ASSERT(last_slash);
+ if (last_slash != buffer_orig) {
+ *last_slash = '\0';
+ }
+#endif
err = uv_chdir(buffer_orig);
ASSERT(err.code == UV_OK);
Please sign in to comment.
Something went wrong with that request. Please try again.