/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013, 2016 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
{
xmlFree (r->sheets[i].name);
}
-
+
+
free (r->sheets);
state_data_destroy (&r->msd);
+ dict_destroy (r->dict);
+
free (s->file_name);
free (r);
}
free (var_spec);
- dict_destroy (spreadsheet->dict);
- spreadsheet->dict = NULL;
gnm_file_casereader_destroy (NULL, r);
/* PSPP - a program for statistical analysis.
- Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012, 2013, 2016 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
{
xmlFree (r->sheets[i].name);
}
-
+
+ dict_destroy (r->dict);
+
zip_reader_destroy (r->zreader);
free (r->sheets);
free (s->file_name);
free (var_spec);
- dict_destroy (r->spreadsheet.dict);
- r->spreadsheet.dict = NULL;
ods_file_casereader_destroy (NULL, r);
return NULL;
/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010, 2016 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
/* The total number of sheets in the "workbook" */
int n_sheets;
- /* The dictionary */
- struct dictionary *dict;
+ /* The dictionary for client's reference.
+ Client must clone if it needs a permanent or modifiable copy. */
+ const struct dictionary *dict;
int ref_cnt;
};
lex_match_id (lexer, "ODS"))
{
char *filename = NULL;
- struct casereader *reader = NULL;
- struct dictionary *dict = NULL;
-
if (!parse_spreadsheet (lexer, &filename, &opts))
goto error;
+ struct spreadsheet *spreadsheet = NULL;
if ( gnm_read_support && 0 == strncasecmp (tok, "GNM", 3))
- {
- struct spreadsheet *spreadsheet = gnumeric_probe (filename, true);
- if (spreadsheet == NULL)
- goto error;
- reader = gnumeric_make_reader (spreadsheet, &opts);
- dict = spreadsheet->dict;
- gnumeric_unref (spreadsheet);
- }
+ spreadsheet = gnumeric_probe (filename, true);
else if ( odf_read_support && 0 == strncasecmp (tok, "ODS", 3))
- {
- struct spreadsheet *spreadsheet = ods_probe (filename, true);
- if (spreadsheet == NULL)
- goto error;
- reader = ods_make_reader (spreadsheet, &opts);
- dict = spreadsheet->dict;
- ods_unref (spreadsheet);
- }
+ spreadsheet = ods_probe (filename, true);
free (filename);
+ if (spreadsheet == NULL)
+ goto error;
+ struct casereader *reader = spreadsheet_make_reader (spreadsheet, &opts);
if (reader)
{
- dataset_set_dict (ds, dict);
+ dataset_set_dict (ds, dict_clone (spreadsheet->dict));
dataset_set_source (ds, reader);
free (tok);
destroy_spreadsheet_read_info (&opts);
+ spreadsheet_unref (spreadsheet);
return CMD_SUCCESS;
}
+ spreadsheet_unref (spreadsheet);
}
else
msg (SE, _("Unsupported TYPE %s."), tok);
case SPREADSHEET_GNUMERIC:
{
reader = spreadsheet_make_reader (ia->spreadsheet, &sro);
- ia->dict = ia->spreadsheet->dict;
+ ia->dict = dict_clone (ia->spreadsheet->dict);
}
break;
default: