-static const char *
-ctables_summary_label__ (const struct ctables_summary_spec *spec)
-{
- bool w = spec->weighted;
- enum ctables_area_type a = spec->user_area;
- switch (spec->function)
- {
- case CTSF_COUNT:
- return w ? N_("Count") : N_("Unweighted Count");
-
- case CTSF_ECOUNT:
- return N_("Adjusted Count");
-
- case CTSF_areaPCT_COUNT:
- switch (a)
- {
- case CTAT_TABLE: return w ? N_("Table %") : N_("Unweighted Table %");
- case CTAT_LAYER: return w ? N_("Layer %") : N_("Unweighted Layer %");
- case CTAT_LAYERROW: return w ? N_("Layer Row %") : N_("Unweighted Layer Row %");
- case CTAT_LAYERCOL: return w ? N_("Layer Column %") : N_("Unweighted Layer Column %");
- case CTAT_SUBTABLE: return w ? N_("Subtable %") : N_("Unweighted Subtable %");
- case CTAT_ROW: return w ? N_("Row %") : N_("Unweighted Row %");
- case CTAT_COL: return w ? N_("Column %") : N_("Unweighted Column %");
- }
- NOT_REACHED ();
-
- case CTSF_areaPCT_VALIDN:
- switch (a)
- {
- case CTAT_TABLE: return w ? N_("Table Valid N %") : N_("Unweighted Table Valid N %");
- case CTAT_LAYER: return w ? N_("Layer Valid N %") : N_("Unweighted Layer Valid N %");
- case CTAT_LAYERROW: return w ? N_("Layer Row Valid N %") : N_("Unweighted Layer Row Valid N %");
- case CTAT_LAYERCOL: return w ? N_("Layer Column Valid N %") : N_("Unweighted Layer Column Valid N %");
- case CTAT_SUBTABLE: return w ? N_("Subtable Valid N %") : N_("Unweighted Subtable Valid N %");
- case CTAT_ROW: return w ? N_("Row Valid N %") : N_("Unweighted Row Valid N %");
- case CTAT_COL: return w ? N_("Column Valid N %") : N_("Unweighted Column Valid N %");
- }
- NOT_REACHED ();
-
- case CTSF_areaPCT_TOTALN:
- switch (a)
- {
- case CTAT_TABLE: return w ? N_("Table Total N %") : N_("Unweighted Table Total N %");
- case CTAT_LAYER: return w ? N_("Layer Total N %") : N_("Unweighted Layer Total N %");
- case CTAT_LAYERROW: return w ? N_("Layer Row Total N %") : N_("Unweighted Layer Row Total N %");
- case CTAT_LAYERCOL: return w ? N_("Layer Column Total N %") : N_("Unweighted Layer Column Total N %");
- case CTAT_SUBTABLE: return w ? N_("Subtable Total N %") : N_("Unweighted Subtable Total N %");
- case CTAT_ROW: return w ? N_("Row Total N %") : N_("Unweighted Row Total N %");
- case CTAT_COL: return w ? N_("Column Total N %") : N_("Unweighted Column Total N %");
- }
- NOT_REACHED ();
-
- case CTSF_MAXIMUM: return N_("Maximum");
- case CTSF_MEAN: return w ? N_("Mean") : N_("Unweighted Mean");
- case CTSF_MEDIAN: return N_("Median");
- case CTSF_MINIMUM: return N_("Minimum");
- case CTSF_MISSING: return N_("Missing");
- case CTSF_MODE: return N_("Mode");
- case CTSF_PTILE: NOT_REACHED ();
- case CTSF_RANGE: return N_("Range");
- case CTSF_SEMEAN: return N_("Std Error of Mean");
- case CTSF_STDDEV: return N_("Std Deviation");
- case CTSF_SUM: return N_("Sum");
- case CTSF_TOTALN: return N_("Total N");
- case CTSF_ETOTALN: return N_("Adjusted Total N");
- case CTSF_VALIDN: return N_("Valid N");
- case CTSF_EVALIDN: return N_("Adjusted Valid N");
- case CTSF_VARIANCE: return N_("Variance");
- case CTSF_areaPCT_SUM:
- switch (a)
- {
- case CTAT_TABLE: return w ? N_("Table Sum %") : N_("Unweighted Table Sum %");
- case CTAT_LAYER: return w ? N_("Layer Sum %") : N_("Unweighted Layer Sum %");
- case CTAT_LAYERROW: return w ? N_("Layer Row Sum %") : N_("Unweighted Layer Row Sum %");
- case CTAT_LAYERCOL: return w ? N_("Layer Column Sum %") : N_("Unweighted Layer Column Sum %");
- case CTAT_SUBTABLE: return w ? N_("Subtable Sum %") : N_("Unweighted Subtable Sum %");
- case CTAT_ROW: return w ? N_("Row Sum %") : N_("Unweighted Row Sum %");
- case CTAT_COL: return w ? N_("Column Sum %") : N_("Unweighted Column Sum %");
- }
- NOT_REACHED ();
-
- case CTSF_areaID:
- switch (a)
- {
- /* Don't bother translating these: they are for developers only. */
- case CTAT_TABLE: return "Table ID";
- case CTAT_LAYER: return "Layer ID";
- case CTAT_LAYERROW: return "Layer Row ID";
- case CTAT_LAYERCOL: return "Layer Column ID";
- case CTAT_SUBTABLE: return "Subtable ID";
- case CTAT_ROW: return "Row ID";
- case CTAT_COL: return "Column ID";
- }
- NOT_REACHED ();
- }
-
- NOT_REACHED ();
-}
-
-static struct pivot_value *
-ctables_summary_label (const struct ctables_summary_spec *spec, double cilevel)
-{
- if (!spec->label)
- {
- if (spec->function == CTSF_PTILE)
- {
- double p = spec->percentile;
- char *s = (spec->weighted
- ? xasprintf (_("Percentile %.2f"), p)
- : xasprintf (_("Unweighted Percentile %.2f"), p));
- return pivot_value_new_user_text_nocopy (s);
- }
- else
- return pivot_value_new_text (ctables_summary_label__ (spec));
- }
- 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);
- }
- }
-}
-
-static const char *
-ctables_summary_function_name (enum ctables_summary_function function,
- bool weighted,
- enum ctables_area_type area,
- char *buffer, size_t bufsize)
-{
- const struct ctables_function_info *cfi = &ctables_function_info[function];
- snprintf (buffer, bufsize, "%s%s%s",
- weighted ? "" : "U",
- cfi->is_area ? ctables_area_type_name[area] : "",
- cfi->basename.string);
- return buffer;
-}
-