SPLIT FILE: Add LAYERED vs. SEPARATE distinction to the dictionary.
[pspp] / src / language / dictionary / split-file.c
index 73cc20a0570ddb9d8ed4e4c324356a578aa2ffdf..8b4c8783371a8d165a1243c2896a9618f542f557 100644 (file)
@@ -43,20 +43,22 @@ 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);
+      dict_set_split_vars (dataset_dict (ds), v, n, type);
       free (v);
     }
 
@@ -68,7 +70,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;