X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdata-io%2Fdata-reader.c;h=5ff1693351dd576b936cf3a843e0d458c74af44e;hb=691c25e36fd1ee722dd35419d6110e3876b99f9c;hp=74e4c5692b1b83a95987bc1e16e7b92aaeebc500;hpb=d0b91eae59319ab2756d0d43b9cb15eb9cd3c234;p=pspp-builds.git diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index 74e4c569..5ff16933 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1997-2004, 2006, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -143,11 +143,10 @@ dfm_open_reader (struct file_handle *fh, struct lexer *lexer) struct stat s; 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."), + msg (ME, _("Could not open `%s' for reading as a data file: %s."), fh_get_file_name (r->fh), strerror (errno)); fh_unlock (r->lock); fh_unref (fh); @@ -179,7 +178,7 @@ read_inline_record (struct dfm_reader *r) { r->flags |= DFM_SAW_BEGIN_DATA; - while (lex_token (r->lexer) == '.') + while (lex_token (r->lexer) == T_ENDCMD) lex_get (r->lexer); if (!lex_force_match_id (r->lexer, "BEGIN") || !lex_force_match_id (r->lexer, "DATA")) return false; @@ -191,7 +190,7 @@ read_inline_record (struct dfm_reader *r) 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. " + "a missing or incorrectly formatted END DATA command. " "END DATA must appear by itself on a single line " "with exactly one space between words.")); return false; @@ -557,7 +556,7 @@ dfm_expand_tabs (struct dfm_reader *r) if (r->fh != fh_inline_file () && (fh_get_mode (r->fh) != FH_MODE_TEXT || fh_get_tab_width (r->fh) == 0 - || ds_find_char (&r->line, '\t') == SIZE_MAX)) + || ds_find_byte (&r->line, '\t') == SIZE_MAX)) return; /* Expand tabs from r->line into r->scratch, and figure out @@ -574,11 +573,11 @@ dfm_expand_tabs (struct dfm_reader *r) c = ds_data (&r->line)[ofs]; if (c != '\t') - ds_put_char (&r->scratch, c); + ds_put_byte (&r->scratch, c); else { do - ds_put_char (&r->scratch, ' '); + ds_put_byte (&r->scratch, ' '); while (ds_length (&r->scratch) % tab_width != 0); } } @@ -678,20 +677,16 @@ dfm_get_column (const struct dfm_reader *r, const char *p) return ds_pointer_to_position (&r->line, p) + 1; } -/* Pushes the file name and line number on the fn/ln stack. */ -void -dfm_push (struct dfm_reader *r) +const char * +dfm_get_file_name (const struct dfm_reader *r) { - if (r->fh != fh_inline_file ()) - msg_push_msg_locator (&r->where); + return fh_get_referent (r->fh) == FH_REF_FILE ? r->where.file_name : NULL; } -/* Pops the file name and line number from the fn/ln stack. */ -void -dfm_pop (struct dfm_reader *r) +int +dfm_get_line_number (const struct dfm_reader *r) { - if (r->fh != fh_inline_file ()) - msg_pop_msg_locator (&r->where); + return fh_get_referent (r->fh) == FH_REF_FILE ? r->where.line_number : -1; } /* BEGIN DATA...END DATA procedure. */