X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fspv%2Fspv-light-decoder.c;h=f1f3dba9607dc68599ceb4a3a755bd471a5754d0;hb=f20d313de2b85419c3e2e22a78cdcdce499af43d;hp=ce5bd067c9e930637dababca3fba654c474ff606;hpb=34cb3b49aed3f145ccf68f083041e493cc5fc924;p=pspp diff --git a/src/output/spv/spv-light-decoder.c b/src/output/spv/spv-light-decoder.c index ce5bd067c9..f1f3dba960 100644 --- a/src/output/spv/spv-light-decoder.c +++ b/src/output/spv/spv-light-decoder.c @@ -96,7 +96,7 @@ static char * WARN_UNUSED_RESULT decode_spvlb_color_string (const char *s, uint8_t def, struct cell_color *colorp) { - int r, g, b; + unsigned int r, g, b; if (!*s) r = g = b = def; else if (sscanf (s, "#%2x%2x%2x", &r, &g, &b) != 3) @@ -291,7 +291,7 @@ decode_spvlb_value (const struct pivot_table *table, { *outp = NULL; - struct pivot_value *out = xzalloc (sizeof *out); + struct pivot_value *out = XZALLOC (struct pivot_value); const struct spvlb_value_mod *vm; char *error; @@ -302,6 +302,7 @@ decode_spvlb_value (const struct pivot_table *table, out->type = PIVOT_VALUE_NUMERIC; out->numeric.x = in->type_01.x; error = spv_decode_fmt_spec (in->type_01.format, &out->numeric.format); + out->numeric.honor_small = (in->type_01.format >> 16) == 40; if (error) return error; break; @@ -392,17 +393,19 @@ decode_spvlb_value (const struct pivot_table *table, { if (vm->n_subscripts) { - out->n_subscripts = vm->n_subscripts; - out->subscripts = xnmalloc (vm->n_subscripts, - sizeof *out->subscripts); + struct pivot_value_ex *ex = pivot_value_ex_rw (out); + ex->n_subscripts = vm->n_subscripts; + ex->subscripts = xnmalloc (vm->n_subscripts, sizeof *ex->subscripts); for (size_t i = 0; i < vm->n_subscripts; i++) - out->subscripts[i] = to_utf8 (vm->subscripts[i], encoding); + ex->subscripts[i] = to_utf8 (vm->subscripts[i], encoding); } if (vm->n_refs) { - out->footnote_indexes = xnmalloc (vm->n_refs, - sizeof *out->footnote_indexes); + struct pivot_value_ex *ex = pivot_value_ex_rw (out); + ex->footnote_indexes = xnmalloc (vm->n_refs, + sizeof *ex->footnote_indexes); + for (size_t i = 0; i < vm->n_refs; i++) { uint16_t idx = vm->refs[i]; @@ -413,18 +416,19 @@ decode_spvlb_value (const struct pivot_table *table, idx, table->n_footnotes); } - out->footnote_indexes[out->n_footnotes++] = idx; + ex->footnote_indexes[ex->n_footnotes++] = idx; } pivot_value_sort_footnotes (out); } if (vm->style_pair) { + struct pivot_value_ex *ex = pivot_value_ex_rw (out); error = decode_spvlb_font_style (vm->style_pair->font_style, - encoding, &out->font_style); + encoding, &ex->font_style); if (!error) error = decode_spvlb_cell_style (vm->style_pair->cell_style, - &out->cell_style); + &ex->cell_style); if (error) { pivot_value_destroy (out); @@ -536,7 +540,7 @@ decode_spvlb_categories (const struct pivot_table *table, if (error) return error; - struct pivot_category *out = xzalloc (sizeof *out); + struct pivot_category *out = XZALLOC (struct pivot_category); out->name = name; out->parent = parent; out->dimension = dimension; @@ -625,7 +629,7 @@ decode_spvlb_dimension (const struct pivot_table *table, if (error) return error; - struct pivot_dimension *out = xzalloc (sizeof *out); + struct pivot_dimension *out = XZALLOC (struct pivot_dimension); out->level = UINT_MAX; out->top_index = idx; out->hide_all_labels = in->props->hide_all_labels; @@ -729,7 +733,7 @@ decode_data_index (uint64_t in, const struct pivot_table *table, size_t *out) { uint64_t remainder = in; - for (size_t i = table->n_dimensions - 1; i > 0; i--) + for (size_t i = table->n_dimensions - 1; i < table->n_dimensions; i--) { const struct pivot_dimension *d = table->dimensions[i]; if (d->n_leaves) @@ -740,10 +744,9 @@ decode_data_index (uint64_t in, const struct pivot_table *table, else out[i] = 0; } - if (remainder >= table->dimensions[0]->n_leaves) + if (remainder) return xasprintf ("out of range cell data index %"PRIu64, in); - out[0] = remainder; return NULL; } @@ -808,19 +811,21 @@ decode_current_layer (uint64_t current_layer, struct pivot_table *table) table->current_layer = xnmalloc (axis->n_dimensions, sizeof *table->current_layer); + uint64_t remainder = current_layer; for (size_t i = 0; i < axis->n_dimensions; i++) { const struct pivot_dimension *d = axis->dimensions[i]; if (d->n_leaves) { - table->current_layer[i] = current_layer % d->n_leaves; - current_layer /= d->n_leaves; + table->current_layer[i] = remainder % d->n_leaves; + remainder /= d->n_leaves; } else table->current_layer[i] = 0; } - if (current_layer > 0) + if (remainder > 0) return xasprintf ("out of range layer data index %"PRIu64, current_layer); + return NULL; } @@ -833,7 +838,7 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp) in->header->version); char *error = NULL; - struct pivot_table *out = xzalloc (sizeof *out); + struct pivot_table *out = XZALLOC (struct pivot_table); out->ref_cnt = 1; hmap_init (&out->cells); out->look = pivot_table_look_new_builtin_default (); @@ -917,7 +922,7 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp) if (epoch >= 1000 && epoch <= 9999) out->settings.epoch = epoch; char decimal = in->formats->y0->decimal; - if (decimal == '.' || decimal == '.') + if (decimal == '.' || decimal == ',') out->settings.decimal = decimal; else {