From: Ben Pfaff Date: Sat, 17 Oct 2009 23:46:21 +0000 (-0700) Subject: Fix get-data-txt-importcases.sh test on Mingw. X-Git-Tag: lenny-x64-build45^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9f77673d45b465987304c76d80b29fba893a93a;p=pspp-builds.git Fix get-data-txt-importcases.sh test on Mingw. On Mingw, ftell() and ftello() are unreliable when used on text files with plain LF line endings: http://article.gmane.org/gmane.comp.gnu.m4.bugs/2224 This made the get-data-txt-importcases.sh test fail, because dfm_get_percent_read() that it depends upon to determine the percentage of the file that has been read uses ftello(). The solution is to always open the text file as a binary file. According to my audit of the ways that the text file is read, this should not cause other problems. In particular, ds_read_line() handles both LF and CR-LF line endings. But it cannot handle negative effects on Unix platforms anyway, since they do not distinguish text and binary modes. --- diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index 6f620a6a..df5836e1 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -142,8 +142,7 @@ dfm_open_reader (struct file_handle *fh, struct lexer *lexer) struct stat s; r->where.file_name = fh_get_file_name (fh); r->where.line_number = 0; - r->file = fn_open (fh_get_file_name (fh), - fh_get_mode (fh) == FH_MODE_TEXT ? "r" : "rb"); + r->file = fn_open (fh_get_file_name (fh), "rb"); if (r->file == NULL) { msg (ME, _("Could not open \"%s\" for reading as a data file: %s."),