projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Damn! Forgot to change casenum_t in *.q
[pspp]
/
src
/
language
/
command.c
diff --git
a/src/language/command.c
b/src/language/command.c
index 61d54f9c4d3403f54f2cf32151b663f2ee273025..f98277aa75048f665c33c0bde1646d70701ecd08 100644
(file)
--- a/
src/language/command.c
+++ b/
src/language/command.c
@@
-34,6
+34,7
@@
#include <language/lexer/lexer.h>
#include <language/line-buffer.h>
#include <libpspp/alloc.h>
#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>
#include <libpspp/compiler.h>
#include <libpspp/message.h>
#include <libpspp/message.h>
@@
-107,7
+108,7
@@
struct command
enum states states; /* States in which command is allowed. */
enum flags flags; /* Other command requirements. */
const char *name; /* Command name. */
enum states states; /* States in which command is allowed. */
enum flags flags; /* Other command requirements. */
const char *name; /* Command name. */
- int (*function) (
void);
/* Function to call. */
+ int (*function) (
struct dataset *);
/* Function to call. */
};
/* Define the command array. */
};
/* Define the command array. */
@@
-130,24
+131,24
@@
static void set_completion_state (enum cmd_state);
/* Command parser. */
static const struct command *parse_command_name (void);
/* Command parser. */
static const struct command *parse_command_name (void);
-static enum cmd_result do_parse_command (enum cmd_state);
+static enum cmd_result do_parse_command (
struct dataset *ds,
enum cmd_state);
/* Parses an entire command, from command name to terminating
dot. On failure, skips to the terminating dot.
Returns the command's success or failure result. */
enum cmd_result
/* Parses an entire command, from command name to terminating
dot. On failure, skips to the terminating dot.
Returns the command's success or failure result. */
enum cmd_result
-cmd_parse (enum cmd_state state)
+cmd_parse (
struct dataset *ds,
enum cmd_state state)
{
int result;
som_new_series ();
{
int result;
som_new_series ();
- result = do_parse_command (state);
+ result = do_parse_command (
ds,
state);
if (cmd_result_is_failure (result))
lex_discard_rest_of_command ();
unset_cmd_algorithm ();
if (cmd_result_is_failure (result))
lex_discard_rest_of_command ();
unset_cmd_algorithm ();
- dict_clear_aux (d
efault_dict
);
+ dict_clear_aux (d
ataset_dict (ds)
);
return result;
}
return result;
}
@@
-155,7
+156,7
@@
cmd_parse (enum cmd_state state)
/* Parses an entire command, from command name to terminating
dot. */
static enum cmd_result
/* Parses an entire command, from command name to terminating
dot. */
static enum cmd_result
-do_parse_command (enum cmd_state state)
+do_parse_command (
struct dataset *ds,
enum cmd_state state)
{
const struct command *command;
enum cmd_result result;
{
const struct command *command;
enum cmd_result result;
@@
-177,8
+178,11
@@
do_parse_command (enum cmd_state state)
command = parse_command_name ();
if (command == NULL)
return CMD_FAILURE;
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);
else if ((command->flags & F_TESTING) && !get_testing_mode ())
{
msg (SE, _("%s may be used only in testing mode."), command->name);
@@
-199,7
+203,7
@@
do_parse_command (enum cmd_state state)
/* Execute command. */
msg_set_command_name (command->name);
tab_set_command_name (command->name);
/* Execute command. */
msg_set_command_name (command->name);
tab_set_command_name (command->name);
- result = command->function ();
+ result = command->function (
ds
);
tab_set_command_name (NULL);
msg_set_command_name (NULL);
tab_set_command_name (NULL);
msg_set_command_name (NULL);
@@
-263,9
+267,9
@@
find_word (const char *string, size_t *word_len)
return string;
}
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. */
their first three letters. */
-static
int
+static
bool
conflicting_3char_prefixes (const char *a, const char *b)
{
size_t aw_len, bw_len;
conflicting_3char_prefixes (const char *a, const char *b)
{
size_t aw_len, bw_len;
@@
-277,7
+281,7
@@
conflicting_3char_prefixes (const char *a, const char *b)
/* Words that are the same don't conflict. */
if (aw_len == bw_len && !buf_compare_case (aw, bw, aw_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. */
/* Words that are otherwise the same in the first three letters
do conflict. */
@@
-286,9
+290,9
@@
conflicting_3char_prefixes (const char *a, const char *b)
|| (bw_len == 3 && aw_len > 3)) && !buf_compare_case (aw, bw, 3);
}
|| (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. */
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);
conflicting_3char_prefix_command (const struct command *cmd)
{
assert (cmd >= commands && cmd < commands + command_cnt);
@@
-421,7
+425,7
@@
find_command (const char *name)
for (cmd = commands; cmd < commands + command_cnt; cmd++)
if (!strcmp (cmd->name, name))
return cmd;
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. */
}
/* Frees the WORD_CNT words in WORDS. */
@@
-595,7
+599,7
@@
report_state_mismatch (const struct command *command, enum cmd_state state)
else if (allowed_cnt == 3)
s = xasprintf (_("%s, %s, or %s"), allowed[0], allowed[1], allowed[2]);
else
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);
msg (SE, _("%s is allowed only %s."), command->name, s);
@@
-645,14
+649,14
@@
cmd_complete (const char *prefix, const struct command **cmd)
/* Parse and execute FINISH command. */
int
/* Parse and execute FINISH command. */
int
-cmd_finish (
void
)
+cmd_finish (
struct dataset *ds UNUSED
)
{
return CMD_FINISH;
}
/* Parses the N command. */
int
{
return CMD_FINISH;
}
/* Parses the N command. */
int
-cmd_n_of_cases (
void
)
+cmd_n_of_cases (
struct dataset *ds
)
{
/* Value for N. */
int x;
{
/* Value for N. */
int x;
@@
-662,23
+666,23
@@
cmd_n_of_cases (void)
x = lex_integer ();
lex_get ();
if (!lex_match_id ("ESTIMATED"))
x = lex_integer ();
lex_get ();
if (!lex_match_id ("ESTIMATED"))
- dict_set_case_limit (d
efault_dict
, x);
+ dict_set_case_limit (d
ataset_dict (ds)
, x);
return lex_end_of_command ();
}
/* Parses, performs the EXECUTE procedure. */
int
return lex_end_of_command ();
}
/* Parses, performs the EXECUTE procedure. */
int
-cmd_execute (
void
)
+cmd_execute (
struct dataset *ds
)
{
{
- if (!procedure (NULL, NULL))
+ if (!procedure (
ds,
NULL, NULL))
return CMD_CASCADING_FAILURE;
return lex_end_of_command ();
}
/* Parses, performs the ERASE command. */
int
return CMD_CASCADING_FAILURE;
return lex_end_of_command ();
}
/* Parses, performs the ERASE command. */
int
-cmd_erase (
void
)
+cmd_erase (
struct dataset *ds UNUSED
)
{
if (get_safer_mode ())
{
{
if (get_safer_mode ())
{
@@
-807,7
+811,7
@@
run_command (void)
/* Parses, performs the HOST command. */
int
/* Parses, performs the HOST command. */
int
-cmd_host (
void
)
+cmd_host (
struct dataset *ds UNUSED
)
{
int code;
{
int code;
@@
-844,16
+848,16
@@
cmd_host (void)
/* Parses, performs the NEW FILE command. */
int
/* Parses, performs the NEW FILE command. */
int
-cmd_new_file (
void
)
+cmd_new_file (
struct dataset *ds
)
{
{
- discard_variables ();
+ discard_variables (
ds
);
return lex_end_of_command ();
}
/* Parses a comment. */
int
return lex_end_of_command ();
}
/* Parses a comment. */
int
-cmd_comment (
void
)
+cmd_comment (
struct dataset *ds UNUSED
)
{
lex_skip_comment ();
return CMD_SUCCESS;
{
lex_skip_comment ();
return CMD_SUCCESS;