* inftarg.c (child_create_inferior, child_attach,
[deliverable/binutils-gdb.git] / gdb / command.c
index 4eed2a00d4c4e802272ae63eaa90675cebaa37bc..5327a4cde8e6cd297aecb99ede64d4a48a117489 100644 (file)
@@ -45,6 +45,9 @@ parse_binary_operation PARAMS ((char *));
 static void
 print_doc_line PARAMS ((FILE *, char *));
 
+extern void
+not_just_help_class_command PARAMS ((char *, int));
+
 /* Add element named NAME to command list *LIST.
    FUN should be the function to execute the command;
    it will get a character string as argument, with leading
@@ -162,7 +165,7 @@ add_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
   return c;
 }
 
-/* Like add_prefix_cmd butsets the abbrev_flag on the new command. */
+/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
    
 struct cmd_list_element *
 add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
@@ -186,10 +189,9 @@ add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
 
 /* ARGSUSED */
 void
-not_just_help_class_command (args, from_tty, c)
+not_just_help_class_command (args, from_tty)
      char *args;
      int from_tty;
-     struct cmd_list_element *c;
 {
 }
 
@@ -233,7 +235,7 @@ add_show_from_set (setcmd, list)
   struct cmd_list_element *showcmd =
     (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
 
-  bcopy (setcmd, showcmd, sizeof (struct cmd_list_element));
+  memcpy (showcmd, setcmd, sizeof (struct cmd_list_element));
   delete_cmd (showcmd->name, list);
   showcmd->type = show_cmd;
   
@@ -262,7 +264,7 @@ delete_cmd (name, list)
   while (*list && !strcmp ((*list)->name, name))
     {
       p = (*list)->next;
-      free (*list);
+      free ((PTR)*list);
       *list = p;
     }
 
@@ -272,7 +274,7 @@ delete_cmd (name, list)
        if (!strcmp (c->next->name, name))
          {
            p = c->next->next;
-           free (c->next);
+           free ((PTR)c->next);
            c->next = p;
          }
        else
@@ -415,7 +417,7 @@ print_doc_line (stream, str)
   if (p - str > line_size - 1)
     {
       line_size = p - str + 1;
-      free (line_buffer);
+      free ((PTR)line_buffer);
       line_buffer = (char *) xmalloc (line_size);
     }
   strncpy (line_buffer, str, p - str);
@@ -469,36 +471,35 @@ help_cmd_list (list, class, prefix, recurse, stream)
     }
 }
 \f
-/* This routine takes a line of TEXT and a CLIST in which to
-   start the lookup.  When it returns it will have incremented the text
-   pointer past the section of text it matched, set *RESULT_LIST to
-   the list in which the last word was matched, and will return the
-   cmd list element which the text matches.  It will return 0 if no
-   match at all was possible.  It will return -1 if ambigous matches are
-   possible; in this case *RESULT_LIST will be set to the list in which
-   there are ambiguous choices (and text will be set to the ambiguous
-   text string).
+/* This routine takes a line of TEXT and a CLIST in which to start the
+   lookup.  When it returns it will have incremented the text pointer past
+   the section of text it matched, set *RESULT_LIST to point to the list in
+   which the last word was matched, and will return a pointer to the cmd
+   list element which the text matches.  It will return NULL if no match at
+   all was possible.  It will return -1 (cast appropriately, ick) if ambigous
+   matches are possible; in this case *RESULT_LIST will be set to point to
+   the list in which there are ambiguous choices (and *TEXT will be set to
+   the ambiguous text string).
 
    It does no error reporting whatsoever; control will always return
    to the superior routine.
 
-   In the case of an ambiguous return (-1), *RESULT_LIST will be set to
-   point at the prefix_command (ie. the best match) *or* (special
-   case) will be 0 if no prefix command was ever found.  For example,
-   in the case of "info a", "info" matches without ambiguity, but "a"
-   could be "args" or "address", so *RESULT_LIST is set to
-   the cmd_list_element for "info".  So in this case
-   result list should not be interpeted as a pointer to the beginning
-   of a list; it simply points to a specific command.
+   In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
+   at the prefix_command (ie. the best match) *or* (special case) will be NULL
+   if no prefix command was ever found.  For example, in the case of "info a",
+   "info" matches without ambiguity, but "a" could be "args" or "address", so
+   *RESULT_LIST is set to the cmd_list_element for "info".  So in this case
+   RESULT_LIST should not be interpeted as a pointer to the beginning of a
+   list; it simply points to a specific command.
 
    If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
    affect the operation).
 
    This routine does *not* modify the text pointed to by TEXT.
    
-   If IGNORE_HELP_CLASSES is nonzero, ignore any command list
-   elements which are actually help classes rather than commands (i.e.
-   the function field of the struct cmd_list_element is 0).  */
+   If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
+   are actually help classes rather than commands (i.e. the function field of
+   the struct cmd_list_element is NULL).  */
 
 struct cmd_list_element *
 lookup_cmd_1 (text, clist, result_list, ignore_help_classes)
@@ -535,7 +536,7 @@ lookup_cmd_1 (text, clist, result_list, ignore_help_classes)
   for (tmp = 0; tmp < len; tmp++)
     {
       char x = (*text)[tmp];
-      command[tmp] = (x >= 'A' && x <= 'Z') ? x - 'A' + 'a' : x;
+      command[tmp] = isupper(x) ? tolower(x) : x;
     }
   command[len] = '\0';
 
@@ -784,10 +785,7 @@ lookup_cmd (line, list, cmdtype, allow_unknown)
   /* Find end of command name.  */
 
   p = *line;
-  while (*p == '-'
-        || (*p >= 'a' && *p <= 'z')
-        || (*p >= 'A' && *p <= 'Z')
-        || (*p >= '0' && *p <= '9'))
+  while (*p == '-' || isalnum(*p))
     p++;
 
   /* Look up the command name.
@@ -812,8 +810,8 @@ lookup_cmd (line, list, cmdtype, allow_unknown)
   for (cmd_len = 0; cmd_len < p - *line; cmd_len++)
     {
       char x = (*line)[cmd_len];
-      if (x >= 'A' && x <= 'Z')
-       processed_cmd[cmd_len] = x - 'A' + 'a';
+      if (isupper(x))
+       processed_cmd[cmd_len] = tolower(x);
       else
        processed_cmd[cmd_len] = x;
     }
@@ -924,7 +922,7 @@ complete_on_cmdlist (list, text)
 
   if (matches == 0)
     {
-      free (matchlist);
+      free ((PTR)matchlist);
       matchlist = 0;
     }
   else
This page took 0.025371 seconds and 4 git commands to generate.