#include "language/lexer/variable-parser.h"
#include "libpspp/array.h"
#include "libpspp/assertion.h"
-#include "libpspp/bit-vector.h"
#include "libpspp/compiler.h"
#include "libpspp/i18n.h"
#include "libpspp/message.h"
{
if (!lex_match (lexer, T_LPAREN))
{
- lex_error_expecting (lexer, "`('", NULL_SENTINEL);
+ lex_error_expecting (lexer, "`('");
free (v);
goto done;
}
}
if (!lex_match (lexer, T_RPAREN))
{
- lex_error_expecting (lexer, "`)'", NULL_SENTINEL);
+ lex_error_expecting (lexer, "`)'");
free (v);
goto done;
}
}
- sort (&v[prev_nv], nv - prev_nv, sizeof *v,
- compare_variables_given_ordering, &ordering);
+
+ if (!ordering.positional)
+ sort (&v[prev_nv], nv - prev_nv, sizeof *v,
+ compare_variables_given_ordering, &ordering);
+ else if (!ordering.forward)
+ reverse_array(&v[prev_nv], nv - prev_nv, sizeof *v);
}
while (lex_token (lexer) != T_SLASH
&& lex_token (lexer) != T_ENDCMD);
if (!lex_match (lexer, T_LPAREN))
{
- lex_error_expecting (lexer, "`('", NULL_SENTINEL);
+ lex_error_expecting (lexer, "`('");
goto done;
}
if (!parse_variables (lexer, dataset_dict (ds),
goto done;
if (!lex_match (lexer, T_EQUALS))
{
- lex_error_expecting (lexer, "`='", NULL_SENTINEL);
+ lex_error_expecting (lexer, "`='");
goto done;
}
}
if (!lex_match (lexer, T_RPAREN))
{
- lex_error_expecting (lexer, "`)'", NULL_SENTINEL);
+ lex_error_expecting (lexer, "`)'");
goto done;
}
}
"not be given in conjunction with the %s "
"subcommand."),
"DROP", "KEEP"
- );
+ );
goto done;
}
already_encountered |= 4;
goto done;
vm.drop_vars = drop_vars;
vm.n_drop = n_drop;
+
+ if (n_drop == dict_get_var_cnt (dataset_dict (ds)))
+ {
+ msg (SE, _("%s may not be used to delete all variables "
+ "from the active dataset dictionary. "
+ "Use %s instead."), "MODIFY VARS", "NEW FILE");
+ goto done;
+ }
}
else if (lex_match_id (lexer, "MAP"))
{
break;
if (lex_token (lexer) != T_SLASH)
{
- lex_error_expecting (lexer, "`/'", "`.'", NULL_SENTINEL);
+ lex_error_expecting (lexer, "`/'", "`.'");
goto done;
}
lex_get (lexer);
done:
free (vm.reorder_vars);
free (vm.rename_vars);
- for (size_t i = 0; i < vm.n_rename; i++)
- free (vm.new_names[i]);
+ if (vm.new_names)
+ for (size_t i = 0; i < vm.n_rename; i++)
+ free (vm.new_names[i]);
free (vm.new_names);
free (vm.drop_vars);
return ret_code;