ext-array.c: Ensure that fseek is called before switching between read and write. 20120616000502/pspp 20120617000503/pspp 20120618000503/pspp 20120619000503/pspp 20120620000508/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 15 Jun 2012 18:29:24 +0000 (20:29 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 15 Jun 2012 18:43:00 +0000 (20:43 +0200)
commit987428608748d573aa3378725e929823f45b7a81
tree4383679af1ea127cefed81a04623c017679e3eea
parent5f74f90119911893336f366f06744cd920c0010c
ext-array.c: Ensure that fseek is called before switching between read and write.

ANSI C requires that a file positioning function (eg seek) occurs before a switch
from reading to writing a stream (or vici-versa).  We had not been doing this.
This had caused problems which manifested themselves on Windows operating systems,
by mysteriously failing to write the stream (and thus truncating the datafile).
This change corrects this.

Thanks to Harry Thijssen and Henry Gong for their very valuable assistance tracking
down the cause of this problem.

Reviewed-by: Ben Pfaff
src/libpspp/ext-array.c