parent
13d292786e
commit
3dad130034
4 changed files with 10 additions and 2 deletions
|
|
@ -129,3 +129,5 @@
|
||||||
|
|
||||||
- The `FD` variant of `selector.unregister` for `ioselector_epoll` and
|
- The `FD` variant of `selector.unregister` for `ioselector_epoll` and
|
||||||
`ioselector_select` now properly handle the `Event.User` select event type.
|
`ioselector_select` now properly handle the `Event.User` select event type.
|
||||||
|
- `joinPath` path normalization when `/` is the first argument works correctly:
|
||||||
|
`assert "/" / "/a" == "/a"`. Fixed the edgecase: `assert "" / "" == ""`.
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ proc joinPath*(head, tail: string): string {.
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
assert joinPath("usr", "lib") == "usr/lib"
|
assert joinPath("usr", "lib") == "usr/lib"
|
||||||
assert joinPath("usr", "") == "usr/"
|
assert joinPath("usr", "") == "usr/"
|
||||||
|
assert joinPath("", "") == ""
|
||||||
assert joinPath("", "lib") == "lib"
|
assert joinPath("", "lib") == "lib"
|
||||||
assert joinPath("", "/lib") == "/lib"
|
assert joinPath("", "/lib") == "/lib"
|
||||||
assert joinPath("usr/", "/lib") == "usr/lib"
|
assert joinPath("usr/", "/lib") == "usr/lib"
|
||||||
|
|
@ -149,7 +150,7 @@ proc joinPath*(head, tail: string): string {.
|
||||||
result = newStringOfCap(head.len + tail.len)
|
result = newStringOfCap(head.len + tail.len)
|
||||||
var state = 0
|
var state = 0
|
||||||
addNormalizePath(head, result, state, DirSep)
|
addNormalizePath(head, result, state, DirSep)
|
||||||
if tail.len == 0:
|
if result.len != 0 and result[^1] notin {DirSep, AltSep} and tail.len == 0:
|
||||||
result.add DirSep
|
result.add DirSep
|
||||||
else:
|
else:
|
||||||
addNormalizePath(tail, result, state, DirSep)
|
addNormalizePath(tail, result, state, DirSep)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,8 @@ proc addNormalizePath*(x: string; result: var string; state: var int;
|
||||||
while hasNext(it, x):
|
while hasNext(it, x):
|
||||||
let b = next(it, x)
|
let b = next(it, x)
|
||||||
if (state shr 1 == 0) and isSlash(x, b):
|
if (state shr 1 == 0) and isSlash(x, b):
|
||||||
result.add dirSep
|
if result.len == 0 or result[^1] notin {DirSep, AltSep}:
|
||||||
|
result.add dirSep
|
||||||
state = state or 1
|
state = state or 1
|
||||||
elif isDotDot(x, b):
|
elif isDotDot(x, b):
|
||||||
if (state shr 1) >= 1:
|
if (state shr 1) >= 1:
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,10 @@ block ospaths:
|
||||||
doAssert joinPath("", "lib") == "lib"
|
doAssert joinPath("", "lib") == "lib"
|
||||||
doAssert joinPath("", "/lib") == unixToNativePath"/lib"
|
doAssert joinPath("", "/lib") == unixToNativePath"/lib"
|
||||||
doAssert joinPath("usr/", "/lib") == unixToNativePath"usr/lib"
|
doAssert joinPath("usr/", "/lib") == unixToNativePath"usr/lib"
|
||||||
|
doAssert joinPath("", "") == unixToNativePath""
|
||||||
|
doAssert joinPath("/" / "") == unixToNativePath"/"
|
||||||
|
doAssert joinPath("/", "/a/b/c") == unixToNativePath"/a/b/c"
|
||||||
|
doAssert joinPath("foo/","") == unixToNativePath"foo/"
|
||||||
|
|
||||||
block getTempDir:
|
block getTempDir:
|
||||||
block TMPDIR:
|
block TMPDIR:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue