X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffile-type.c;h=bc33599da97db2d33a0171c00f438aaba1f57799;hb=9b4b94c6d3b5fd98bf396e23d015380b87d2d296;hp=ea0bb332d679040e1031ff84ebf2fd4ee1ddf86b;hpb=bc963dae9be291ea0a7cccf189d13e00d3797cfd;p=pspp diff --git a/src/file-type.c b/src/file-type.c index ea0bb332d6..bc33599da9 100644 --- a/src/file-type.c +++ b/src/file-type.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" @@ -86,6 +86,7 @@ struct file_type_pgm DATA LIST. */ struct record_type *recs_head; /* List of record types. */ struct record_type *recs_tail; /* Last in list of record types. */ + size_t case_size; /* Case size in bytes. */ }; static int parse_col_spec (struct col_spec *, const char *); @@ -108,7 +109,6 @@ cmd_file_type (void) fty->had_rec_type = 0; fty->recs_head = fty->recs_tail = NULL; - lex_match_id ("TYPE"); if (lex_match_id ("MIXED")) fty->type = FTY_MIXED; else if (lex_match_id ("GROUPED")) @@ -269,12 +269,14 @@ cmd_file_type (void) } } + if (!dfm_open_for_reading (fty->handle)) + goto error; default_handle = fty->handle; - vfm_source = create_case_source (&file_type_source_class, fty); create_col_var (&fty->record); if (fty->case_sbc.name[0]) create_col_var (&fty->case_sbc); + vfm_source = create_case_source (&file_type_source_class, default_dict, fty); return CMD_SUCCESS; @@ -422,9 +424,6 @@ cmd_record_type (void) } } - lex_match_id ("RECORD"); - lex_match_id ("TYPE"); - /* Parse record type values. */ if (lex_match_id ("OTHER")) rct->flags |= RCT_OTHER; @@ -579,8 +578,7 @@ cmd_end_file_type (void) return CMD_FAILURE; } fty = vfm_source->aux; - - lex_match_id ("TYPE"); + fty->case_size = dict_get_case_size (default_dict); if (fty->recs_tail) { @@ -616,10 +614,11 @@ cmd_end_file_type (void) static void read_from_file_type_grouped(void); static void read_from_file_type_nested(void); */ -/* Reads any number of cases into temp_case and calls write_case() for - each one. Compare data-list.c:read_from_data_list. */ +/* Reads any number of cases into case C and calls write_case() + for each one. Compare data-list.c:read_from_data_list. */ static void file_type_source_read (struct case_source *source, + struct ccase *c, write_case_func *write_case UNUSED, write_case_data wc_data UNUSED) { @@ -644,7 +643,7 @@ file_type_source_read (struct case_source *source, { struct data_in di; - v.c = temp_case->data[fty->record.v->fv].s; + v.c = c->data[fty->record.v->fv].s; data_in_finite_line (&di, line, len, fty->record.fc, fty->record.fc + fty->record.nc); @@ -677,7 +676,7 @@ file_type_source_read (struct case_source *source, di.format = format; data_in (&di); - memcpy (&temp_case->data[fty->record.v->fv].f, &v.f, sizeof v.f); + memcpy (&c->data[fty->record.v->fv].f, &v.f, sizeof v.f); for (iter = fty->recs_head; iter; iter = iter->next) { if (iter->flags & RCT_OTHER)