X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fgnumeric-reader.c;h=2e92e3f5127595b0fd2d75ba0bb96e8af94fd993;hb=b273a2c9bdfaf0d37181a5ea78098a2f2125eb62;hp=5a0c75ede293a21052228a87b295a070398f3e1f;hpb=8953baa61127d6d3b91f763663ea647bf3e4e793;p=pspp-builds.git diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index 5a0c75ed..2e92e3f5 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -314,11 +314,10 @@ static void convert_xml_string_to_value (struct ccase *c, const struct variable *var, const xmlChar *xv) { - char *text; int n_bytes = 0; union value *v = case_data_rw (c, var); - text = recode_string (CONV_UTF8_TO_PSPP, (const char *) xv, -1); + const char *text = (const char *) xv; if ( text) n_bytes = MIN (var_get_width (var), strlen (text)); @@ -335,8 +334,6 @@ convert_xml_string_to_value (struct ccase *c, const struct variable *var, if ( errno != 0 || endptr == text) v->f = SYSMIS; } - - free (text); } struct var_spec @@ -451,7 +448,7 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) if ( idx >= n_var_specs ) { n_var_specs = idx + 1 ; - var_spec = realloc (var_spec, sizeof (*var_spec) * n_var_specs); + var_spec = xrealloc (var_spec, sizeof (*var_spec) * n_var_specs); var_spec [idx].name = NULL; var_spec [idx].width = -1; var_spec [idx].first_value = NULL; @@ -459,16 +456,14 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) if ( r->node_type == XML_READER_TYPE_TEXT ) { - char *text ; xmlChar *value = xmlTextReaderValue (r->xtr); - - text = recode_string (CONV_UTF8_TO_PSPP, (const char *) value, -1); + const char *text = (const char *) value; if ( r->row < r->start_row) { if ( gri->read_names ) { - var_spec [idx].name = strdup (text); + var_spec [idx].name = xstrdup (text); } } else @@ -481,7 +476,6 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) } free (value); - free (text); } else if ( r->node_type == XML_READER_TYPE_ELEMENT && r->state == STATE_CELL) @@ -503,6 +497,8 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) /* Create the dictionary and populate it */ *dict = r->dict = dict_create (); + dict_set_encoding (r->dict, (const char *) xmlTextReaderConstEncoding (r->xtr)); + r->value_cnt = 0; for (i = 0 ; i < n_var_specs ; ++i )