even more strict isNil handling for strings/seqs in order to detect bugs

This commit is contained in:
Araq 2018-08-22 12:35:46 +02:00
commit 64517445ea
36 changed files with 193 additions and 245 deletions

View file

@ -233,7 +233,7 @@ proc fileNewer*(a, b: string): bool {.rtl, extern: "nos$1".} =
## modification time is later than `b`'s.
when defined(posix):
# If we don't have access to nanosecond resolution, use '>='
when not StatHasNanoseconds:
when not StatHasNanoseconds:
result = getLastModificationTime(a) >= getLastModificationTime(b)
else:
result = getLastModificationTime(a) > getLastModificationTime(b)
@ -1343,16 +1343,21 @@ elif defined(windows):
# is always the same -- independent of the used C compiler.
var
ownArgv {.threadvar.}: seq[string]
ownParsedArgv {.threadvar.}: bool
proc paramCount*(): int {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
# Docstring in nimdoc block.
if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLine())
if not ownParsedArgv:
ownArgv = parseCmdLine($getCommandLine())
ownParsedArgv = true
result = ownArgv.len-1
proc paramStr*(i: int): TaintedString {.rtl, extern: "nos$1",
tags: [ReadIOEffect].} =
# Docstring in nimdoc block.
if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLine())
if not ownParsedArgv:
ownArgv = parseCmdLine($getCommandLine())
ownParsedArgv = true
if i < ownArgv.len and i >= 0: return TaintedString(ownArgv[i])
raise newException(IndexError, "invalid index")