diff options
-rw-r--r-- | compiler/options.nim | 10 | ||||
-rw-r--r-- | compiler/pretty.nim | 28 | ||||
-rw-r--r-- | compiler/prettybase.nim | 6 | ||||
-rw-r--r-- | lib/pure/os.nim | 5 |
4 files changed, 31 insertions, 18 deletions
diff --git a/compiler/options.nim b/compiler/options.nim index cb2173554..69067b7c4 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -337,6 +337,16 @@ proc findFile*(f: string): string {.procvar.} = proc findModule*(modulename, currentModule: string): string = # returns path to module + when defined(nimfix): + # '.nimfix' modules are preferred over '.nim' modules so that specialized + # versions can be kept for 'nimfix'. + block: + let m = addFileExt(modulename, "nimfix") + let currentPath = currentModule.splitFile.dir + result = currentPath / m + if not existsFile(result): + result = findFile(m) + if existsFile(result): return result let m = addFileExt(modulename, NimExt) let currentPath = currentModule.splitFile.dir result = currentPath / m diff --git a/compiler/pretty.nim b/compiler/pretty.nim index b7265b946..436181bbc 100644 --- a/compiler/pretty.nim +++ b/compiler/pretty.nim @@ -31,20 +31,20 @@ type proc overwriteFiles*() = let doStrip = options.getConfigVar("pretty.strip").normalize == "on" for i in 0 .. high(gSourceFiles): - if not gSourceFiles[i].dirty: continue - let newFile = if gOverWrite: gSourceFiles[i].fullpath - else: gSourceFiles[i].fullpath.changeFileExt(".pretty.nim") - try: - var f = open(newFile, fmWrite) - for line in gSourceFiles[i].lines: - if doStrip: - f.write line.strip(leading = false, trailing = true) - else: - f.write line - f.write("\L") - f.close - except IOError: - rawMessage(errCannotOpenFile, newFile) + if gSourceFiles[i].dirty and not gSourceFiles[i].isNimfixFile: + let newFile = if gOverWrite: gSourceFiles[i].fullpath + else: gSourceFiles[i].fullpath.changeFileExt(".pretty.nim") + try: + var f = open(newFile, fmWrite) + for line in gSourceFiles[i].lines: + if doStrip: + f.write line.strip(leading = false, trailing = true) + else: + f.write line + f.write("\L") + f.close + except IOError: + rawMessage(errCannotOpenFile, newFile) proc `=~`(s: string, a: openArray[string]): bool = for x in a: diff --git a/compiler/prettybase.nim b/compiler/prettybase.nim index eb0cf983d..e3c1e6ae9 100644 --- a/compiler/prettybase.nim +++ b/compiler/prettybase.nim @@ -8,11 +8,12 @@ # import ast, msgs, strutils, idents +from os import splitFile type TSourceFile* = object lines*: seq[string] - dirty*: bool + dirty*, isNimfixFile*: bool fullpath*: string var @@ -26,7 +27,8 @@ proc loadFile*(info: TLineInfo) = gSourceFiles[i].lines = @[] let path = info.toFullPath gSourceFiles[i].fullpath = path - # we want to die here for EIO: + gSourceFiles[i].isNimfixFile = path.splitFile.ext == "nimfix" + # we want to die here for IOError: for line in lines(path): gSourceFiles[i].lines.add(line) diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 8227c92b2..6b3ee6e6d 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -187,7 +187,7 @@ proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} = ## On Windows ``GetLastError`` is checked before ``errno``. ## Returns "" if no error occured. ## - ## **Deprecated since version 0.9.4**: use the other ``OSErrorMsg`` proc. + ## **Deprecated since version 0.9.4**: use the other ``osErrorMsg`` proc. result = "" when defined(Windows): @@ -225,7 +225,8 @@ proc raiseOSError*(msg: string = "") {.noinline, rtl, extern: "nos$1", raise newException(OSError, msg) {.pop.} -{.deprecated: [osError: raiseOSError].} +when not defined(nimfix): + {.deprecated: [osError: raiseOSError].} proc `==`*(err1, err2: OSErrorCode): bool {.borrow.} proc `$`*(err: OSErrorCode): string {.borrow.} |