diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-07-03 14:57:52 -0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-07-03 23:57:52 +0200 |
commit | 64168d4aea282a82230cc41064890db8a51566d0 (patch) | |
tree | 356e9b88a666557892c207a51ffe26f303acf2fa /lib | |
parent | 0718d6c2cddac89256e2fcde17407f1685f1a457 (diff) | |
download | Nim-64168d4aea282a82230cc41064890db8a51566d0.tar.gz |
fixes #8405: -d:useNimRtl now works even when {.rtl.} procs are used at compile time; CTFFI now works with {dynlib} (#11635)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/parseopt.nim | 71 | ||||
-rw-r--r-- | lib/system/repr.nim | 25 |
2 files changed, 48 insertions, 48 deletions
diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index fab32060a..545f9f00a 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -366,43 +366,42 @@ proc next*(p: var OptParser) {.rtl, extern: "npo$1".} = inc p.idx p.pos = 0 -when declared(os.paramCount): - proc cmdLineRest*(p: OptParser): TaintedString {.rtl, extern: "npo$1".} = - ## Retrieves the rest of the command line that has not been parsed yet. - ## - ## See also: - ## * `remainingArgs proc<#remainingArgs,OptParser>`_ - ## - ## **Examples:** - ## - ## .. code-block:: - ## var p = initOptParser("--left -r:2 -- foo.txt bar.txt") - ## while true: - ## p.next() - ## if p.kind == cmdLongOption and p.key == "": # Look for "--" - ## break - ## else: continue - ## doAssert p.cmdLineRest == "foo.txt bar.txt" - result = p.cmds[p.idx .. ^1].quoteShellCommand.TaintedString +proc cmdLineRest*(p: OptParser): TaintedString {.rtl, extern: "npo$1".} = + ## Retrieves the rest of the command line that has not been parsed yet. + ## + ## See also: + ## * `remainingArgs proc<#remainingArgs,OptParser>`_ + ## + ## **Examples:** + ## + ## .. code-block:: + ## var p = initOptParser("--left -r:2 -- foo.txt bar.txt") + ## while true: + ## p.next() + ## if p.kind == cmdLongOption and p.key == "": # Look for "--" + ## break + ## else: continue + ## doAssert p.cmdLineRest == "foo.txt bar.txt" + result = p.cmds[p.idx .. ^1].quoteShellCommand.TaintedString - proc remainingArgs*(p: OptParser): seq[TaintedString] {.rtl, extern: "npo$1".} = - ## Retrieves a sequence of the arguments that have not been parsed yet. - ## - ## See also: - ## * `cmdLineRest proc<#cmdLineRest,OptParser>`_ - ## - ## **Examples:** - ## - ## .. code-block:: - ## var p = initOptParser("--left -r:2 -- foo.txt bar.txt") - ## while true: - ## p.next() - ## if p.kind == cmdLongOption and p.key == "": # Look for "--" - ## break - ## else: continue - ## doAssert p.remainingArgs == @["foo.txt", "bar.txt"] - result = @[] - for i in p.idx..<p.cmds.len: result.add TaintedString(p.cmds[i]) +proc remainingArgs*(p: OptParser): seq[TaintedString] {.rtl, extern: "npo$1".} = + ## Retrieves a sequence of the arguments that have not been parsed yet. + ## + ## See also: + ## * `cmdLineRest proc<#cmdLineRest,OptParser>`_ + ## + ## **Examples:** + ## + ## .. code-block:: + ## var p = initOptParser("--left -r:2 -- foo.txt bar.txt") + ## while true: + ## p.next() + ## if p.kind == cmdLongOption and p.key == "": # Look for "--" + ## break + ## else: continue + ## doAssert p.remainingArgs == @["foo.txt", "bar.txt"] + result = @[] + for i in p.idx..<p.cmds.len: result.add TaintedString(p.cmds[i]) iterator getopt*(p: var OptParser): tuple[kind: CmdLineKind, key, val: TaintedString] = ## Convenience iterator for iterating over the given diff --git a/lib/system/repr.nim b/lib/system/repr.nim index 29c0d4ce9..a3212020a 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -299,18 +299,19 @@ when not defined(useNimRtl): add result, "(invalid data!)" inc(cl.recdepth) -proc reprOpenArray(p: pointer, length: int, elemtyp: PNimType): string {. - compilerRtl.} = - var - cl: ReprClosure - initReprClosure(cl) - result = "[" - var bs = elemtyp.size - for i in 0..length - 1: - if i > 0: add result, ", " - reprAux(result, cast[pointer](cast[ByteAddress](p) + i*bs), elemtyp, cl) - add result, "]" - deinitReprClosure(cl) +when not defined(useNimRtl): + proc reprOpenArray(p: pointer, length: int, elemtyp: PNimType): string {. + compilerRtl.} = + var + cl: ReprClosure + initReprClosure(cl) + result = "[" + var bs = elemtyp.size + for i in 0..length - 1: + if i > 0: add result, ", " + reprAux(result, cast[pointer](cast[ByteAddress](p) + i*bs), elemtyp, cl) + add result, "]" + deinitReprClosure(cl) when not defined(useNimRtl): proc reprAny(p: pointer, typ: PNimType): string = |