From b9f77673d45b465987304c76d80b29fba893a93a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 17 Oct 2009 16:46:21 -0700 Subject: [PATCH] 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. --- src/language/data-io/data-reader.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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."), -- 2.30.2