diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-09-11 16:41:34 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-09-11 16:41:34 +0200 |
commit | af94946517d4e07e91b5c5ca21d58645f6da86c4 (patch) | |
tree | a393b463691766cac615049e772fab9966477270 /lib/pure | |
parent | 49708d9c2564762904e2405135926afe55a48009 (diff) | |
parent | 9ba80d204407cafeaf195dbe7b144b16b84dca6e (diff) | |
download | Nim-af94946517d4e07e91b5c5ca21d58645f6da86c4.tar.gz |
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/asyncdispatch.nim | 6 | ||||
-rw-r--r-- | lib/pure/asyncmacro.nim | 2 | ||||
-rw-r--r-- | lib/pure/memfiles.nim | 1 | ||||
-rw-r--r-- | lib/pure/strscans.nim | 6 | ||||
-rw-r--r-- | lib/pure/strutils.nim | 2 |
5 files changed, 10 insertions, 7 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index 093bf58af..820f34703 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -1536,7 +1536,11 @@ proc withTimeout*[T](fut: Future[T], timeout: int): Future[bool] = var timeoutFuture = sleepAsync(timeout) fut.callback = proc () = - if not retFuture.finished: retFuture.complete(true) + if not retFuture.finished: + if fut.failed: + retFuture.fail(fut.error) + else: + retFuture.complete(true) timeoutFuture.callback = proc () = if not retFuture.finished: retFuture.complete(false) diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index 4665ad25f..9e0893a4d 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -327,8 +327,8 @@ macro async*(prc: untyped): untyped = ## Macro which processes async procedures into the appropriate ## iterators and yield statements. if prc.kind == nnkStmtList: + result = newStmtList() for oneProc in prc: - result = newStmtList() result.add asyncSingleProc(oneProc) else: result = asyncSingleProc(prc) diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim index 0249b7413..9fccd08d4 100644 --- a/lib/pure/memfiles.nim +++ b/lib/pure/memfiles.nim @@ -328,7 +328,6 @@ proc `$`*(ms: MemSlice): string {.inline.} = ## Return a Nim string built from a MemSlice. var buf = newString(ms.size) copyMem(addr(buf[0]), ms.data, ms.size) - buf[ms.size] = '\0' result = buf iterator memSlices*(mfile: MemFile, delim='\l', eat='\r'): MemSlice {.inline.} = diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 11f182495..b17eee6ff 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -10,7 +10,7 @@ ##[ This module contains a `scanf`:idx: macro that can be used for extracting substrings from an input string. This is often easier than regular expressions. -Some examples as an apetizer: +Some examples as an appetizer: .. code-block:: nim # check if input string matches a triple of integers: @@ -308,7 +308,7 @@ proc buildUserCall(x: string; args: varargs[NimNode]): NimNode = for i in 1..<y.len: result.add y[i] macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): bool = - ## See top level documentation of his module of how ``scanf`` works. + ## See top level documentation of this module about how ``scanf`` works. template matchBind(parser) {.dirty.} = var resLen = genSym(nskLet, "resLen") conds.add newLetStmt(resLen, newCall(bindSym(parser), inp, results[i], idx)) @@ -469,7 +469,7 @@ template success*(x: int): bool = x != 0 template nxt*(input: string; idx, step: int = 1) = inc(idx, step) macro scanp*(input, idx: typed; pattern: varargs[untyped]): bool = - ## See top level documentation of his module of how ``scanf`` works. + ## See top level documentation of this module about how ``scanp`` works. type StmtTriple = tuple[init, cond, action: NimNode] template interf(x): untyped = bindSym(x, brForceOpen) diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 7730aa7a2..396f14972 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -820,7 +820,7 @@ proc toHex*(x: BiggestInt, len: Positive): string {.noSideEffect, # handle negative overflow if n == 0 and x < 0: n = -1 -proc toHex*[T](x: T): string = +proc toHex*[T: SomeInteger](x: T): string = ## Shortcut for ``toHex(x, T.sizeOf * 2)`` toHex(BiggestInt(x), T.sizeOf * 2) |