summary refs log tree commit diff stats
diff options
context:
space:
mode:
authordef <dennis@felsin9.de>2015-07-24 01:12:32 +0200
committerdef <dennis@felsin9.de>2015-07-24 01:13:52 +0200
commit401189c3fe3f02ec90a9905f981667a1b9a1d40a (patch)
tree73a64163261ec21e1938b030f60e25fb88bff1ae
parent3943fba34b317abf2c2421fdfd0f042dd34bbbc6 (diff)
downloadNim-401189c3fe3f02ec90a9905f981667a1b9a1d40a.tar.gz
No need to set trailing \0
-rw-r--r--lib/system/sysio.nim11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index dccb13303..e1c928e22 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -67,11 +67,6 @@ proc raiseEIO(msg: string) {.noinline, noreturn.} =
   sysFatal(IOError, msg)
 
 proc readLine(f: File, line: var TaintedString): bool =
-  template returnUntil(p: int) =
-    line.string[p] = '\0'
-    line.string.setLen(p)
-    return true
-
   var pos = 0
   # Use the currently reserved space for a first try
   var space = cast[PGenericSeq](line.string).space
@@ -84,8 +79,10 @@ proc readLine(f: File, line: var TaintedString): bool =
     let last = pos + cstring(addr line.string[pos]).len-1
     if line.string[last] == '\l':
       if last > 0 and line.string[last-1] == '\c':
-        returnUntil(last-1)
-      returnUntil(last)
+        line.string.setLen(last-1)
+        return true
+      line.string.setLen(last)
+      return true
     pos = last+1
     space = 128 # Read in 128 bytes at a time
     line.string.setLen(pos+space)