diff options
author | Araq <rumpf_a@web.de> | 2018-03-01 09:42:25 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-03-01 09:42:25 +0100 |
commit | ce1047f2ae07430c80eeeaa0b65eb0a32d8720a3 (patch) | |
tree | 6140c54a1a447cf6cfbc480f851461d4764035c4 /lib | |
parent | 51935c47b0f1c93df28c92fce96ba80501d561e0 (diff) | |
download | Nim-ce1047f2ae07430c80eeeaa0b65eb0a32d8720a3.tar.gz |
added -d:nimNoArrayToString define to allow easier porting to 0.18
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/parseopt.nim | 20 | ||||
-rw-r--r-- | lib/system.nim | 8 |
2 files changed, 23 insertions, 5 deletions
diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index 23568edb9..a5ab9899e 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -78,7 +78,7 @@ when declared(os.paramCount): # we cannot provide this for NimRtl creation on Posix, because we can't # access the command line arguments then! - proc initOptParser*(cmdline = ""): OptParser = + proc initOptParser*(cmdline = ""): OptParser {.rtl, extern: "npo$1String".} = ## inits the option parser. If ``cmdline == ""``, the real command line ## (as provided by the ``OS`` module) is taken. result.pos = 0 @@ -94,6 +94,24 @@ when declared(os.paramCount): result.key = TaintedString"" result.val = TaintedString"" +proc initOptParser*(cmdline: seq[string]): OptParser {.rtl, extern: "npo$1Seq".} = + ## inits the option parser. If ``cmdline.len == 0``, the real command line + ## (as provided by the ``OS`` module) is taken. + result.pos = 0 + result.inShortState = false + result.cmd = "" + if cmdline.len != 0: + for i in 0..<cmdline.len: + result.cmd.add quote(cmdline[i]) + result.cmd.add ' ' + else: + for i in countup(1, paramCount()): + result.cmd.add quote(paramStr(i).string) + result.cmd.add ' ' + result.kind = cmdEnd + result.key = TaintedString"" + result.val = TaintedString"" + proc handleShortOption(p: var OptParser) = var i = p.pos p.kind = cmdShortOption diff --git a/lib/system.nim b/lib/system.nim index 2f95b45f0..e6388698d 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3428,10 +3428,10 @@ elif defined(JS): when defined(nimffi): include "system/sysio" - -proc `$`*[T, IDX](x: array[IDX, T]): string = - ## generic ``$`` operator for arrays that is lifted from the components - collectionToString(x, "[", ", ", "]") +when not defined(nimNoArrayToString): + proc `$`*[T, IDX](x: array[IDX, T]): string = + ## generic ``$`` operator for arrays that is lifted from the components + collectionToString(x, "[", ", ", "]") proc quit*(errormsg: string, errorcode = QuitFailure) {.noReturn.} = ## a shorthand for ``echo(errormsg); quit(errorcode)``. |