X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fsplit-file.c;h=13eecbb4ce358ffd1d8ad2a7c6c61556343e8fa3;hb=7be27d2d9fb7f5d62523c744599bc4cc2f3fc1ea;hp=1ebd7ae9ca6fa415cd2b13a737ea255827562244;hpb=339f1956cc727eda788638644ef93ab7852b31cd;p=pspp diff --git a/src/language/dictionary/split-file.c b/src/language/dictionary/split-file.c index 1ebd7ae9ca..13eecbb4ce 100644 --- a/src/language/dictionary/split-file.c +++ b/src/language/dictionary/split-file.c @@ -43,20 +43,33 @@ 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); + int vars_start = lex_ofs (lexer); 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); + 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); }