diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-06-29 11:34:39 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-06-29 11:34:39 +0200 |
commit | b5a96d28c7e848a9a8fd9d7766d8c8462a12e2b8 (patch) | |
tree | 16301d0dabb555c69e737bea4e7c837114115fce /lib/system | |
parent | a9e96888d0074a9bffb9711e40a15be1a222059d (diff) | |
download | Nim-b5a96d28c7e848a9a8fd9d7766d8c8462a12e2b8.tar.gz |
codgen refactoring: prepare for alternative string/seq implementations
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/sysstr.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 7b81f54da..90ae91cf5 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -94,8 +94,8 @@ proc mnewString(len: int): NimString {.compilerProc.} = result.len = len proc copyStrLast(s: NimString, start, last: int): NimString {.compilerProc.} = - var start = max(start, 0) - var len = min(last, s.len-1) - start + 1 + let start = max(start, 0) + let len = min(last, s.len-1) - start + 1 if len > 0: result = rawNewStringNoInit(len) result.len = len @@ -104,6 +104,10 @@ proc copyStrLast(s: NimString, start, last: int): NimString {.compilerProc.} = else: result = rawNewString(len) +proc nimToCStringConv(s: NimString): cstring {.compilerProc, inline.} = + if s == nil or s.len == 0: result = cstring"" + else: result = cstring(addr s.data) + proc copyStr(s: NimString, start: int): NimString {.compilerProc.} = result = copyStrLast(s, start, s.len-1) |