From 9fa477de755daf76c6a2302f58553d10caa061e9 Mon Sep 17 00:00:00 2001 From: skilchen Date: Sat, 15 Sep 2018 01:04:23 +0200 Subject: more efficient fix for #8961 --- lib/system/sysio.nim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/system/sysio.nim') diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index df13ab628..672d0e0f1 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -149,6 +149,12 @@ proc readLine(f: File, line: var TaintedString): bool = if sp == 0: sp = 80 line.string.setLen(sp) + else: + when not defined(nimscript): + sp = cint(cast[PGenericSeq](line.string).space) + else: + line.string.setLen(sp + 1) + while true: # memset to \L so that we can tell how far fgets wrote, even on EOF, where # fgets doesn't append an \L -- cgit 1.4.1-2-gfad0 From e317745098b95418bc1bc3d76b930ab197d67110 Mon Sep 17 00:00:00 2001 From: skilchen Date: Sat, 15 Sep 2018 14:05:42 +0200 Subject: don't reuse code from 0.18.0 --- lib/system/sysio.nim | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'lib/system/sysio.nim') diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 672d0e0f1..61835e0f7 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -145,15 +145,8 @@ proc readLine(f: File, line: var TaintedString): bool = var pos = 0 # Use the currently reserved space for a first try - var sp = line.string.len - if sp == 0: - sp = 80 - line.string.setLen(sp) - else: - when not defined(nimscript): - sp = cint(cast[PGenericSeq](line.string).space) - else: - line.string.setLen(sp + 1) + var sp = max(line.string.len, 80) + line.string.setLen(sp) while true: # memset to \L so that we can tell how far fgets wrote, even on EOF, where -- cgit 1.4.1-2-gfad0