summary refs log tree commit diff stats
path: root/lib/pure/pathnorm.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-12-13 16:18:43 +0100
committerAraq <rumpf_a@web.de>2018-12-13 16:19:00 +0100
commit5b39c7aca91c1d20eb81425cf8f3854876aed475 (patch)
treeff4943dca92804db14fb80bebdb3d0c7787dfe46 /lib/pure/pathnorm.nim
parent5d34dec97d8ba330a9614d331504c0bb2e867fba (diff)
downloadNim-5b39c7aca91c1d20eb81425cf8f3854876aed475.tar.gz
fixes joinPath regressions
Diffstat (limited to 'lib/pure/pathnorm.nim')
-rw-r--r--lib/pure/pathnorm.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/pure/pathnorm.nim b/lib/pure/pathnorm.nim
index 696f6b2ef..a33afefbd 100644
--- a/lib/pure/pathnorm.nim
+++ b/lib/pure/pathnorm.nim
@@ -57,7 +57,12 @@ proc addNormalizePath*(x: string; result: var string; state: var int; dirSep = D
 
   # state: 0th bit set if isAbsolute path. Other bits count
   # the number of path components.
-  for b in dirs(x):
+  var it: PathIter
+  it.notFirst = (state shr 1) > 0
+  if it.notFirst:
+    while it.i < x.len and x[it.i] in {DirSep, AltSep}: inc it.i
+  while hasNext(it, x):
+    let b = next(it, x)
     if (state shr 1 == 0) and isSlash(x, b):
       result.add dirSep
       state = state or 1