Changed a lot of ints to bools.
[pspp-builds.git] / src / language / command.c
index c55ff1b8c6a1d542d076a81e2ed97f28fc1a7849..16a663c50b731fa8c55a28377a9ce09eda4afc14 100644 (file)
@@ -34,6 +34,7 @@
 #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>
@@ -97,7 +98,8 @@ enum flags
   {
     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. */
@@ -262,9 +264,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;
@@ -276,7 +278,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. */
@@ -285,9 +287,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);
@@ -420,7 +422,7 @@ find_command (const char *name)
   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. */
@@ -594,7 +596,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
-        abort ();
+        NOT_REACHED ();
 
       msg (SE, _("%s is allowed only %s."), command->name, s);
 
@@ -632,6 +634,7 @@ cmd_complete (const char *prefix, const struct command **cmd)
     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;