#include <language/lexer/lexer.h>
#include <language/line-buffer.h>
#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
#include <libpspp/compiler.h>
#include <libpspp/message.h>
#include <libpspp/message.h>
{
F_ENHANCED = 0x10, /* Allowed only in enhanced syntax mode. */
F_TESTING = 0x20, /* Allowed only in testing mode. */
- F_KEEP_FINAL_TOKEN = 0x40 /* Don't skip final token in command name. */
+ F_KEEP_FINAL_TOKEN = 0x40,/* Don't skip final token in command name. */
+ F_ABBREV = 0x80 /* Not a candidate for name completion. */
};
/* A single command. */
lex_discard_rest_of_command ();
unset_cmd_algorithm ();
- dict_clear_aux (default_dict);
+ dict_clear_aux (dataset_dict (current_dataset));
return result;
}
command = parse_command_name ();
if (command == NULL)
return CMD_FAILURE;
- else if (command->function == NULL)
- return CMD_NOT_IMPLEMENTED;
+ else if (command->function == NULL)
+ {
+ msg (SE, _("%s is unimplemented."), command->name);
+ return CMD_NOT_IMPLEMENTED;
+ }
else if ((command->flags & F_TESTING) && !get_testing_mode ())
{
msg (SE, _("%s may be used only in testing mode."), command->name);
return string;
}
-/* Returns nonzero if strings A and B can be confused based on
+/* Returns true if strings A and B can be confused based on
their first three letters. */
-static int
+static bool
conflicting_3char_prefixes (const char *a, const char *b)
{
size_t aw_len, bw_len;
/* Words that are the same don't conflict. */
if (aw_len == bw_len && !buf_compare_case (aw, bw, aw_len))
- return 0;
+ return false;
/* Words that are otherwise the same in the first three letters
do conflict. */
|| (bw_len == 3 && aw_len > 3)) && !buf_compare_case (aw, bw, 3);
}
-/* Returns nonzero if CMD can be confused with another command
+/* Returns true if CMD can be confused with another command
based on the first three letters of its first word. */
-static int
+static bool
conflicting_3char_prefix_command (const struct command *cmd)
{
assert (cmd >= commands && cmd < commands + command_cnt);
for (cmd = commands; cmd < commands + command_cnt; cmd++)
if (!strcmp (cmd->name, name))
return cmd;
- abort ();
+ NOT_REACHED ();
}
/* Frees the WORD_CNT words in WORDS. */
else if (allowed_cnt == 3)
s = xasprintf (_("%s, %s, or %s"), allowed[0], allowed[1], allowed[2]);
else
- abort ();
+ NOT_REACHED ();
msg (SE, _("%s is allowed only %s."), command->name, s);
if (!memcasecmp ((*cmd)->name, prefix, strlen (prefix))
&& (!((*cmd)->flags & F_TESTING) || get_testing_mode ())
&& (!((*cmd)->flags & F_ENHANCED) || get_syntax () == ENHANCED)
+ && !((*cmd)->flags & F_ABBREV)
&& ((*cmd)->function != NULL)
&& in_correct_state (*cmd, completion_state))
return (*cmd)++->name;
x = lex_integer ();
lex_get ();
if (!lex_match_id ("ESTIMATED"))
- dict_set_case_limit (default_dict, x);
+ dict_set_case_limit (dataset_dict (current_dataset), x);
return lex_end_of_command ();
}
int
cmd_execute (void)
{
- if (!procedure (NULL, NULL))
+ if (!procedure (current_dataset,NULL, NULL))
return CMD_CASCADING_FAILURE;
return lex_end_of_command ();
}
int
cmd_new_file (void)
{
- discard_variables ();
+ discard_variables (current_dataset);
return lex_end_of_command ();
}