Updated the docs and the parser for EXAMINE to make it clearer which options
[pspp] / src / language / command.c
index a465aa0dad7c7f4692ec465782990f3592e9c7e3..f98277aa75048f665c33c0bde1646d70701ecd08 100644 (file)
@@ -108,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. */
-    int (*function) (void);    /* Function to call. */
+    int (*function) (struct dataset *);        /* Function to call. */
   };
 
 /* Define the command array. */
@@ -131,24 +131,24 @@ static void set_completion_state (enum cmd_state);
 /* 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
-cmd_parse (enum cmd_state state) 
+cmd_parse (struct dataset *ds, enum cmd_state state) 
 {
   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 ();
-  dict_clear_aux (default_dict);
+  dict_clear_aux (dataset_dict (ds));
 
   return result;
 }
@@ -156,7 +156,7 @@ cmd_parse (enum cmd_state state)
 /* 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;
@@ -178,8 +178,11 @@ do_parse_command (enum cmd_state state)
   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);
@@ -200,7 +203,7 @@ do_parse_command (enum cmd_state state)
   /* 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);
     
@@ -264,9 +267,9 @@ find_word (const char *string, size_t *word_len)
   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;
@@ -278,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))
-    return 0;
+    return false;
   
   /* Words that are otherwise the same in the first three letters
      do conflict. */
@@ -287,9 +290,9 @@ conflicting_3char_prefixes (const char *a, const char *b)
           || (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);
@@ -646,14 +649,14 @@ cmd_complete (const char *prefix, const struct command **cmd)
 
 /* Parse and execute FINISH command. */
 int
-cmd_finish (void)
+cmd_finish (struct dataset *ds UNUSED)
 {
   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;
@@ -663,23 +666,23 @@ cmd_n_of_cases (void)
   x = lex_integer ();
   lex_get ();
   if (!lex_match_id ("ESTIMATED"))
-    dict_set_case_limit (default_dict, x);
+    dict_set_case_limit (dataset_dict (ds), x);
 
   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
-cmd_erase (void)
+cmd_erase (struct dataset *ds UNUSED)
 {
   if (get_safer_mode ()) 
     { 
@@ -808,7 +811,7 @@ run_command (void)
 
 /* Parses, performs the HOST command. */
 int
-cmd_host (void)
+cmd_host (struct dataset *ds UNUSED)
 {
   int code;
 
@@ -845,16 +848,16 @@ cmd_host (void)
 
 /* 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
-cmd_comment (void)
+cmd_comment (struct dataset *ds UNUSED)
 {
   lex_skip_comment ();
   return CMD_SUCCESS;