summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-09-07 19:20:44 +0200
committerAraq <rumpf_a@web.de>2018-09-07 19:21:17 +0200
commitf078f272e5080d2b0983b53750e9d0b2d63c5e02 (patch)
tree892e831cd2a66d6fecc9c35ba87de4b5f1d6d578 /compiler
parente06a89e11234e8882a4021d8d7cad0883c431f86 (diff)
downloadNim-f078f272e5080d2b0983b53750e9d0b2d63c5e02.tar.gz
make tests green again
Diffstat (limited to 'compiler')
-rw-r--r--compiler/layouter.nim7
-rw-r--r--compiler/pathutils.nim11
2 files changed, 12 insertions, 6 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim
index 36ad08696..cc6ec48b7 100644
--- a/compiler/layouter.nim
+++ b/compiler/layouter.nim
@@ -9,7 +9,8 @@
 
 ## Layouter for nimpretty.
 
-import idents, lexer, lineinfos, llstream, options, msgs, strutils
+import idents, lexer, lineinfos, llstream, options, msgs, strutils,
+  pathutils
 from os import changeFileExt
 
 const
@@ -39,7 +40,7 @@ type
 
 proc openEmitter*(em: var Emitter, cache: IdentCache;
                   config: ConfigRef, fileIdx: FileIndex) =
-  let fullPath = config.toFullPath(fileIdx)
+  let fullPath = Absolutefile config.toFullPath(fileIdx)
   em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
                                cache, config)
   if em.indWidth == 0: em.indWidth = 2
@@ -55,7 +56,7 @@ proc openEmitter*(em: var Emitter, cache: IdentCache;
 proc closeEmitter*(em: var Emitter) =
   var f = llStreamOpen(em.config.outFile, fmWrite)
   if f == nil:
-    rawMessage(em.config, errGenerated, "cannot open file: " & em.config.outFile)
+    rawMessage(em.config, errGenerated, "cannot open file: " & em.config.outFile.string)
   f.llStreamWrite em.content
   llStreamClose(f)
 
diff --git a/compiler/pathutils.nim b/compiler/pathutils.nim
index b27981159..e5317d5c3 100644
--- a/compiler/pathutils.nim
+++ b/compiler/pathutils.nim
@@ -111,11 +111,12 @@ proc canon(x: string; result: var string; state: var int) =
       # f/..
       while d > (state and 1) and result[d-1] != DirSep:
         dec d
-      setLen(result, d)
+      setLen(result, d-1)
     elif isDot(x, b):
       discard "discard the dot"
-    else:
-      if result.len > (state and 1): result.add DirSep
+    elif b[1] > b[0]:
+      if result.len > 0 and result[^1] != DirSep:
+        result.add DirSep
       result.add substr(x, b[0], b[1])
     inc state, 2
 
@@ -253,3 +254,7 @@ when isMainModule and defined(posix):
 
   doAssert AbsoluteDir"/Users/me///" / RelativeFile"z.nim" == AbsoluteFile"/Users/me/z.nim"
   doAssert relativeTo("/foo/bar.nim", "/foo/") == "bar.nim"
+
+when isMainModule and defined(windows):
+  let nasty = string(AbsoluteDir(r"C:\Users\rumpf\projects\nim\tests\nimble\nimbleDir\linkedPkgs\pkgB-#head\../../simplePkgs/pkgB-#head/") / RelativeFile"pkgA/module.nim")
+  doAssert nasty == r"C:\Users\rumpf\projects\nim\tests\nimble\nimbleDir\simplePkgs\pkgB-#head\pkgA\module.nim"