Fix get-data-txt-importcases.sh test on Mingw. fc11-i386-build24 lenny-x64-build45 sid-i386-build92
authorBen Pfaff <blp@gnu.org>
Sat, 17 Oct 2009 23:46:21 +0000 (16:46 -0700)
committerBen Pfaff <blp@gnu.org>
Sat, 17 Oct 2009 23:46:21 +0000 (16:46 -0700)
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

index 6f620a6a948341a0dfa5db150763d20f51e92284..df5836e11470c0b9af40f9f89e4f1bee0ff0fc6d 100644 (file)
@@ -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."),