X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fcommand.c;h=1e040d6c677deb202604844e746c25c3d9555d18;hb=5e89e0049bd55f22412f547d8d7bfefc69443e98;hp=b842084eada0b00f33b2b0ce2d8d0b1113108aec;hpb=30728b09540b323fef43b23dd5f1e4d1e8298c92;p=pspp diff --git a/src/language/command.c b/src/language/command.c index b842084ead..1e040d6c67 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,6 @@ #include #include #include -#include #if HAVE_SYS_WAIT_H #include @@ -52,13 +52,24 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid +/* Returns true if RESULT is a valid "enum cmd_result", + false otherwise. */ +static inline bool +cmd_result_is_valid (enum cmd_result result) +{ + return (result == CMD_SUCCESS || result == CMD_EOF || result == CMD_FINISH + || (result >= CMD_PRIVATE_FIRST && result <= CMD_PRIVATE_LAST) + || result == CMD_FAILURE || result == CMD_NOT_IMPLEMENTED + || result == CMD_CASCADING_FAILURE); +} + /* Returns true if RESULT indicates success, false otherwise. */ bool cmd_result_is_success (enum cmd_result result) { - return (result == CMD_SUCCESS || result == CMD_EOF - || result == CMD_QUIT || result == CMD_END_SUBLOOP); + assert (cmd_result_is_valid (result)); + return result > 0; } /* Returns true if RESULT indicates failure, @@ -66,7 +77,8 @@ cmd_result_is_success (enum cmd_result result) bool cmd_result_is_failure (enum cmd_result result) { - return !cmd_result_is_success (result); + assert (cmd_result_is_valid (result)); + return result < 0; } /* Command processing states. */ @@ -175,6 +187,7 @@ do_parse_command (enum cmd_state state) tab_set_command_name (NULL); msg_set_command_name (NULL); + assert (cmd_result_is_valid (result)); return result; } @@ -628,7 +641,7 @@ command_generator (const char *text, int state) int cmd_finish (void) { - return CMD_QUIT; + return CMD_FINISH; } /* Parses the N command. */ @@ -832,17 +845,6 @@ cmd_new_file (void) return lex_end_of_command (); } -/* Parses, performs the CLEAR TRANSFORMATIONS command. */ -int -cmd_clear_transformations (void) -{ - cancel_transformations (); - /* FIXME: what about variables created by transformations? - They need to be properly initialized. */ - - return CMD_SUCCESS; -} - /* Parses a comment. */ int cmd_comment (void)