diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/collections/tables.nim | 2 | ||||
-rw-r--r-- | lib/pure/ftpclient.nim | 2 | ||||
-rw-r--r-- | lib/pure/httpclient.nim | 3 | ||||
-rw-r--r-- | lib/pure/irc.nim | 2 | ||||
-rw-r--r-- | lib/pure/osproc.nim | 10 | ||||
-rw-r--r-- | lib/pure/scgi.nim | 1 | ||||
-rw-r--r-- | lib/pure/selectors.nim | 1 | ||||
-rw-r--r-- | lib/system/debugger.nim | 2 | ||||
-rw-r--r-- | lib/wrappers/sqlite3.nim | 1 |
9 files changed, 20 insertions, 4 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 412bebeee..cd28f9af0 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -196,7 +196,7 @@ proc `==`*[A, B](s, t: TTable[A, B]): bool = # to use the slow route here: for key, val in s: if not hasKey(t, key): return false - if mget(t, key) != val: return false + if t[key] != val: return false return true proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): TTable[C, B] = diff --git a/lib/pure/ftpclient.nim b/lib/pure/ftpclient.nim index f136e0016..3bb55239b 100644 --- a/lib/pure/ftpclient.nim +++ b/lib/pure/ftpclient.nim @@ -107,6 +107,7 @@ proc ftpClient*(address: string, port = TPort(21), result.isAsync = false result.dsockConnected = false result.csock = socket() + if result.csock == InvalidSocket: osError(osLastError()) proc getDSock(ftp: PFTPClient): TSocket = if ftp.isAsync: return ftp.asyncDSock else: return ftp.dsock @@ -213,6 +214,7 @@ proc pasv(ftp: PFTPClient) = ## Negotiate a data connection. if not ftp.isAsync: ftp.dsock = socket() + if ftp.dsock == InvalidSocket: osError(osLastError()) else: ftp.asyncDSock = AsyncSocket() ftp.asyncDSock.handleRead = diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 2a145eb89..be06a7b8e 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -75,7 +75,7 @@ ## constructor should be used for this purpose. However, ## currently only basic authentication is supported. -import sockets, strutils, parseurl, parseutils, strtabs, base64 +import sockets, strutils, parseurl, parseutils, strtabs, base64, os import asyncnet, asyncdispatch import rawsockets @@ -288,6 +288,7 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "", add(headers, "\c\L") var s = socket() + if s == InvalidSocket: osError(osLastError()) var port = sockets.TPort(80) if r.scheme == "https": when defined(ssl): diff --git a/lib/pure/irc.nim b/lib/pure/irc.nim index 83fb231f6..31a673210 100644 --- a/lib/pure/irc.nim +++ b/lib/pure/irc.nim @@ -249,6 +249,7 @@ proc reconnect*(irc: PIRC, timeout = 5000) = if secSinceReconnect < timeout: sleep(timeout - secSinceReconnect) irc.sock = socket() + if irc.sock == InvalidSocket: osError(osLastError()) irc.connect() irc.lastReconnect = epochTime() @@ -274,6 +275,7 @@ proc irc*(address: string, port: TPort = 6667.TPort, result.messageBuffer = @[] result.status = SockIdle result.sock = socket() + if result.sock == InvalidSocket: osError(osLastError()) proc processLine(irc: PIRC, line: string): TIRCEvent = if line.len == 0: diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 5d6848565..ed83507d4 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -137,6 +137,14 @@ proc startProcess*(command: string, ## to `startProcess`. See the documentation of ``TProcessOption`` for the ## meaning of these flags. You need to `close` the process when done. ## + ## Note that you can't pass any `args` if you use the option + ## ``poEvalCommand``, which invokes the system shell to run the specified + ## `command`. In this situation you have to concatenate manually the contents + ## of `args` to `command` carefully escaping/quoting any special characters, + ## since it will be passed *as is* to the system shell. Each system/shell may + ## feature different escaping rules, so try to avoid this kind of shell + ## invokation if possible as it leads to non portable software. + ## ## Return value: The newly created process object. Nil is never returned, ## but ``EOS`` is raised in case of an error. @@ -633,7 +641,7 @@ elif not defined(useNimRtl): if poEvalCommand in options: sysCommand = "/bin/sh" sysArgsRaw = @[sysCommand, "-c", command] - assert args.len == 0 + assert args.len == 0, "`args` has to be empty when using poEvalCommand." else: sysCommand = command sysArgsRaw = @[command] diff --git a/lib/pure/scgi.nim b/lib/pure/scgi.nim index 04b77fafe..a6a0faabc 100644 --- a/lib/pure/scgi.nim +++ b/lib/pure/scgi.nim @@ -102,6 +102,7 @@ proc open*(s: var TScgiState, port = TPort(4000), address = "127.0.0.1", s.input = newString(s.buflen) # will be reused s.server = socket() + if s.server == InvalidSocket: osError(osLastError()) new(s.client) # Initialise s.client for `next` if s.server == InvalidSocket: scgiError("could not open socket") #s.server.connect(connectionName, port) diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index a4a7b5afd..f630ba235 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -238,6 +238,7 @@ when isMainModule: sock: TSocket var sock = socket() + if sock == sockets.InvalidSocket: osError(osLastError()) #sock.setBlocking(false) sock.connect("irc.freenode.net", TPort(6667)) diff --git a/lib/system/debugger.nim b/lib/system/debugger.nim index b5cb5e9ba..af7b6d515 100644 --- a/lib/system/debugger.nim +++ b/lib/system/debugger.nim @@ -178,7 +178,7 @@ proc hash(data: pointer, size: int): THash = while s > 0: h = h !& ord(p[i]) inc(i) - cec(s) + dec(s) result = !$h proc hashGcHeader(data: pointer): THash = diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim index 8ff1da1d1..586f763ae 100644 --- a/lib/wrappers/sqlite3.nim +++ b/lib/wrappers/sqlite3.nim @@ -90,6 +90,7 @@ const SQLITE_IGNORE* = 2 # Original from sqlite3.h: ##define SQLITE_STATIC ((void(*)(void *))0) ##define SQLITE_TRANSIENT ((void(*)(void *))-1) + SQLITE_DETERMINISTIC* = 0x800 const SQLITE_STATIC* = nil |