X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fods-reader.c;h=1b828d1e36a186a9e532c4c88871881e347d23a6;hb=3380cd42c3831b98b71709a0c1fcb175e3e4a5d9;hp=6e6fab4634a1c313574bb545314221e8039f6e07;hpb=9166c38ef1fc025217b9aaa3f49be610e6cf4748;p=pspp diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index 6e6fab4634..1b828d1e36 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -152,6 +152,8 @@ struct ods_reader bool read_names; struct string ods_errs; + + struct string zip_errs; }; void @@ -602,28 +604,33 @@ init_reader (struct ods_reader *r, bool report_errors) } + struct spreadsheet * ods_probe (const char *filename, bool report_errors) { - struct ods_reader *r; - struct string errs = DS_EMPTY_INITIALIZER; int sheet_count; - struct zip_reader *zr = zip_reader_create (filename, &errs); - xmlTextReaderPtr xtr; + struct ods_reader *r = xzalloc (sizeof *r); + xmlTextReaderPtr xtr; + struct zip_reader *zr; + + ds_init_empty (&r->zip_errs); + + zr = zip_reader_create (filename, &r->zip_errs); if (zr == NULL) { if (report_errors) { msg (ME, _("Cannot open %s as a OpenDocument file: %s"), - filename, ds_cstr (&errs)); + filename, ds_cstr (&r->zip_errs)); } + ds_destroy (&r->zip_errs); + free (r); return NULL; } sheet_count = get_sheet_count (zr); - r = xzalloc (sizeof *r); r->zreader = zr; r->ref_cnt = 1; @@ -643,14 +650,12 @@ ods_probe (const char *filename, bool report_errors) r->n_allocated_sheets = 0; r->sheets = NULL; - ds_destroy (&errs); - r->spreadsheet.file_name = filename; return &r->spreadsheet; error: + ds_destroy (&r->zip_errs); zip_reader_destroy (r->zreader); - ds_destroy (&errs); free (r); return NULL; } @@ -981,8 +986,9 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_) struct xml_value *xmv = xzalloc (sizeof *xmv); xmv->text = xmlTextReaderValue (r->rsd.xtr); xmv->value = val_string; - xmv->type = type; val_string = NULL; + xmv->type = type; + type = NULL; for (col = 0; col < r->rsd.col_span; ++col) {