diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-08-26 18:00:12 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-08-26 18:00:12 +0200 |
commit | ff3cf001a39028601b295160492d90deeeb4b030 (patch) | |
tree | c70c449b4afb389cec002ed148690ff59e9ee6c5 /compiler/ropes.nim | |
parent | b4d7ab3caab6b4e1b00d29071ebee7f0372f3512 (diff) | |
download | Nim-ff3cf001a39028601b295160492d90deeeb4b030.tar.gz |
fixes #4656; ropes.nim checks properly for file equality
Diffstat (limited to 'compiler/ropes.nim')
-rw-r--r-- | compiler/ropes.nim | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/ropes.nim b/compiler/ropes.nim index bfae7aaa4..d84b59f78 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -310,15 +310,19 @@ proc equalsFile*(r: Rope, f: File): bool = buf: array[bufSize, char] bpos = buf.len blen = buf.len + btotal = 0 + rtotal = 0 for s in leaves(r): var spos = 0 let slen = s.len + rtotal += slen while spos < slen: if bpos == blen: # Read more data bpos = 0 blen = readBuffer(f, addr(buf[0]), buf.len) + btotal += blen if blen == 0: # no more data in file result = false return @@ -330,7 +334,8 @@ proc equalsFile*(r: Rope, f: File): bool = spos += n bpos += n - result = readBuffer(f, addr(buf[0]), 1) == 0 # check that we've read all + result = readBuffer(f, addr(buf[0]), 1) == 0 and + btotal == rtotal # check that we've read all proc equalsFile*(r: Rope, filename: string): bool = ## returns true if the contents of the file `f` equal `r`. If `f` does not |