- bool add_vars = (at == CTAT_LAYER ? a == PIVOT_AXIS_LAYER
- : at == CTAT_LAYERROW ? a != PIVOT_AXIS_COLUMN
- : at == CTAT_LAYERCOL ? a != PIVOT_AXIS_ROW
- : at == CTAT_TABLE ? false
- : true);
- if (add_vars)
+ enum pivot_axis_type ata, atb;
+ if (at == CTAT_ROW || at == CTAT_LAYERROW)
+ {
+ ata = PIVOT_AXIS_ROW;
+ atb = PIVOT_AXIS_COLUMN;
+ }
+ else if (at == CTAT_COL || at == CTAT_LAYERCOL)
+ {
+ ata = PIVOT_AXIS_COLUMN;
+ atb = PIVOT_AXIS_ROW;
+ }
+
+ if (((at == CTAT_LAYERCOL || at == CTAT_LAYERROW)
+ && a == atb && t->label_axis[a] != a)
+ || (at == CTAT_LAYER
+ && a != PIVOT_AXIS_LAYER
+ && t->label_axis[a] == PIVOT_AXIS_LAYER))
+ {
+ for (size_t k = nest->n - 1; k < nest->n; k--)
+ if (k != nest->scale_idx)
+ {
+ nest->areas[at][nest->n_areas[at]++] = k;
+ break;
+ }
+ continue;
+ }
+
+ if (at == CTAT_LAYER ? a == PIVOT_AXIS_LAYER
+ : at == CTAT_LAYERROW || at == CTAT_LAYERCOL ? a != atb
+ : at == CTAT_TABLE ? false
+ : true)