From 6a1b8e691fdd413578bb9e315f34a53369f111ed Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 14 Sep 2016 19:57:14 +0200 Subject: [PATCH] fixes #4764, fixes #4731, fixes #4724 --- compiler/scriptconfig.nim | 1 + install_nimble.nims | 6 +++++- lib/pure/os.nim | 4 ++-- lib/system/gc.nim | 2 ++ lib/windows/winlean.nim | 10 ++++------ 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim index 0f1dfaa1ed..f04cef0ee1 100644 --- a/compiler/scriptconfig.nim +++ b/compiler/scriptconfig.nim @@ -43,6 +43,7 @@ proc setupVM*(module: PSym; scriptName: string): PEvalContext = template cbos(name, body) {.dirty.} = result.registerCallback "stdlib.system." & astToStr(name), proc (a: VmArgs) = + errorMsg = nil try: body except OSError: diff --git a/install_nimble.nims b/install_nimble.nims index 5d028726be..05024c046e 100644 --- a/install_nimble.nims +++ b/install_nimble.nims @@ -16,4 +16,8 @@ mkDir "bin/nimblepkg" for file in listFiles("nimble" & $id & "/src/nimblepkg/"): cpFile file, "bin/nimblepkg/" & file.extractFilename -mvFile "nimble" & $id & "/src/nimble".toExe, "bin/nimble".toExe +try: + mvFile "nimble" & $id & "/src/nimble".toExe, "bin/nimble".toExe +except OSError: + cpFile "nimble" & $id & "/src/nimble".toExe, "bin/nimble".toExe + diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 343c82f5e4..d9ae5a1e62 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -580,9 +580,9 @@ proc moveFile*(source, dest: string) {.rtl, extern: "nos$1", when useWinUnicode: let s = newWideCString(source) let d = newWideCString(dest) - if moveFileW(s, d, 0'i32) == 0'i32: raiseOSError(osLastError()) + if moveFileW(s, d) == 0'i32: raiseOSError(osLastError()) else: - if moveFileA(source, dest, 0'i32) == 0'i32: raiseOSError(osLastError()) + if moveFileA(source, dest) == 0'i32: raiseOSError(osLastError()) else: if c_rename(source, dest) != 0'i32: raiseOSError(osLastError(), $strerror(errno)) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index ba6b2fcf9f..11897ce806 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -116,6 +116,8 @@ template gcAssert(cond: bool, msg: string) = echo "[GCASSERT] ", msg GC_disable() writeStackTrace() + #var x: ptr int + #echo x[] quit 1 proc addZCT(s: var CellSeq, c: PCell) {.noinline.} = diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index b766ead9cd..2441c72679 100644 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -337,11 +337,10 @@ when useWinUnicode: stdcall, dynlib: "kernel32", importc: "SetFileAttributesW".} proc copyFileW*(lpExistingFileName, lpNewFileName: WideCString, - bFailIfExists: cint): cint {. + bFailIfExists: WINBOOL): WINBOOL {. importc: "CopyFileW", stdcall, dynlib: "kernel32".} - proc moveFileW*(lpExistingFileName, lpNewFileName: WideCString, - bFailIfExists: cint): cint {. + proc moveFileW*(lpExistingFileName, lpNewFileName: WideCString): WINBOOL {. importc: "MoveFileW", stdcall, dynlib: "kernel32".} proc getEnvironmentStringsW*(): WideCString {. @@ -368,8 +367,7 @@ else: bFailIfExists: cint): cint {. importc: "CopyFileA", stdcall, dynlib: "kernel32".} - proc moveFileA*(lpExistingFileName, lpNewFileName: cstring, - bFailIfExists: cint): cint {. + proc moveFileA*(lpExistingFileName, lpNewFileName: cstring): WINBOOL {. importc: "MoveFileA", stdcall, dynlib: "kernel32".} proc getEnvironmentStringsA*(): cstring {. @@ -1035,4 +1033,4 @@ when defined(useWinAnsi): else: proc readConsoleInput*(hConsoleInput: Handle, lpBuffer: pointer, nLength: cint, lpNumberOfEventsRead: ptr cint): cint - {.stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".} \ No newline at end of file + {.stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".}