#include <language/lexer/lexer.h>
#include <language/prompt.h>
#include <libpspp/assertion.h>
+#include <libpspp/cast.h>
#include <libpspp/integer-format.h>
#include <libpspp/message.h>
#include <libpspp/str.h>
if (fh_get_referent (fh) != FH_REF_INLINE)
{
struct stat s;
- r->where.file_name = fh_get_file_name (fh);
+ r->where.file_name = CONST_CAST (char *, 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."),
if (!lex_get_line_raw (r->lexer))
{
+ lex_discard_line (r->lexer);
msg (SE, _("Unexpected end-of-file while reading data in BEGIN "
"DATA. This probably indicates "
"a missing or misformatted END DATA command. "
switch (fh_get_mode (r->fh))
{
case FH_MODE_TEXT:
- if (ds_read_line (&r->line, r->file))
+ if (ds_read_line (&r->line, r->file, SIZE_MAX))
{
ds_chomp (&r->line, '\n');
return true;
}
/* Returns the legacy character encoding of data read from READER. */
-enum legacy_encoding
+const char *
dfm_reader_get_legacy_encoding (const struct dfm_reader *reader)
{
return fh_get_legacy_encoding (reader->fh);