- return (function == CTSF_PTILE
- ? xasprintf (_("Percentile %.2f"), percentile)
- : xstrdup (gettext (default_labels[function])));
+ return (spec->function == CTSF_PTILE
+ ? pivot_value_new_text_format (N_("Percentile %.2f"),
+ spec->percentile)
+ : pivot_value_new_text (default_labels[spec->function]));
+ }
+ else
+ {
+ struct substring in = ss_cstr (spec->label);
+ struct substring target = ss_cstr (")CILEVEL");
+
+ struct string out = DS_EMPTY_INITIALIZER;
+ for (;;)
+ {
+ size_t chunk = ss_find_substring (in, target);
+ ds_put_substring (&out, ss_head (in, chunk));
+ ss_advance (&in, chunk);
+ if (!in.length)
+ return pivot_value_new_user_text_nocopy (ds_steal_cstr (&out));
+
+ ss_advance (&in, target.length);
+ ds_put_format (&out, "%g", cilevel);
+ }
+ }