From: Ben Pfaff Date: Fri, 16 Sep 2022 23:14:34 +0000 (-0700) Subject: DELETE VARIABLES: Improve error messages. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18fb045fc51127bb69d2f241c7878088c357853e;p=pspp DELETE VARIABLES: Improve error messages. --- diff --git a/src/language/dictionary/delete-variables.c b/src/language/dictionary/delete-variables.c index 1063b1652e..03ccd115fe 100644 --- a/src/language/dictionary/delete-variables.c +++ b/src/language/dictionary/delete-variables.c @@ -47,9 +47,10 @@ cmd_delete_variables (struct lexer *lexer, struct dataset *ds) goto error; if (n_vars == dict_get_n_vars (dataset_dict (ds))) { - msg (SE, _("%s may not be used to delete all variables " - "from the active dataset dictionary. " - "Use %s instead."), "DELETE VARIABLES", "NEW FILE"); + lex_ofs_error (lexer, 0, lex_ofs (lexer) - 1, + _("%s may not be used to delete all variables " + "from the active dataset dictionary. " + "Use %s instead."), "DELETE VARIABLES", "NEW FILE"); goto error; } diff --git a/tests/language/dictionary/delete-variables.at b/tests/language/dictionary/delete-variables.at index b4b199987b..b5cda6e9d0 100644 --- a/tests/language/dictionary/delete-variables.at +++ b/tests/language/dictionary/delete-variables.at @@ -62,3 +62,27 @@ s2,n1 2,. @&t@ ]) AT_CLEANUP + +AT_SETUP([DELETE VARIABLES syntax errors]) +AT_DATA([delete-variables.sps], [dnl +DATA LIST LIST NOTABLE /x y z. +BEGIN DATA. +1 2 3 +END DATA. +TEMPORARY. +DELETE VARIABLES x. +DELETE VARIABLES y z. +]) +AT_DATA([insert.sps], [dnl +INSERT FILE='delete-variables.sps' ERROR=IGNORE. +]) +AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl +"delete-variables.sps:6.1-6.16: error: DELETE VARIABLES: DELETE VARIABLES may not be used after TEMPORARY. Temporary transformations will be made permanent. + 6 | DELETE VARIABLES x. + | ^~~~~~~~~~~~~~~~" + +"delete-variables.sps:7.1-7.20: error: DELETE VARIABLES: DELETE VARIABLES may not be used to delete all variables from the active dataset dictionary. Use NEW FILE instead. + 7 | DELETE VARIABLES y z. + | ^~~~~~~~~~~~~~~~~~~~" +]) +AT_CLEANUP \ No newline at end of file