VECTOR: Improve error messages and coding style.
[pspp] / src / language / dictionary / split-file.c
index 8b4c8783371a8d165a1243c2896a9618f542f557..13eecbb4ce358ffd1d8ad2a7c6c61556343e8fa3 100644 (file)
@@ -55,8 +55,19 @@ cmd_split_file (struct lexer *lexer, struct dataset *ds)
                               : SPLIT_LAYERED);
 
       lex_match (lexer, T_BY);
+      int vars_start = lex_ofs (lexer);
       if (!parse_variables (lexer, dataset_dict (ds), &v, &n, PV_NO_DUPLICATE))
        return CMD_CASCADING_FAILURE;
+      int vars_end = lex_ofs (lexer) - 1;
+
+      if (n > MAX_SPLITS)
+        {
+          verify (MAX_SPLITS == 8);
+          lex_ofs_error (lexer, vars_start, vars_end,
+                         _("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);