case OUTPUT_ITEM_TEXT:
{
- char *s = pivot_value_to_string_defaults (item->text.content);
+ char *s = pivot_value_to_string (item->text.content, NULL);
printf ("text %s \"%s\"\n",
text_item_subtype_to_string (item->text.subtype), s);
free (s);
text_item_get_plain_text (const struct output_item *item)
{
assert (item->type == OUTPUT_ITEM_TEXT);
- return pivot_value_to_string_defaults (item->text.content);
+ return pivot_value_to_string (item->text.content, NULL);
}
static bool
xmlFreeParserCtxt (parser);
}
-/* Appends a text representation of the body of VALUE to OUT. Settings on
- PT control whether variable and value labels are included.
+static const struct pivot_table pivot_value_format_defaults = {
+ .show_values = SETTINGS_VALUE_SHOW_DEFAULT,
+ .show_variables = SETTINGS_VALUE_SHOW_DEFAULT,
+ .settings = FMT_SETTINGS_INIT,
+};
+
+/* Appends a text representation of the body of VALUE to OUT. Settings on PT
+ control whether variable and value labels are included (pass NULL for PT to
+ get default formatting in the absence of a pivot table).
The "body" omits subscripts and superscripts and footnotes.
otherwise. */
bool
pivot_value_format_body (const struct pivot_value *value,
- const struct pivot_table *pt,
+ const struct pivot_table *pt_,
struct string *out)
{
+ const struct pivot_table *pt = pt_ ? pt_ : &pivot_value_format_defaults;
enum settings_value_show show;
bool numeric = false;
return numeric;
}
-/* Appends a text representation of VALUE to OUT. Settings on
- PT control whether variable and value labels are included.
+/* Appends a text representation of VALUE to OUT. Settings on PT control
+ whether variable and value labels are included (pass NULL for PT to get
+ default formatting in the absence of a pivot table).
Subscripts and footnotes are included.
otherwise. */
bool
pivot_value_format (const struct pivot_value *value,
- const struct pivot_table *pt,
+ const struct pivot_table *pt_,
struct string *out)
{
+ const struct pivot_table *pt = pt_ ? pt_ : &pivot_value_format_defaults;
bool numeric = pivot_value_format_body (value, pt, out);
const struct pivot_value_ex *ex = value->ex;
}
/* Returns a text representation of VALUE. The caller must free the string,
- with free(). */
+ with free(). Settings on PT control whether variable and value labels are
+ included (pass NULL for PT to get default formatting in the absence of a
+ pivot table). */
char *
pivot_value_to_string (const struct pivot_value *value,
const struct pivot_table *pt)
return ds_steal_cstr (&s);
}
-char *
-pivot_value_to_string_defaults (const struct pivot_value *value)
-{
- static const struct pivot_table pt = {
- .show_values = SETTINGS_VALUE_SHOW_DEFAULT,
- .show_variables = SETTINGS_VALUE_SHOW_DEFAULT,
- .settings = FMT_SETTINGS_INIT,
- };
- return pivot_value_to_string (value, &pt);
-}
-
struct pivot_value *
pivot_value_clone (const struct pivot_value *old)
{