static void
free_headings (const struct pivot_axis *axis, char ***headings)
{
+ if (!headings)
+ return;
for (size_t i = 0; i < axis->label_depth; i++)
{
for (size_t j = 0; j < axis->extent; j++)
{
if (x)
fputs ("; ", stdout);
- if (column_headings[y][x])
+ if (column_headings && column_headings[y] && column_headings[y][x])
fputs (column_headings[y][x], stdout);
}
putchar ('\n');
/* Returns a new pivot_value for VARIABLE. */
struct pivot_value *
pivot_value_new_variable (const struct variable *variable)
+{
+ return pivot_value_new_variable__ (var_get_name (variable),
+ var_get_label (variable));
+}
+
+/* Returns a new pivot_value for a variable with the given NAME and optional
+ LABEL. */
+struct pivot_value *
+pivot_value_new_variable__ (const char *name, const char *label)
{
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
.variable = {
.type = PIVOT_VALUE_VARIABLE,
- .var_name = xstrdup (var_get_name (variable)),
- .var_label = xstrdup_if_nonempty (var_get_label (variable)),
+ .var_name = xstrdup (name),
+ .var_label = xstrdup_if_nonempty (label),
},
};
return value;