summary refs log tree commit diff stats
path: root/lib/system/sysio.nim
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2018-09-14 18:34:56 -0500
committerGanesh Viswanathan <dev@genotrance.com>2018-09-14 18:34:56 -0500
commit80520eef3cce0b3145dedc71a6652429adb9cc9e (patch)
treed64725d2749cb82bfef997bbbdb443cc4827de6d /lib/system/sysio.nim
parente07a256f74b9e89e49287c8a21c1334af43e27c2 (diff)
parentb9dc486db15bb1b4b6f3cef7626733b904d377f7 (diff)
downloadNim-80520eef3cce0b3145dedc71a6652429adb9cc9e.tar.gz
Merge remote-tracking branch 'upstream/devel' into test-6483
Diffstat (limited to 'lib/system/sysio.nim')
-rw-r--r--lib/system/sysio.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 40bbf97dc..df13ab628 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -161,7 +161,7 @@ proc readLine(f: File, line: var TaintedString): bool =
       var last = cast[ByteAddress](m) - cast[ByteAddress](addr line.string[0])
       if last > 0 and line.string[last-1] == '\c':
         line.string.setLen(last-1)
-        return fgetsSuccess
+        return last > 1 or fgetsSuccess
         # We have to distinguish between two possible cases:
         # \0\l\0 => line ending in a null character.
         # \0\l\l => last line without newline, null was put there by fgets.
@@ -169,7 +169,7 @@ proc readLine(f: File, line: var TaintedString): bool =
         if last < pos + sp - 1 and line.string[last+1] != '\0':
           dec last
       line.string.setLen(last)
-      return fgetsSuccess
+      return last > 0 or fgetsSuccess
     else:
       # fgets will have inserted a null byte at the end of the string.
       dec sp