projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
output-item: Fix memory leak in output_item_dump().
[pspp]
/
src
/
output
/
spv
/
spv-writer.c
diff --git
a/src/output/spv/spv-writer.c
b/src/output/spv/spv-writer.c
index 64bb365c614f48d1f13f4cffaa949bd7198468f5..bb37a05e24b103ab86be47f9e766e2a39e98fe7d 100644
(file)
--- a/
src/output/spv/spv-writer.c
+++ b/
src/output/spv/spv-writer.c
@@
-194,8
+194,9
@@
spv_writer_open_file (struct spv_writer *w)
time_t t = time (NULL);
struct tm *tm = gmtime (&t);
time_t t = time (NULL);
struct tm *tm = gmtime (&t);
- char *tm_s = asctime (tm);
- write_attr (w, "creation-date-time", tm_s);
+ char tm_s[128];
+ if (strftime (tm_s, sizeof tm_s, "%x %X", tm))
+ write_attr (w, "creation-date-time", tm_s);
write_attr (w, "creator", version);
write_attr (w, "creator", version);
@@
-557,20
+558,25
@@
static void
put_value_mod (struct buf *buf, const struct pivot_value *value,
const char *template)
{
put_value_mod (struct buf *buf, const struct pivot_value *value,
const char *template)
{
- if (value->n_footnotes || value->n_subscripts
- || template || value->font_style || value->cell_style)
+ if ((value->ex
+ && (value->ex->n_footnotes
+ || value->ex->n_subscripts
+ || value->ex->font_style
+ || value->ex->cell_style))
+ || template)
{
{
+ const struct pivot_value_ex *ex = pivot_value_ex (value);
put_byte (buf, 0x31);
/* Footnotes. */
put_byte (buf, 0x31);
/* Footnotes. */
- put_u32 (buf,
value
->n_footnotes);
- for (size_t i = 0; i <
value
->n_footnotes; i++)
- put_u16 (buf,
value
->footnote_indexes[i]);
+ put_u32 (buf,
ex
->n_footnotes);
+ for (size_t i = 0; i <
ex
->n_footnotes; i++)
+ put_u16 (buf,
ex
->footnote_indexes[i]);
/* Subscripts. */
/* Subscripts. */
- put_u32 (buf,
value
->n_subscripts);
- for (size_t i = 0; i <
value
->n_subscripts; i++)
- put_string (buf,
value
->subscripts[i]);
+ put_u32 (buf,
ex
->n_subscripts);
+ for (size_t i = 0; i <
ex
->n_subscripts; i++)
+ put_string (buf,
ex
->subscripts[i]);
/* Template and style. */
uint32_t v3_start = start_count (buf);
/* Template and style. */
uint32_t v3_start = start_count (buf);
@@
-584,7
+590,7
@@
put_value_mod (struct buf *buf, const struct pivot_value *value,
put_string (buf, template);
}
end_count_u32 (buf, template_string_start);
put_string (buf, template);
}
end_count_u32 (buf, template_string_start);
- put_style_pair (buf,
value->font_style, value
->cell_style);
+ put_style_pair (buf,
ex->font_style, ex
->cell_style);
end_count_u32 (buf, v3_start);
}
else
end_count_u32 (buf, v3_start);
}
else
@@
-643,9
+649,10
@@
put_value (struct buf *buf, const struct pivot_value *value)
put_value_mod (buf, value, NULL);
size_t len = strlen (value->string.s);
if (value->string.hex)
put_value_mod (buf, value, NULL);
size_t len = strlen (value->string.s);
if (value->string.hex)
- put_format (buf, &(struct fmt_spec) { FMT_AHEX, len * 2, 0 }, false);
+ put_format (buf, &(struct fmt_spec) { .type = FMT_AHEX, .w = len * 2 },
+ false);
else
else
- put_format (buf, &(struct fmt_spec) {
FMT_A, len, 0
}, false);
+ put_format (buf, &(struct fmt_spec) {
.type = FMT_A, .w = len
}, false);
put_string (buf, value->string.value_label);
put_string (buf, value->string.var_name);
put_show_values (buf, value->string.show);
put_string (buf, value->string.value_label);
put_string (buf, value->string.var_name);
put_show_values (buf, value->string.show);
@@
-1126,11
+1133,6
@@
spv_writer_write (struct spv_writer *w, const struct output_item *item)
w->need_page_break = true;
break;
w->need_page_break = true;
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- page_setup_destroy (w->page_setup);
- w->page_setup = page_setup_clone (item->page_setup);
- break;
-
case OUTPUT_ITEM_TABLE:
spv_writer_put_table (w, item);
break;
case OUTPUT_ITEM_TABLE:
spv_writer_put_table (w, item);
break;
@@
-1140,3
+1142,11
@@
spv_writer_write (struct spv_writer *w, const struct output_item *item)
break;
}
}
break;
}
}
+
+void
+spv_writer_set_page_setup (struct spv_writer *w,
+ const struct page_setup *ps)
+{
+ page_setup_destroy (w->page_setup);
+ w->page_setup = page_setup_clone (ps);
+}