Merge branch 'master' of git@github.com:Araq/Nimrod

This commit is contained in:
Araq
2011-05-22 21:15:40 +02:00
5 changed files with 1490 additions and 980 deletions

View File

@@ -471,7 +471,8 @@ elif not defined(useNimRtl):
p_stdin, p_stdout, p_stderr: array [0..1, cint]
new(result)
result.exitCode = -3 # for ``waitForExit``
if pipe(p_stdin) != 0'i32 or pipe(p_stdout) != 0'i32:
if pipe(p_stdin) != 0'i32 or pipe(p_stdout) != 0'i32 or
pipe(p_stderr) != 0'i32:
OSError("failed to create a pipe")
var Pid = fork()
if Pid < 0:
@@ -484,9 +485,9 @@ elif not defined(useNimRtl):
discard close(p_stdout[readIdx])
if dup2(p_stdout[writeIdx], writeIdx) < 0: OSError()
if poStdErrToStdOut in options:
discard close(p_stderr[readIdx])
if dup2(p_stdout[writeIdx], 2) < 0: OSError()
else:
if pipe(p_stderr) != 0'i32: OSError("failed to create a pipe")
discard close(p_stderr[readIdx])
if dup2(p_stderr[writeIdx], 2) < 0: OSError()

View File

@@ -846,6 +846,19 @@ proc slaveof*(r: TRedis, host: string, port: string) =
r.sendCommand("SLAVEOF", host, port)
raiseNoOK(r.parseStatus())
iterator hPairs*(r: TRedis, key: string): tuple[key, value: string] =
## Iterator for keys and values in a hash.
var
contents = r.hGetAll(key)
k = ""
for i in items(contents):
if k == "":
k = i
else:
yield (k, i)
k = ""
when false:
# sorry, deactivated for the test suite
var r = open()