lex_match (lexer, T_LPAREN);
if (!lex_force_int (lexer))
goto error;
- data_parser_set_records (parser, lex_integer (lexer));
+
+ int records = lex_integer (lexer);
+ if (records < 0)
+ {
+ msg (SE, _("The %s value must be nonnegative."), "RECORDS");
+ goto error;
+ }
+ data_parser_set_records (parser, records);
lex_get (lexer);
lex_match (lexer, T_RPAREN);
}
lex_match (lexer, T_EQUALS);
if (!lex_force_int (lexer))
goto error;
- data_parser_set_skip (parser, lex_integer (lexer));
+ int skip = lex_integer (lexer);
+ if (skip < 0)
+ {
+ msg (SE, _("The %s value must be nonnegative."), "SKIP");
+ goto error;
+ }
+ data_parser_set_skip (parser, skip);
lex_get (lexer);
}
else if (lex_match_id (lexer, "END"))
])
AT_CLEANUP
+
+
+AT_SETUP([DATA LIST - Negative SKIP])
+AT_DATA([data-list.sps], [dnl
+DATA LIST LIST FILE='f.in' NOTABLE SKIP=-1 /a b c d.
+
+EXECUTE.
+])
+
+AT_CHECK([pspp -O format=csv data-list.sps], [1], [dnl
+data-list.sps:1: error: DATA LIST: The SKIP value must be nonnegative.
+
+data-list.sps:3: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([DATA LIST - Negative RECORDS])
+AT_DATA([data-list.sps], [dnl
+DATA LIST LIST FILE='f.in' NOTABLE RECORDS=-1 /a b c d.
+
+EXECUTE.
+])
+
+AT_CHECK([pspp -O format=csv data-list.sps], [1], [dnl
+data-list.sps:1: error: DATA LIST: The RECORDS value must be nonnegative.
+
+data-list.sps:3: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
+])
+
+AT_CLEANUP
+