+
+/* Compares the values of the VAR_CNT variables in VP
+ in cases A and B and returns a strcmp()-type result. */
+int
+case_compare (const struct ccase *a, const struct ccase *b,
+ struct variable *const *vp, size_t var_cnt)
+{
+ return case_compare_2dict (a, b, vp, vp, var_cnt);
+}
+
+/* Compares the values of the VAR_CNT variables in VAP in case CA
+ to the values of the VAR_CNT variables in VBP in CB
+ and returns a strcmp()-type result. */
+int
+case_compare_2dict (const struct ccase *ca, const struct ccase *cb,
+ struct variable *const *vap, struct variable *const *vbp,
+ size_t var_cnt)
+{
+ for (; var_cnt-- > 0; vap++, vbp++)
+ {
+ const struct variable *va = *vap;
+ const struct variable *vb = *vbp;
+
+ assert (va->type == vb->type);
+ assert (va->width == vb->width);
+
+ if (va->width == 0)
+ {
+ double af = case_num (ca, va->fv);
+ double bf = case_num (cb, vb->fv);
+
+ if (af != bf)
+ return af > bf ? 1 : -1;
+ }
+ else
+ {
+ const char *as = case_str (ca, va->fv);
+ const char *bs = case_str (cb, vb->fv);
+ int cmp = memcmp (as, bs, va->width);
+
+ if (cmp != 0)
+ return cmp;
+ }
+ }
+ return 0;
+}
+
+/* Returns a pointer to the array of `union value's used for C.
+ The caller must *not* modify the returned data.
+
+ NOTE: This function breaks the case abstraction. It should
+ *not* be used often. Prefer the other case functions. */
+const union value *
+case_data_all (const struct ccase *c)
+{
+ assert (c != NULL);
+ assert (c->this == c);
+ assert (c->case_data != NULL);
+ assert (c->case_data->ref_cnt > 0);
+
+ return c->case_data->values;
+}
+
+/* Returns a pointer to the array of `union value's used for C.
+ The caller is allowed to modify the returned data.
+
+ NOTE: This function breaks the case abstraction. It should
+ *not* be used often. Prefer the other case functions. */
+union value *
+case_data_all_rw (struct ccase *c)
+{
+ assert (c != NULL);
+ assert (c->this == c);
+ assert (c->case_data != NULL);
+ assert (c->case_data->ref_cnt > 0);
+
+ if (c->case_data->ref_cnt > 1)
+ case_unshare (c);
+ return c->case_data->values;
+}