diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2014-07-26 02:15:14 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2014-07-26 02:15:14 +0100 |
commit | f59d76a59e73f4b9697796535929d9337936cdd4 (patch) | |
tree | 4e87337723e6661149007d6529def319b8ff513e /lib | |
parent | 030c2d6deb6f8538627009ad4fc77e56e4f2b714 (diff) | |
parent | ba394e6d3649839d73c5ae3a12e6f1ff6d66e802 (diff) | |
download | Nim-f59d76a59e73f4b9697796535929d9337936cdd4.tar.gz |
Merge branch 'devel' of github.com:Araq/Nimrod into devel
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/collections/tables.nim | 7 | ||||
-rw-r--r-- | lib/pure/json.nim | 8 | ||||
-rw-r--r-- | lib/pure/osproc.nim | 4 |
3 files changed, 13 insertions, 6 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index ce9df09e1..dcf2ab481 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -246,7 +246,8 @@ template equalsImpl() = # different insertion orders mean different 'data' seqs, so we have # to use the slow route here: for key, val in s: - if not hasKey(t, key): return false + # prefix notation leads to automatic dereference in case of PTable + if not t.hasKey(key): return false if t[key] != val: return false return true @@ -332,7 +333,9 @@ proc `$`*[A, B](t: PTable[A, B]): string = dollarImpl() proc `==`*[A, B](s, t: PTable[A, B]): bool = - equalsImpl() + if isNil(s): result = isNil(t) + elif isNil(t): result = false + else: result = equalsImpl() proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): PTable[C, B] = ## Index the collection with the proc provided. diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 508e564c5..a45900f29 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -621,9 +621,13 @@ proc `%`*(elements: openArray[PJsonNode]): PJsonNode = proc `==`* (a,b: PJsonNode): bool = ## Check two nodes for equality - if a.kind != b.kind: false + if a.isNil: + if b.isNil: return true + return false + elif b.isNil or a.kind != b.kind: + return false else: - case a.kind + return case a.kind of JString: a.str == b.str of JInt: diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 04a0c2403..c74fa1ceb 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -763,7 +763,7 @@ elif not defined(useNimRtl): discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error)) exitnow(1) - when defined(macosx): + when defined(macosx) or defined(freebsd): var environ {.importc.}: cstringArray proc startProcessAfterFork(data: ptr TStartProcessData) = @@ -793,7 +793,7 @@ elif not defined(useNimRtl): discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC) if data.optionPoUsePath: - when defined(macosx): + when defined(macosx) or defined(freebsd): # MacOSX doesn't have execvpe, so we need workaround. # On MacOSX we can arrive here only from fork, so this is safe: environ = data.sysEnv |