projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Test individual-cell summary functions for scale varaibles.
[pspp]
/
src
/
data
/
ods-reader.c
diff --git
a/src/data/ods-reader.c
b/src/data/ods-reader.c
index cac060f81d9fa93b518d2f55b0c493a2f4a18dc3..dc861f29abcdab8916fc0b5d0534726467a8dc80 100644
(file)
--- a/
src/data/ods-reader.c
+++ b/
src/data/ods-reader.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2011, 2012, 2013, 2016, 2020 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012, 2013, 2016, 2020
, 2021
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
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
@@
-121,7
+121,6
@@
struct ods_reader
struct string ods_errs;
struct string ods_errs;
- struct string zip_errs;
struct hmap cache;
};
struct hmap cache;
};
@@
-130,7
+129,7
@@
struct cache_datum
{
struct hmap_node node;
{
struct hmap_node node;
- /* The
the
number of the sheet. */
+ /* The number of the sheet. */
int sheet;
/* The cell's row. */
int sheet;
/* The cell's row. */
@@
-164,7
+163,7
@@
ods_destroy (struct spreadsheet *s)
dict_unref (r->spreadsheet.dict);
dict_unref (r->spreadsheet.dict);
- zip_reader_
destroy
(r->zreader);
+ zip_reader_
unref
(r->zreader);
free (r->spreadsheet.sheets);
free (s->file_name);
free (r->spreadsheet.sheets);
free (s->file_name);
@@
-206,10
+205,12
@@
state_data_init (const struct ods_reader *r, struct state_data *sd)
{
memset (sd, 0, sizeof (*sd));
{
memset (sd, 0, sizeof (*sd));
- sd->zm = zip_member_open (r->zreader, "content.xml");
-
- if (sd->zm == NULL)
- return false;
+ char *error = zip_member_open (r->zreader, "content.xml", &sd->zm);
+ if (error)
+ {
+ free (error);
+ return false;
+ }
sd->xtr =
xmlReaderForIO (xml_reader_for_zip_member, NULL, sd->zm, NULL, NULL,
sd->xtr =
xmlReaderForIO (xml_reader_for_zip_member, NULL, sd->zm, NULL, NULL,
@@
-674,11
+675,9
@@
convert_xml_to_value (struct ccase *c, const struct variable *var,
const char *text = xmv->value ?
CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text);
const char *text = xmv->value ?
CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text);
- char *m = data_in (ss_cstr (text), "UTF-8",
- fmt->type,
- v,
- var_get_width (var),
- "UTF-8");
+ char *m = data_in (ss_cstr (text), "UTF-8", fmt->type,
+ settings_get_fmt_settings (), v,
+ var_get_width (var), "UTF-8");
if (m)
{
if (m)
{
@@
-700,10
+699,12
@@
get_sheet_count (struct zip_reader *zreader)
{
xmlTextReaderPtr mxtr;
struct zip_member *meta = NULL;
{
xmlTextReaderPtr mxtr;
struct zip_member *meta = NULL;
- meta = zip_member_open (zreader, "meta.xml");
-
- if (meta == NULL)
- return -1;
+ char *error = zip_member_open (zreader, "meta.xml", &meta);
+ if (error)
+ {
+ free (error);
+ return -1;
+ }
mxtr = xmlReaderForIO (xml_reader_for_zip_member, NULL, meta, NULL, NULL, 0);
mxtr = xmlReaderForIO (xml_reader_for_zip_member, NULL, meta, NULL, NULL, 0);
@@
-908,25
+909,27
@@
ods_make_reader (struct spreadsheet *spreadsheet,
{
if (idx >= n_var_specs)
{
{
if (idx >= n_var_specs)
{
- var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx +
1
));
+ var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx +
r->rsd.col_span
));
memset (var_spec + n_var_specs,
memset (var_spec + n_var_specs,
- 0,
- (idx
- n_var_specs + 1
) * sizeof (*var_spec));
+ 0,
+ (idx
+ r->rsd.col_span - n_var_specs
) * sizeof (*var_spec));
var_spec [idx].name = NULL;
n_var_specs = idx + 1;
}
var_spec [idx].name = NULL;
n_var_specs = idx + 1;
}
- var_spec [idx].firstval.type = type;
- var_spec [idx].firstval.text = xmlTextReaderValue (r->rsd.xtr);
- var_spec [idx].firstval.value = val_string;
+ for (int x = 0; x < r->rsd.col_span; ++x)
+ {
+ var_spec [idx - x].firstval.type = xmlStrdup (type);
+ var_spec [idx - x].firstval.text = xmlTextReaderValue (r->rsd.xtr);
+ var_spec [idx - x].firstval.value = xmlStrdup (val_string);
+ }
-
val_string = NULL
;
-
type = NULL
;
+
free (val_string)
;
+
free (type)
;
}
}
}
}
-
/* Create the dictionary and populate it */
r->spreadsheet.dict = dict_create (
CHAR_CAST (const char *, xmlTextReaderConstEncoding (r->rsd.xtr)));
/* Create the dictionary and populate it */
r->spreadsheet.dict = dict_create (
CHAR_CAST (const char *, xmlTextReaderConstEncoding (r->rsd.xtr)));
@@
-1076,7
+1079,7
@@
ods_file_casereader_read (struct casereader *reader UNUSED, void *r_)
r->rsd.node_type == XML_READER_TYPE_TEXT)
{
int col;
r->rsd.node_type == XML_READER_TYPE_TEXT)
{
int col;
- struct xml_value *xmv =
xzalloc (sizeof *xmv
);
+ struct xml_value *xmv =
XZALLOC (struct xml_value
);
xmv->text = xmlTextReaderValue (r->rsd.xtr);
xmv->value = val_string;
val_string = NULL;
xmv->text = xmlTextReaderValue (r->rsd.xtr);
xmv->value = val_string;
val_string = NULL;
@@
-1091,7
+1094,7
@@
ods_file_casereader_read (struct casereader *reader UNUSED, void *r_)
continue;
if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col)
break;
continue;
if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col)
break;
- if (idx >= dict_get_
var_cnt
(r->spreadsheet.dict))
+ if (idx >= dict_get_
n_vars
(r->spreadsheet.dict))
break;
var = dict_get_var (r->spreadsheet.dict, idx);
break;
var = dict_get_var (r->spreadsheet.dict, idx);
@@
-1121,9
+1124,13
@@
init_reader (struct ods_reader *r, bool report_errors,
if (state)
{
if (state)
{
- struct zip_member *content = zip_member_open (r->zreader, "content.xml");
+ struct zip_member *content;
+ char *error = zip_member_open (r->zreader, "content.xml", &content);
if (content == NULL)
if (content == NULL)
- return NULL;
+ {
+ free (error);
+ return NULL;
+ }
xmlTextReaderPtr xtr = xmlReaderForIO (xml_reader_for_zip_member, NULL, content, NULL, NULL,
report_errors
xmlTextReaderPtr xtr = xmlReaderForIO (xml_reader_for_zip_member, NULL, content, NULL, NULL,
report_errors
@@
-1156,21
+1163,18
@@
init_reader (struct ods_reader *r, bool report_errors,
struct spreadsheet *
ods_probe (const char *filename, bool report_errors)
{
struct spreadsheet *
ods_probe (const char *filename, bool report_errors)
{
- struct ods_reader *r = xzalloc (sizeof *r);
- struct zip_reader *zr;
-
- ds_init_empty (&r->zip_errs);
+ struct ods_reader *r = XZALLOC (struct ods_reader);
-
zr = zip_reader_create (filename, &r->zip_errs)
;
-
- if (
zr == NULL
)
+
struct zip_reader *zr
;
+ char *error = zip_reader_create (filename, &zr);
+ if (
error
)
{
if (report_errors)
{
msg (ME, _("Cannot open %s as a OpenDocument file: %s"),
{
if (report_errors)
{
msg (ME, _("Cannot open %s as a OpenDocument file: %s"),
- filename,
ds_cstr (&r->zip_errs)
);
+ filename,
error
);
}
}
-
ds_destroy (&r->zip_errs
);
+
free (error
);
free (r);
return NULL;
}
free (r);
return NULL;
}
@@
-1190,8
+1194,7
@@
ods_probe (const char *filename, bool report_errors)
return &r->spreadsheet;
error:
return &r->spreadsheet;
error:
- ds_destroy (&r->zip_errs);
- zip_reader_destroy (r->zreader);
+ zip_reader_unref (r->zreader);
free (r);
return NULL;
}
free (r);
return NULL;
}