+/* Read record type 7, subtype 7. */
+static void
+read_mrsets (struct sfm_reader *r, size_t size, size_t count)
+{
+ struct text_record *text;
+
+ printf ("%08llx: multiple response sets\n",
+ (long long int) ftello (r->file));
+ text = open_text_record (r, size * count);
+ for (;;)
+ {
+ const char *name;
+ enum { MRSET_MC, MRSET_MD } type;
+ bool cat_label_from_counted_values = false;
+ bool label_from_var_label = false;
+ const char *counted;
+ const char *label;
+ const char *variables;
+
+ name = text_tokenize (text, '=');
+ if (name == NULL)
+ break;
+
+ if (text_match (text, 'C'))
+ {
+ type = MRSET_MC;
+ counted = NULL;
+ if (!text_match (text, ' '))
+ {
+ sys_warn (r, "missing space following 'C' at offset %zu "
+ "in mrsets record", text_pos (text));
+ break;
+ }
+ }
+ else if (text_match (text, 'D'))
+ {
+ type = MRSET_MD;
+ }
+ else if (text_match (text, 'E'))
+ {
+ char *number;
+
+ type = MRSET_MD;
+ cat_label_from_counted_values = true;
+
+ if (!text_match (text, ' '))
+ {
+ sys_warn (r, _("Missing space following 'E' at offset %zu "
+ "in MRSETS record"), text_pos (text));
+ break;
+ }
+
+ number = text_tokenize (text, ' ');
+ if (!strcmp (number, "11"))
+ label_from_var_label = true;
+ else if (strcmp (number, "1"))
+ sys_warn (r, _("Unexpected label source value `%s' "
+ "following 'E' at offset %zu in MRSETS record"),
+ number, text_pos (text));
+
+ }
+ else
+ {
+ sys_warn (r, "missing 'C', 'D', or 'E' at offset %zu "
+ "in mrsets record", text_pos (text));
+ break;
+ }
+
+ if (type == MRSET_MD)
+ {
+ counted = text_parse_counted_string (text);
+ if (counted == NULL)
+ break;
+ }
+
+ label = text_parse_counted_string (text);
+ if (label == NULL)
+ break;
+
+ variables = text_tokenize (text, '\n');
+ if (variables == NULL)
+ {
+ sys_warn (r, "missing variable names following label "
+ "at offset %zu in mrsets record", text_pos (text));
+ break;
+ }
+
+ printf ("\t\"%s\": multiple %s set",
+ name, type == MRSET_MC ? "category" : "dichotomy");
+ if (counted != NULL)
+ printf (", counted value \"%s\"", counted);
+ if (cat_label_from_counted_values)
+ printf (", category labels from counted values");
+ if (label[0] != '\0')
+ printf (", label \"%s\"", label);
+ if (label_from_var_label)
+ printf (", label from variable label");
+ printf(", variables \"%s\"\n", variables);
+ }
+ close_text_record (text);
+}
+