dictionary: Limit split file variables to 8, for compatibility.
[pspp] / src / language / dictionary / split-file.c
index 48eec2958161224e021db6600152562543194588..8a134e1e769eca5562e57e31febb49b9c29b03d0 100644 (file)
@@ -43,20 +43,30 @@ int
 cmd_split_file (struct lexer *lexer, struct dataset *ds)
 {
   if (lex_match_id (lexer, "OFF"))
-    dict_set_split_vars (dataset_dict (ds), NULL, 0);
+    dict_clear_split_vars (dataset_dict (ds));
   else
     {
       struct variable **v;
       size_t n;
 
-      /* For now, ignore SEPARATE and LAYERED. */
-      (void) (lex_match_id (lexer, "SEPARATE") || lex_match_id (lexer, "LAYERED"));
+      enum split_type type = (!lex_match_id (lexer, "LAYERED")
+                              && lex_match_id (lexer, "SEPARATE")
+                              ? SPLIT_SEPARATE
+                              : SPLIT_LAYERED);
 
       lex_match (lexer, T_BY);
       if (!parse_variables (lexer, dataset_dict (ds), &v, &n, PV_NO_DUPLICATE))
        return CMD_CASCADING_FAILURE;
 
-      dict_set_split_vars (dataset_dict (ds), v, n);
+      if (n > MAX_SPLITS)
+        {
+          verify (MAX_SPLITS == 8);
+          msg (SE, _("At most 8 split variables may be specified."));
+          free (v);
+          return CMD_CASCADING_FAILURE;
+        }
+
+      dict_set_split_vars (dataset_dict (ds), v, n, type);
       free (v);
     }
 
@@ -68,7 +78,7 @@ void
 output_split_file_values (const struct dataset *ds, const struct ccase *c)
 {
   const struct dictionary *dict = dataset_dict (ds);
-  size_t n_vars = dict_get_split_cnt (dict);
+  size_t n_vars = dict_get_n_splits (dict);
   if (n_vars == 0)
     return;