Check for <sys/poll.h>.
[deliverable/binutils-gdb.git] / gdb / command.c
CommitLineData
c906108c 1/* Handle lists of commands, their decoding and documentation, for GDB.
d9fcf2fb 2 Copyright 1986, 1989, 1990, 1991, 1998, 2000 Free Software Foundation, Inc.
c906108c 3
c5aa993b
JM
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
c906108c 8
c5aa993b
JM
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
c906108c 13
c5aa993b
JM
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
c906108c
SS
18
19#include "defs.h"
20#include "gdbcmd.h"
21#include "symtab.h"
22#include "value.h"
23#include <ctype.h>
24#include "gdb_string.h"
8b93c638
JM
25#ifdef UI_OUT
26#include "ui-out.h"
27#endif
c906108c 28
03f2053f 29#include "gdb_wait.h"
6837a0a2 30#include "gnu-regex.h"
53a5351d
JM
31/* FIXME: this should be auto-configured! */
32#ifdef __MSDOS__
33# define CANT_FORK
34#endif
35
c906108c
SS
36/* Prototypes for local functions */
37
a14ed312 38static void undef_cmd_error (char *, char *);
c906108c 39
a14ed312 40static void show_user (char *, int);
c906108c 41
d9fcf2fb 42static void show_user_1 (struct cmd_list_element *, struct ui_file *);
c906108c 43
a14ed312 44static void make_command (char *, int);
c906108c 45
a14ed312 46static void shell_escape (char *, int);
c906108c 47
a14ed312 48static int parse_binary_operation (char *);
c906108c 49
d9fcf2fb 50static void print_doc_line (struct ui_file *, char *);
c906108c 51
a14ed312
KB
52static struct cmd_list_element *find_cmd (char *command,
53 int len,
54 struct cmd_list_element *clist,
55 int ignore_help_classes,
56 int *nfound);
6837a0a2
DB
57static void apropos_cmd_helper (struct ui_file *, struct cmd_list_element *,
58 struct re_pattern_buffer *, char *);
59
c85871a3
AC
60static void help_all (struct ui_file *stream);
61
6837a0a2 62void apropos_command (char *, int);
392a587b 63
a14ed312 64void _initialize_command (void);
c906108c
SS
65
66/* Add element named NAME.
67 CLASS is the top level category into which commands are broken down
68 for "help" purposes.
69 FUN should be the function to execute the command;
70 it will get a character string as argument, with leading
71 and trailing blanks already eliminated.
72
73 DOC is a documentation string for the command.
74 Its first line should be a complete sentence.
75 It should start with ? for a command that is an abbreviation
76 or with * for a command that most users don't need to know about.
77
78 Add this command to command list *LIST.
79
80 Returns a pointer to the added command (not necessarily the head
81 of *LIST). */
82
83struct cmd_list_element *
84add_cmd (name, class, fun, doc, list)
85 char *name;
86 enum command_class class;
507f3c78 87 void (*fun) (char *, int);
c906108c
SS
88 char *doc;
89 struct cmd_list_element **list;
90{
91 register struct cmd_list_element *c
c5aa993b 92 = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
c906108c
SS
93 struct cmd_list_element *p;
94
95 delete_cmd (name, list);
96
97 if (*list == NULL || STRCMP ((*list)->name, name) >= 0)
98 {
99 c->next = *list;
100 *list = c;
101 }
102 else
103 {
104 p = *list;
105 while (p->next && STRCMP (p->next->name, name) <= 0)
c5aa993b
JM
106 {
107 p = p->next;
108 }
c906108c
SS
109 c->next = p->next;
110 p->next = c;
111 }
112
113 c->name = name;
114 c->class = class;
115 c->function.cfunc = fun;
116 c->doc = doc;
56382845
FN
117 c->flags = 0;
118 c->replacement = NULL;
c906108c
SS
119 c->hook = NULL;
120 c->prefixlist = NULL;
121 c->prefixname = NULL;
122 c->allow_unknown = 0;
123 c->abbrev_flag = 0;
124 c->completer = make_symbol_completion_list;
125 c->type = not_set_cmd;
126 c->var = NULL;
127 c->var_type = var_boolean;
128 c->enums = NULL;
129 c->user_commands = NULL;
130 c->hookee = NULL;
131 c->cmd_pointer = NULL;
132
133 return c;
134}
135
56382845
FN
136
137/* Deprecates a command CMD.
138 REPLACEMENT is the name of the command which should be used in place
139 of this command, or NULL if no such command exists.
140
141 This function does not check to see if command REPLACEMENT exists
142 since gdb may not have gotten around to adding REPLACEMENT when this
143 function is called.
144
145 Returns a pointer to the deprecated command. */
146
147struct cmd_list_element *
148deprecate_cmd (cmd, replacement)
149 struct cmd_list_element *cmd;
150 char *replacement;
151{
152 cmd->flags |= (CMD_DEPRECATED | DEPRECATED_WARN_USER);
153
154 if (replacement != NULL)
155 cmd->replacement = replacement;
156 else
157 cmd->replacement = NULL;
158
159 return cmd;
160}
161
162
c906108c
SS
163/* Same as above, except that the abbrev_flag is set. */
164
c5aa993b 165#if 0 /* Currently unused */
c906108c
SS
166
167struct cmd_list_element *
168add_abbrev_cmd (name, class, fun, doc, list)
169 char *name;
170 enum command_class class;
507f3c78 171 void (*fun) (char *, int);
c906108c
SS
172 char *doc;
173 struct cmd_list_element **list;
174{
175 register struct cmd_list_element *c
c5aa993b 176 = add_cmd (name, class, fun, doc, list);
c906108c
SS
177
178 c->abbrev_flag = 1;
179 return c;
180}
181
182#endif
183
184struct cmd_list_element *
185add_alias_cmd (name, oldname, class, abbrev_flag, list)
186 char *name;
187 char *oldname;
188 enum command_class class;
189 int abbrev_flag;
190 struct cmd_list_element **list;
191{
192 /* Must do this since lookup_cmd tries to side-effect its first arg */
193 char *copied_name;
194 register struct cmd_list_element *old;
195 register struct cmd_list_element *c;
196 copied_name = (char *) alloca (strlen (oldname) + 1);
197 strcpy (copied_name, oldname);
c5aa993b 198 old = lookup_cmd (&copied_name, *list, "", 1, 1);
c906108c
SS
199
200 if (old == 0)
201 {
202 delete_cmd (name, list);
203 return 0;
204 }
205
206 c = add_cmd (name, class, old->function.cfunc, old->doc, list);
207 c->prefixlist = old->prefixlist;
208 c->prefixname = old->prefixname;
209 c->allow_unknown = old->allow_unknown;
210 c->abbrev_flag = abbrev_flag;
211 c->cmd_pointer = old;
212 return c;
213}
214
215/* Like add_cmd but adds an element for a command prefix:
216 a name that should be followed by a subcommand to be looked up
217 in another command list. PREFIXLIST should be the address
218 of the variable containing that list. */
219
220struct cmd_list_element *
221add_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
222 allow_unknown, list)
223 char *name;
224 enum command_class class;
507f3c78 225 void (*fun) (char *, int);
c906108c
SS
226 char *doc;
227 struct cmd_list_element **prefixlist;
228 char *prefixname;
229 int allow_unknown;
230 struct cmd_list_element **list;
231{
232 register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
233 c->prefixlist = prefixlist;
234 c->prefixname = prefixname;
235 c->allow_unknown = allow_unknown;
236 return c;
237}
238
239/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
c5aa993b 240
c906108c
SS
241struct cmd_list_element *
242add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
243 allow_unknown, list)
244 char *name;
245 enum command_class class;
507f3c78 246 void (*fun) (char *, int);
c906108c
SS
247 char *doc;
248 struct cmd_list_element **prefixlist;
249 char *prefixname;
250 int allow_unknown;
251 struct cmd_list_element **list;
252{
253 register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
254 c->prefixlist = prefixlist;
255 c->prefixname = prefixname;
256 c->allow_unknown = allow_unknown;
257 c->abbrev_flag = 1;
258 return c;
259}
260
261/* This is an empty "cfunc". */
262void
263not_just_help_class_command (args, from_tty)
264 char *args;
265 int from_tty;
266{
267}
268
269/* This is an empty "sfunc". */
a14ed312 270static void empty_sfunc (char *, int, struct cmd_list_element *);
c906108c
SS
271
272static void
273empty_sfunc (args, from_tty, c)
274 char *args;
275 int from_tty;
276 struct cmd_list_element *c;
277{
278}
279
280/* Add element named NAME to command list LIST (the list for set
281 or some sublist thereof).
282 CLASS is as in add_cmd.
283 VAR_TYPE is the kind of thing we are setting.
284 VAR is address of the variable being controlled by this command.
285 DOC is the documentation string. */
286
287struct cmd_list_element *
1ed2a135
AC
288add_set_cmd (char *name,
289 enum command_class class,
290 var_types var_type,
291 void *var,
292 char *doc,
293 struct cmd_list_element **list)
c906108c
SS
294{
295 struct cmd_list_element *c
c5aa993b 296 = add_cmd (name, class, NO_FUNCTION, doc, list);
c906108c
SS
297
298 c->type = set_cmd;
299 c->var_type = var_type;
300 c->var = var;
301 /* This needs to be something besides NO_FUNCTION so that this isn't
302 treated as a help class. */
303 c->function.sfunc = empty_sfunc;
304 return c;
305}
306
307/* Add element named NAME to command list LIST (the list for set
308 or some sublist thereof).
309 CLASS is as in add_cmd.
310 ENUMLIST is a list of strings which may follow NAME.
311 VAR is address of the variable which will contain the matching string
c5aa993b 312 (from ENUMLIST).
c906108c
SS
313 DOC is the documentation string. */
314
315struct cmd_list_element *
1ed2a135
AC
316add_set_enum_cmd (char *name,
317 enum command_class class,
53904c9e
AC
318 const char *enumlist[],
319 const char **var,
1ed2a135
AC
320 char *doc,
321 struct cmd_list_element **list)
c906108c
SS
322{
323 struct cmd_list_element *c
c5aa993b 324 = add_set_cmd (name, class, var_enum, var, doc, list);
c906108c
SS
325 c->enums = enumlist;
326
327 return c;
328}
329
97c3646f
AC
330/* Add element named NAME to command list LIST (the list for set
331 or some sublist thereof).
332 CLASS is as in add_cmd.
333 VAR is address of the variable which will contain the value.
334 DOC is the documentation string. */
335struct cmd_list_element *
336add_set_auto_boolean_cmd (char *name,
337 enum command_class class,
338 enum cmd_auto_boolean *var,
339 char *doc,
340 struct cmd_list_element **list)
341{
342 static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL };
343 struct cmd_list_element *c;
344 c = add_set_cmd (name, class, var_auto_boolean, var, doc, list);
345 c->enums = auto_boolean_enums;
346 return c;
347}
348
c906108c
SS
349/* Where SETCMD has already been added, add the corresponding show
350 command to LIST and return a pointer to the added command (not
351 necessarily the head of LIST). */
352struct cmd_list_element *
353add_show_from_set (setcmd, list)
354 struct cmd_list_element *setcmd;
355 struct cmd_list_element **list;
356{
357 struct cmd_list_element *showcmd =
c5aa993b 358 (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
c906108c
SS
359 struct cmd_list_element *p;
360
361 memcpy (showcmd, setcmd, sizeof (struct cmd_list_element));
362 delete_cmd (showcmd->name, list);
363 showcmd->type = show_cmd;
c5aa993b 364
c906108c
SS
365 /* Replace "set " at start of docstring with "show ". */
366 if (setcmd->doc[0] == 'S' && setcmd->doc[1] == 'e'
367 && setcmd->doc[2] == 't' && setcmd->doc[3] == ' ')
368 showcmd->doc = concat ("Show ", setcmd->doc + 4, NULL);
369 else
370 fprintf_unfiltered (gdb_stderr, "GDB internal error: Bad docstring for set command\n");
c5aa993b
JM
371
372 if (*list == NULL || STRCMP ((*list)->name, showcmd->name) >= 0)
c906108c
SS
373 {
374 showcmd->next = *list;
375 *list = showcmd;
376 }
377 else
378 {
379 p = *list;
380 while (p->next && STRCMP (p->next->name, showcmd->name) <= 0)
c5aa993b
JM
381 {
382 p = p->next;
383 }
c906108c
SS
384 showcmd->next = p->next;
385 p->next = showcmd;
386 }
387
388 return showcmd;
389}
390
391/* Remove the command named NAME from the command list. */
392
393void
394delete_cmd (name, list)
395 char *name;
396 struct cmd_list_element **list;
397{
398 register struct cmd_list_element *c;
399 struct cmd_list_element *p;
400
401 while (*list && STREQ ((*list)->name, name))
402 {
403 if ((*list)->hookee)
404 (*list)->hookee->hook = 0; /* Hook slips out of its mouth */
405 p = (*list)->next;
c5aa993b 406 free ((PTR) * list);
c906108c
SS
407 *list = p;
408 }
409
410 if (*list)
411 for (c = *list; c->next;)
412 {
413 if (STREQ (c->next->name, name))
414 {
415 if (c->next->hookee)
c5aa993b 416 c->next->hookee->hook = 0; /* hooked cmd gets away. */
c906108c 417 p = c->next->next;
c5aa993b 418 free ((PTR) c->next);
c906108c
SS
419 c->next = p;
420 }
421 else
422 c = c->next;
423 }
424}
6837a0a2
DB
425/* Recursively walk the commandlist structures, and print out the
426 documentation of commands that match our regex in either their
427 name, or their documentation.
428*/
429static void
430apropos_cmd_helper (struct ui_file *stream, struct cmd_list_element *commandlist,
431 struct re_pattern_buffer *regex, char *prefix)
432{
433 register struct cmd_list_element *c;
434 int returnvalue=1; /*Needed to avoid double printing*/
435 /* Walk through the commands */
436 for (c=commandlist;c;c=c->next)
437 {
438 if (c->name != NULL)
439 {
440 /* Try to match against the name*/
441 returnvalue=re_search(regex,c->name,strlen(c->name),0,strlen(c->name),NULL);
442 if (returnvalue >= 0)
443 {
444 /* Stolen from help_cmd_list. We don't directly use
445 * help_cmd_list because it doesn't let us print out
446 * single commands
447 */
448 fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
449 print_doc_line (stream, c->doc);
450 fputs_filtered ("\n", stream);
451 returnvalue=0; /*Set this so we don't print it again.*/
452 }
453 }
454 if (c->doc != NULL && returnvalue != 0)
455 {
456 /* Try to match against documentation */
457 if (re_search(regex,c->doc,strlen(c->doc),0,strlen(c->doc),NULL) >=0)
458 {
459 /* Stolen from help_cmd_list. We don't directly use
460 * help_cmd_list because it doesn't let us print out
461 * single commands
462 */
463 fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
464 print_doc_line (stream, c->doc);
465 fputs_filtered ("\n", stream);
466 }
467 }
468 /* Check if this command has subcommands */
469 if (c->prefixlist != NULL)
470 {
471 /* Recursively call ourselves on the subcommand list,
472 passing the right prefix in.
473 */
474 apropos_cmd_helper(stream,*c->prefixlist,regex,c->prefixname);
475 }
476 }
477}
478/* Search through names of commands and documentations for a certain
479 regular expression.
480*/
481void
482apropos_command (char *searchstr, int from_tty)
483{
484 extern struct cmd_list_element *cmdlist; /*This is the main command list*/
485 regex_t pattern;
486 char *pattern_fastmap;
487 char errorbuffer[512];
488 pattern_fastmap=calloc(256,sizeof(char));
489 if (searchstr == NULL)
490 error("REGEXP string is empty");
491
492 if (regcomp(&pattern,searchstr,REG_ICASE) == 0)
493 {
494 pattern.fastmap=pattern_fastmap;
495 re_compile_fastmap(&pattern);
496 apropos_cmd_helper(gdb_stdout,cmdlist,&pattern,"");
497 }
498 else
499 {
500 regerror(regcomp(&pattern,searchstr,REG_ICASE),NULL,errorbuffer,512);
501 error("Error in regular expression:%s",errorbuffer);
502 }
503 free(pattern_fastmap);
504}
505
c906108c
SS
506
507/* This command really has to deal with two things:
508 * 1) I want documentation on *this string* (usually called by
509 * "help commandname").
510 * 2) I want documentation on *this list* (usually called by
511 * giving a command that requires subcommands. Also called by saying
512 * just "help".)
513 *
514 * I am going to split this into two seperate comamnds, help_cmd and
515 * help_list.
516 */
517
518void
519help_cmd (command, stream)
520 char *command;
d9fcf2fb 521 struct ui_file *stream;
c906108c
SS
522{
523 struct cmd_list_element *c;
524 extern struct cmd_list_element *cmdlist;
525
526 if (!command)
527 {
528 help_list (cmdlist, "", all_classes, stream);
529 return;
530 }
531
49a5a3a3
GM
532 if (strcmp (command, "all") == 0)
533 {
534 help_all (stream);
535 return;
536 }
537
c906108c
SS
538 c = lookup_cmd (&command, cmdlist, "", 0, 0);
539
540 if (c == 0)
541 return;
542
543 /* There are three cases here.
544 If c->prefixlist is nonzero, we have a prefix command.
545 Print its documentation, then list its subcommands.
c5aa993b 546
c906108c
SS
547 If c->function is nonzero, we really have a command.
548 Print its documentation and return.
c5aa993b 549
c906108c
SS
550 If c->function is zero, we have a class name.
551 Print its documentation (as if it were a command)
552 and then set class to the number of this class
553 so that the commands in the class will be listed. */
554
555 fputs_filtered (c->doc, stream);
556 fputs_filtered ("\n", stream);
557
558 if (c->prefixlist == 0 && c->function.cfunc != NULL)
559 return;
560 fprintf_filtered (stream, "\n");
561
562 /* If this is a prefix command, print it's subcommands */
563 if (c->prefixlist)
564 help_list (*c->prefixlist, c->prefixname, all_commands, stream);
565
566 /* If this is a class name, print all of the commands in the class */
567 if (c->function.cfunc == NULL)
568 help_list (cmdlist, "", c->class, stream);
569
570 if (c->hook)
571 fprintf_filtered (stream, "\nThis command has a hook defined: %s\n",
572 c->hook->name);
573}
574
575/*
576 * Get a specific kind of help on a command list.
577 *
578 * LIST is the list.
579 * CMDTYPE is the prefix to use in the title string.
580 * CLASS is the class with which to list the nodes of this list (see
581 * documentation for help_cmd_list below), As usual, ALL_COMMANDS for
582 * everything, ALL_CLASSES for just classes, and non-negative for only things
583 * in a specific class.
584 * and STREAM is the output stream on which to print things.
585 * If you call this routine with a class >= 0, it recurses.
586 */
587void
588help_list (list, cmdtype, class, stream)
589 struct cmd_list_element *list;
590 char *cmdtype;
591 enum command_class class;
d9fcf2fb 592 struct ui_file *stream;
c906108c
SS
593{
594 int len;
595 char *cmdtype1, *cmdtype2;
c5aa993b 596
c906108c
SS
597 /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */
598 len = strlen (cmdtype);
599 cmdtype1 = (char *) alloca (len + 1);
600 cmdtype1[0] = 0;
601 cmdtype2 = (char *) alloca (len + 4);
602 cmdtype2[0] = 0;
603 if (len)
604 {
605 cmdtype1[0] = ' ';
606 strncpy (cmdtype1 + 1, cmdtype, len - 1);
607 cmdtype1[len] = 0;
608 strncpy (cmdtype2, cmdtype, len - 1);
609 strcpy (cmdtype2 + len - 1, " sub");
610 }
611
612 if (class == all_classes)
613 fprintf_filtered (stream, "List of classes of %scommands:\n\n", cmdtype2);
614 else
615 fprintf_filtered (stream, "List of %scommands:\n\n", cmdtype2);
616
c5aa993b 617 help_cmd_list (list, class, cmdtype, (int) class >= 0, stream);
c906108c
SS
618
619 if (class == all_classes)
620 fprintf_filtered (stream, "\n\
621Type \"help%s\" followed by a class name for a list of commands in that class.",
c5aa993b 622 cmdtype1);
c906108c
SS
623
624 fprintf_filtered (stream, "\n\
625Type \"help%s\" followed by %scommand name for full documentation.\n\
626Command name abbreviations are allowed if unambiguous.\n",
c5aa993b 627 cmdtype1, cmdtype2);
c906108c 628}
c5aa993b 629
49a5a3a3 630static void
c85871a3 631help_all (struct ui_file *stream)
49a5a3a3
GM
632{
633 struct cmd_list_element *c;
634 extern struct cmd_list_element *cmdlist;
635
636 for (c = cmdlist; c; c = c->next)
637 {
638 if (c->abbrev_flag)
639 continue;
640 /* If this is a prefix command, print it's subcommands */
641 if (c->prefixlist)
642 help_cmd_list (*c->prefixlist, all_commands, c->prefixname, 0, stream);
643
644 /* If this is a class name, print all of the commands in the class */
645 else if (c->function.cfunc == NULL)
646 help_cmd_list (cmdlist, c->class, "", 0, stream);
647 }
648}
649
c906108c
SS
650/* Print only the first line of STR on STREAM. */
651static void
652print_doc_line (stream, str)
d9fcf2fb 653 struct ui_file *stream;
c906108c
SS
654 char *str;
655{
656 static char *line_buffer = 0;
657 static int line_size;
658 register char *p;
659
660 if (!line_buffer)
661 {
662 line_size = 80;
663 line_buffer = (char *) xmalloc (line_size);
664 }
665
666 p = str;
667 while (*p && *p != '\n' && *p != '.' && *p != ',')
668 p++;
669 if (p - str > line_size - 1)
670 {
671 line_size = p - str + 1;
c5aa993b 672 free ((PTR) line_buffer);
c906108c
SS
673 line_buffer = (char *) xmalloc (line_size);
674 }
675 strncpy (line_buffer, str, p - str);
676 line_buffer[p - str] = '\0';
677 if (islower (line_buffer[0]))
678 line_buffer[0] = toupper (line_buffer[0]);
8b93c638
JM
679#ifdef UI_OUT
680 ui_out_text (uiout, line_buffer);
681#else
c906108c 682 fputs_filtered (line_buffer, stream);
8b93c638 683#endif
c906108c
SS
684}
685
686/*
687 * Implement a help command on command list LIST.
688 * RECURSE should be non-zero if this should be done recursively on
689 * all sublists of LIST.
690 * PREFIX is the prefix to print before each command name.
691 * STREAM is the stream upon which the output should be written.
692 * CLASS should be:
c5aa993b 693 * A non-negative class number to list only commands in that
c906108c 694 * class.
c5aa993b
JM
695 * ALL_COMMANDS to list all commands in list.
696 * ALL_CLASSES to list all classes in list.
c906108c
SS
697 *
698 * Note that RECURSE will be active on *all* sublists, not just the
699 * ones selected by the criteria above (ie. the selection mechanism
700 * is at the low level, not the high-level).
701 */
702void
703help_cmd_list (list, class, prefix, recurse, stream)
704 struct cmd_list_element *list;
705 enum command_class class;
706 char *prefix;
707 int recurse;
d9fcf2fb 708 struct ui_file *stream;
c906108c
SS
709{
710 register struct cmd_list_element *c;
711
712 for (c = list; c; c = c->next)
713 {
714 if (c->abbrev_flag == 0 &&
715 (class == all_commands
c5aa993b
JM
716 || (class == all_classes && c->function.cfunc == NULL)
717 || (class == c->class && c->function.cfunc != NULL)))
c906108c
SS
718 {
719 fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
720 print_doc_line (stream, c->doc);
721 fputs_filtered ("\n", stream);
722 }
723 if (recurse
724 && c->prefixlist != 0
725 && c->abbrev_flag == 0)
726 help_cmd_list (*c->prefixlist, class, c->prefixname, 1, stream);
727 }
728}
c906108c 729\f
c5aa993b 730
c906108c
SS
731/* Search the input clist for 'command'. Return the command if
732 found (or NULL if not), and return the number of commands
733 found in nfound */
734
735static struct cmd_list_element *
c5aa993b 736find_cmd (command, len, clist, ignore_help_classes, nfound)
c906108c 737 char *command;
392a587b 738 int len;
c906108c
SS
739 struct cmd_list_element *clist;
740 int ignore_help_classes;
741 int *nfound;
742{
743 struct cmd_list_element *found, *c;
744
c5aa993b 745 found = (struct cmd_list_element *) NULL;
c906108c
SS
746 *nfound = 0;
747 for (c = clist; c; c = c->next)
748 if (!strncmp (command, c->name, len)
c5aa993b 749 && (!ignore_help_classes || c->function.cfunc))
c906108c 750 {
c5aa993b
JM
751 found = c;
752 (*nfound)++;
753 if (c->name[len] == '\0')
754 {
755 *nfound = 1;
756 break;
757 }
c906108c
SS
758 }
759 return found;
760}
761
762/* This routine takes a line of TEXT and a CLIST in which to start the
763 lookup. When it returns it will have incremented the text pointer past
764 the section of text it matched, set *RESULT_LIST to point to the list in
765 which the last word was matched, and will return a pointer to the cmd
766 list element which the text matches. It will return NULL if no match at
767 all was possible. It will return -1 (cast appropriately, ick) if ambigous
768 matches are possible; in this case *RESULT_LIST will be set to point to
769 the list in which there are ambiguous choices (and *TEXT will be set to
770 the ambiguous text string).
771
772 If the located command was an abbreviation, this routine returns the base
773 command of the abbreviation.
774
775 It does no error reporting whatsoever; control will always return
776 to the superior routine.
777
778 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
779 at the prefix_command (ie. the best match) *or* (special case) will be NULL
780 if no prefix command was ever found. For example, in the case of "info a",
781 "info" matches without ambiguity, but "a" could be "args" or "address", so
782 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
783 RESULT_LIST should not be interpeted as a pointer to the beginning of a
784 list; it simply points to a specific command. In the case of an ambiguous
785 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
786 "info t" can be "info types" or "info target"; upon return *TEXT has been
787 advanced past "info ").
788
789 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
790 affect the operation).
791
792 This routine does *not* modify the text pointed to by TEXT.
c5aa993b 793
c906108c
SS
794 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
795 are actually help classes rather than commands (i.e. the function field of
796 the struct cmd_list_element is NULL). */
797
798struct cmd_list_element *
799lookup_cmd_1 (text, clist, result_list, ignore_help_classes)
800 char **text;
801 struct cmd_list_element *clist, **result_list;
802 int ignore_help_classes;
803{
804 char *p, *command;
805 int len, tmp, nfound;
806 struct cmd_list_element *found, *c;
56382845 807 char *line = *text;
c906108c
SS
808
809 while (**text == ' ' || **text == '\t')
810 (*text)++;
811
812 /* Treating underscores as part of command words is important
813 so that "set args_foo()" doesn't get interpreted as
814 "set args _foo()". */
815 for (p = *text;
c5aa993b 816 *p && (isalnum (*p) || *p == '-' || *p == '_' ||
c906108c
SS
817 (tui_version &&
818 (*p == '+' || *p == '<' || *p == '>' || *p == '$')) ||
819 (xdb_commands && (*p == '!' || *p == '/' || *p == '?')));
820 p++)
821 ;
822
823 /* If nothing but whitespace, return 0. */
824 if (p == *text)
825 return 0;
c5aa993b 826
c906108c
SS
827 len = p - *text;
828
829 /* *text and p now bracket the first command word to lookup (and
830 it's length is len). We copy this into a local temporary */
831
832
833 command = (char *) alloca (len + 1);
834 for (tmp = 0; tmp < len; tmp++)
835 {
836 char x = (*text)[tmp];
837 command[tmp] = x;
838 }
839 command[len] = '\0';
840
841 /* Look it up. */
842 found = 0;
843 nfound = 0;
c5aa993b 844 found = find_cmd (command, len, clist, ignore_help_classes, &nfound);
c906108c
SS
845
846 /*
c5aa993b
JM
847 ** We didn't find the command in the entered case, so lower case it
848 ** and search again.
849 */
c906108c
SS
850 if (!found || nfound == 0)
851 {
852 for (tmp = 0; tmp < len; tmp++)
c5aa993b
JM
853 {
854 char x = command[tmp];
855 command[tmp] = isupper (x) ? tolower (x) : x;
856 }
857 found = find_cmd (command, len, clist, ignore_help_classes, &nfound);
c906108c
SS
858 }
859
860 /* If nothing matches, we have a simple failure. */
861 if (nfound == 0)
862 return 0;
863
864 if (nfound > 1)
865 {
866 if (result_list != NULL)
867 /* Will be modified in calling routine
868 if we know what the prefix command is. */
c5aa993b
JM
869 *result_list = 0;
870 return (struct cmd_list_element *) -1; /* Ambiguous. */
c906108c
SS
871 }
872
873 /* We've matched something on this list. Move text pointer forward. */
874
875 *text = p;
876
c906108c 877 if (found->cmd_pointer)
56382845
FN
878 {
879 /* We drop the alias (abbreviation) in favor of the command it is
880 pointing to. If the alias is deprecated, though, we need to
881 warn the user about it before we drop it. Note that while we
882 are warning about the alias, we may also warn about the command
883 itself and we will adjust the appropriate DEPRECATED_WARN_USER
884 flags */
885
886 if (found->flags & DEPRECATED_WARN_USER)
887 deprecated_cmd_warning (&line);
888 found = found->cmd_pointer;
889 }
c906108c
SS
890 /* If we found a prefix command, keep looking. */
891
892 if (found->prefixlist)
893 {
894 c = lookup_cmd_1 (text, *found->prefixlist, result_list,
895 ignore_help_classes);
896 if (!c)
897 {
898 /* Didn't find anything; this is as far as we got. */
899 if (result_list != NULL)
900 *result_list = clist;
901 return found;
902 }
903 else if (c == (struct cmd_list_element *) -1)
904 {
905 /* We've gotten this far properly, but the next step
906 is ambiguous. We need to set the result list to the best
907 we've found (if an inferior hasn't already set it). */
908 if (result_list != NULL)
909 if (!*result_list)
910 /* This used to say *result_list = *found->prefixlist
c5aa993b
JM
911 If that was correct, need to modify the documentation
912 at the top of this function to clarify what is supposed
913 to be going on. */
c906108c
SS
914 *result_list = found;
915 return c;
916 }
917 else
918 {
919 /* We matched! */
920 return c;
921 }
922 }
923 else
924 {
925 if (result_list != NULL)
926 *result_list = clist;
927 return found;
928 }
929}
930
931/* All this hair to move the space to the front of cmdtype */
932
933static void
934undef_cmd_error (cmdtype, q)
935 char *cmdtype, *q;
936{
937 error ("Undefined %scommand: \"%s\". Try \"help%s%.*s\".",
c5aa993b
JM
938 cmdtype,
939 q,
940 *cmdtype ? " " : "",
941 strlen (cmdtype) - 1,
942 cmdtype);
c906108c
SS
943}
944
945/* Look up the contents of *LINE as a command in the command list LIST.
946 LIST is a chain of struct cmd_list_element's.
947 If it is found, return the struct cmd_list_element for that command
948 and update *LINE to point after the command name, at the first argument.
949 If not found, call error if ALLOW_UNKNOWN is zero
950 otherwise (or if error returns) return zero.
951 Call error if specified command is ambiguous,
952 unless ALLOW_UNKNOWN is negative.
953 CMDTYPE precedes the word "command" in the error message.
954
955 If INGNORE_HELP_CLASSES is nonzero, ignore any command list
956 elements which are actually help classes rather than commands (i.e.
957 the function field of the struct cmd_list_element is 0). */
958
959struct cmd_list_element *
960lookup_cmd (line, list, cmdtype, allow_unknown, ignore_help_classes)
961 char **line;
962 struct cmd_list_element *list;
963 char *cmdtype;
964 int allow_unknown;
965 int ignore_help_classes;
966{
967 struct cmd_list_element *last_list = 0;
968 struct cmd_list_element *c =
c5aa993b 969 lookup_cmd_1 (line, list, &last_list, ignore_help_classes);
c906108c
SS
970#if 0
971 /* This is wrong for complete_command. */
972 char *ptr = (*line) + strlen (*line) - 1;
973
974 /* Clear off trailing whitespace. */
975 while (ptr >= *line && (*ptr == ' ' || *ptr == '\t'))
976 ptr--;
977 *(ptr + 1) = '\0';
978#endif
c5aa993b 979
c906108c
SS
980 if (!c)
981 {
982 if (!allow_unknown)
983 {
984 if (!*line)
985 error ("Lack of needed %scommand", cmdtype);
986 else
987 {
988 char *p = *line, *q;
989
c5aa993b 990 while (isalnum (*p) || *p == '-')
c906108c
SS
991 p++;
992
993 q = (char *) alloca (p - *line + 1);
994 strncpy (q, *line, p - *line);
995 q[p - *line] = '\0';
996 undef_cmd_error (cmdtype, q);
997 }
998 }
999 else
1000 return 0;
1001 }
1002 else if (c == (struct cmd_list_element *) -1)
1003 {
1004 /* Ambigous. Local values should be off prefixlist or called
c5aa993b 1005 values. */
c906108c
SS
1006 int local_allow_unknown = (last_list ? last_list->allow_unknown :
1007 allow_unknown);
1008 char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
1009 struct cmd_list_element *local_list =
c5aa993b
JM
1010 (last_list ? *(last_list->prefixlist) : list);
1011
c906108c
SS
1012 if (local_allow_unknown < 0)
1013 {
1014 if (last_list)
1015 return last_list; /* Found something. */
1016 else
1017 return 0; /* Found nothing. */
1018 }
1019 else
1020 {
1021 /* Report as error. */
1022 int amb_len;
1023 char ambbuf[100];
1024
1025 for (amb_len = 0;
1026 ((*line)[amb_len] && (*line)[amb_len] != ' '
1027 && (*line)[amb_len] != '\t');
1028 amb_len++)
1029 ;
c5aa993b 1030
c906108c
SS
1031 ambbuf[0] = 0;
1032 for (c = local_list; c; c = c->next)
1033 if (!strncmp (*line, c->name, amb_len))
1034 {
c5aa993b 1035 if (strlen (ambbuf) + strlen (c->name) + 6 < (int) sizeof ambbuf)
c906108c
SS
1036 {
1037 if (strlen (ambbuf))
1038 strcat (ambbuf, ", ");
1039 strcat (ambbuf, c->name);
1040 }
1041 else
1042 {
1043 strcat (ambbuf, "..");
1044 break;
1045 }
1046 }
1047 error ("Ambiguous %scommand \"%s\": %s.", local_cmdtype,
1048 *line, ambbuf);
1049 return 0; /* lint */
1050 }
1051 }
1052 else
1053 {
1054 /* We've got something. It may still not be what the caller
1055 wants (if this command *needs* a subcommand). */
1056 while (**line == ' ' || **line == '\t')
1057 (*line)++;
1058
1059 if (c->prefixlist && **line && !c->allow_unknown)
1060 undef_cmd_error (c->prefixname, *line);
1061
1062 /* Seems to be what he wants. Return it. */
1063 return c;
1064 }
1065 return 0;
1066}
c5aa993b 1067
56382845
FN
1068/* We are here presumably because an alias or command in *TEXT is
1069 deprecated and a warning message should be generated. This function
1070 decodes *TEXT and potentially generates a warning message as outlined
1071 below.
1072
1073 Example for 'set endian big' which has a fictitious alias 'seb'.
1074
1075 If alias wasn't used in *TEXT, and the command is deprecated:
1076 "warning: 'set endian big' is deprecated."
1077
1078 If alias was used, and only the alias is deprecated:
1079 "warning: 'seb' an alias for the command 'set endian big' is deprecated."
1080
1081 If alias was used and command is deprecated (regardless of whether the
1082 alias itself is deprecated:
1083
1084 "warning: 'set endian big' (seb) is deprecated."
1085
1086 After the message has been sent, clear the appropriate flags in the
1087 command and/or the alias so the user is no longer bothered.
1088
1089*/
1090void
1091deprecated_cmd_warning (char **text)
1092{
1093 struct cmd_list_element *alias = NULL;
1094 struct cmd_list_element *prefix_cmd = NULL;
1095 struct cmd_list_element *cmd = NULL;
1096 struct cmd_list_element *c;
1097 char *type;
1098
1099 if (!lookup_cmd_composition (*text, &alias, &prefix_cmd, &cmd))
1100 /* return if text doesn't evaluate to a command */
1101 return;
1102
1103 if (!((alias ? (alias->flags & DEPRECATED_WARN_USER) : 0)
1104 || (cmd->flags & DEPRECATED_WARN_USER) ) )
1105 /* return if nothing is deprecated */
1106 return;
1107
1108 printf_filtered ("Warning:");
1109
1110 if (alias && !(cmd->flags & CMD_DEPRECATED))
1111 printf_filtered (" '%s', an alias for the", alias->name);
1112
1113 printf_filtered (" command '");
1114
1115 if (prefix_cmd)
1116 printf_filtered ("%s", prefix_cmd->prefixname);
1117
1118 printf_filtered ("%s", cmd->name);
1119
1120 if (alias && (cmd->flags & CMD_DEPRECATED))
1121 printf_filtered ("' (%s) is deprecated.\n", alias->name);
1122 else
1123 printf_filtered ("' is deprecated.\n");
1124
1125
1126 /* if it is only the alias that is deprecated, we want to indicate the
1127 new alias, otherwise we'll indicate the new command */
1128
1129 if (alias && !(cmd->flags & CMD_DEPRECATED))
1130 {
1131 if (alias->replacement)
1132 printf_filtered ("Use '%s'.\n\n", alias->replacement);
1133 else
1134 printf_filtered ("No alternative known.\n\n");
1135 }
1136 else
1137 {
1138 if (cmd->replacement)
1139 printf_filtered ("Use '%s'.\n\n", cmd->replacement);
1140 else
1141 printf_filtered ("No alternative known.\n\n");
1142 }
1143
1144 /* We've warned you, now we'll keep quiet */
1145 if (alias)
1146 alias->flags &= ~DEPRECATED_WARN_USER;
1147
1148 cmd->flags &= ~DEPRECATED_WARN_USER;
1149}
1150
1151
1152
1153/* Look up the contents of LINE as a command in the command list 'cmdlist'.
1154 Return 1 on success, 0 on failure.
1155
1156 If LINE refers to an alias, *alias will point to that alias.
1157
1158 If LINE is a postfix command (i.e. one that is preceeded by a prefix
1159 command) set *prefix_cmd.
1160
1161 Set *cmd to point to the command LINE indicates.
1162
1163 If any of *alias, *prefix_cmd, or *cmd cannot be determined or do not
1164 exist, they are NULL when we return.
1165
1166*/
1167int
1168lookup_cmd_composition (char *text,
1169 struct cmd_list_element **alias,
1170 struct cmd_list_element **prefix_cmd,
1171 struct cmd_list_element **cmd)
1172{
1173 char *p, *command;
1174 int len, tmp, nfound;
1175 struct cmd_list_element *cur_list;
1176 struct cmd_list_element *prev_cmd;
1177 *alias = NULL;
1178 *prefix_cmd = NULL;
1179 *cmd = NULL;
1180
1181 cur_list = cmdlist;
1182
1183 while (1)
1184 {
1185 /* Go through as many command lists as we need to
1186 to find the command TEXT refers to. */
1187
1188 prev_cmd = *cmd;
1189
1190 while (*text == ' ' || *text == '\t')
1191 (text)++;
1192
1193 /* Treating underscores as part of command words is important
1194 so that "set args_foo()" doesn't get interpreted as
1195 "set args _foo()". */
1196 for (p = text;
1197 *p && (isalnum (*p) || *p == '-' || *p == '_' ||
1198 (tui_version &&
1199 (*p == '+' || *p == '<' || *p == '>' || *p == '$')) ||
1200 (xdb_commands && (*p == '!' || *p == '/' || *p == '?')));
1201 p++)
1202 ;
1203
1204 /* If nothing but whitespace, return. */
1205 if (p == text)
1206 return 0;
1207
1208 len = p - text;
1209
1210 /* text and p now bracket the first command word to lookup (and
1211 it's length is len). We copy this into a local temporary */
1212
1213 command = (char *) alloca (len + 1);
1214 for (tmp = 0; tmp < len; tmp++)
1215 {
1216 char x = text[tmp];
1217 command[tmp] = x;
1218 }
1219 command[len] = '\0';
1220
1221 /* Look it up. */
1222 *cmd = 0;
1223 nfound = 0;
1224 *cmd = find_cmd (command, len, cur_list, 1, &nfound);
1225
1226 /* We didn't find the command in the entered case, so lower case it
1227 and search again.
1228 */
1229 if (!*cmd || nfound == 0)
1230 {
1231 for (tmp = 0; tmp < len; tmp++)
1232 {
1233 char x = command[tmp];
1234 command[tmp] = isupper (x) ? tolower (x) : x;
1235 }
1236 *cmd = find_cmd (command, len, cur_list, 1, &nfound);
1237 }
1238
1239 if (*cmd == (struct cmd_list_element *) -1)
1240 {
1241 return 0; /* ambiguous */
1242 }
1243
1244 if (*cmd == NULL)
1245 return 0; /* nothing found */
1246 else
1247 {
1248 if ((*cmd)->cmd_pointer)
1249 {
1250 /* cmd was actually an alias, we note that an alias was used
1251 (by assigning *alais) and we set *cmd.
1252 */
1253 *alias = *cmd;
1254 *cmd = (*cmd)->cmd_pointer;
1255 }
1256 *prefix_cmd = prev_cmd;
1257 }
1258 if ((*cmd)->prefixlist)
1259 cur_list = *(*cmd)->prefixlist;
1260 else
1261 return 1;
1262
1263 text = p;
1264 }
1265}
1266
1267
1268
1269
c906108c
SS
1270#if 0
1271/* Look up the contents of *LINE as a command in the command list LIST.
1272 LIST is a chain of struct cmd_list_element's.
1273 If it is found, return the struct cmd_list_element for that command
1274 and update *LINE to point after the command name, at the first argument.
1275 If not found, call error if ALLOW_UNKNOWN is zero
1276 otherwise (or if error returns) return zero.
1277 Call error if specified command is ambiguous,
1278 unless ALLOW_UNKNOWN is negative.
1279 CMDTYPE precedes the word "command" in the error message. */
1280
1281struct cmd_list_element *
1282lookup_cmd (line, list, cmdtype, allow_unknown)
1283 char **line;
1284 struct cmd_list_element *list;
1285 char *cmdtype;
1286 int allow_unknown;
1287{
1288 register char *p;
1289 register struct cmd_list_element *c, *found;
1290 int nfound;
1291 char ambbuf[100];
1292 char *processed_cmd;
1293 int i, cmd_len;
1294
1295 /* Skip leading whitespace. */
1296
1297 while (**line == ' ' || **line == '\t')
1298 (*line)++;
1299
1300 /* Clear out trailing whitespace. */
1301
1302 p = *line + strlen (*line);
1303 while (p != *line && (p[-1] == ' ' || p[-1] == '\t'))
1304 p--;
1305 *p = 0;
1306
1307 /* Find end of command name. */
1308
1309 p = *line;
c5aa993b 1310 while (*p == '-' || isalnum (*p))
c906108c
SS
1311 p++;
1312
1313 /* Look up the command name.
1314 If exact match, keep that.
1315 Otherwise, take command abbreviated, if unique. Note that (in my
1316 opinion) a null string does *not* indicate ambiguity; simply the
1317 end of the argument. */
1318
1319 if (p == *line)
1320 {
1321 if (!allow_unknown)
1322 error ("Lack of needed %scommand", cmdtype);
1323 return 0;
1324 }
c5aa993b 1325
c906108c
SS
1326 /* Copy over to a local buffer, converting to lowercase on the way.
1327 This is in case the command being parsed is a subcommand which
1328 doesn't match anything, and that's ok. We want the original
1329 untouched for the routine of the original command. */
c5aa993b 1330
c906108c
SS
1331 processed_cmd = (char *) alloca (p - *line + 1);
1332 for (cmd_len = 0; cmd_len < p - *line; cmd_len++)
1333 {
1334 char x = (*line)[cmd_len];
c5aa993b
JM
1335 if (isupper (x))
1336 processed_cmd[cmd_len] = tolower (x);
c906108c
SS
1337 else
1338 processed_cmd[cmd_len] = x;
1339 }
1340 processed_cmd[cmd_len] = '\0';
1341
1342 /* Check all possibilities in the current command list. */
1343 found = 0;
1344 nfound = 0;
1345 for (c = list; c; c = c->next)
1346 {
1347 if (!strncmp (processed_cmd, c->name, cmd_len))
1348 {
1349 found = c;
1350 nfound++;
1351 if (c->name[cmd_len] == 0)
1352 {
1353 nfound = 1;
1354 break;
1355 }
1356 }
1357 }
1358
1359 /* Report error for undefined command name. */
1360
1361 if (nfound != 1)
1362 {
1363 if (nfound > 1 && allow_unknown >= 0)
1364 {
1365 ambbuf[0] = 0;
1366 for (c = list; c; c = c->next)
1367 if (!strncmp (processed_cmd, c->name, cmd_len))
1368 {
1369 if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf)
1370 {
1371 if (strlen (ambbuf))
1372 strcat (ambbuf, ", ");
1373 strcat (ambbuf, c->name);
1374 }
1375 else
1376 {
1377 strcat (ambbuf, "..");
1378 break;
1379 }
1380 }
1381 error ("Ambiguous %scommand \"%s\": %s.", cmdtype,
1382 processed_cmd, ambbuf);
1383 }
1384 else if (!allow_unknown)
1385 error ("Undefined %scommand: \"%s\".", cmdtype, processed_cmd);
1386 return 0;
1387 }
1388
1389 /* Skip whitespace before the argument. */
1390
c5aa993b
JM
1391 while (*p == ' ' || *p == '\t')
1392 p++;
c906108c
SS
1393 *line = p;
1394
1395 if (found->prefixlist && *p)
1396 {
1397 c = lookup_cmd (line, *found->prefixlist, found->prefixname,
1398 found->allow_unknown);
1399 if (c)
1400 return c;
1401 }
1402
1403 return found;
1404}
1405#endif
1406
1407/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
1408
1409/* Return a vector of char pointers which point to the different
1410 possible completions in LIST of TEXT.
1411
1412 WORD points in the same buffer as TEXT, and completions should be
1413 returned relative to this position. For example, suppose TEXT is "foo"
1414 and we want to complete to "foobar". If WORD is "oo", return
1415 "oobar"; if WORD is "baz/foo", return "baz/foobar". */
1416
1417char **
1418complete_on_cmdlist (list, text, word)
1419 struct cmd_list_element *list;
1420 char *text;
1421 char *word;
1422{
1423 struct cmd_list_element *ptr;
1424 char **matchlist;
1425 int sizeof_matchlist;
1426 int matches;
1427 int textlen = strlen (text);
1428
1429 sizeof_matchlist = 10;
1430 matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
1431 matches = 0;
1432
1433 for (ptr = list; ptr; ptr = ptr->next)
1434 if (!strncmp (ptr->name, text, textlen)
1435 && !ptr->abbrev_flag
1436 && (ptr->function.cfunc
1437 || ptr->prefixlist))
1438 {
1439 if (matches == sizeof_matchlist)
1440 {
1441 sizeof_matchlist *= 2;
c5aa993b 1442 matchlist = (char **) xrealloc ((char *) matchlist,
c906108c
SS
1443 (sizeof_matchlist
1444 * sizeof (char *)));
1445 }
1446
c5aa993b 1447 matchlist[matches] = (char *)
c906108c
SS
1448 xmalloc (strlen (word) + strlen (ptr->name) + 1);
1449 if (word == text)
1450 strcpy (matchlist[matches], ptr->name);
1451 else if (word > text)
1452 {
1453 /* Return some portion of ptr->name. */
1454 strcpy (matchlist[matches], ptr->name + (word - text));
1455 }
1456 else
1457 {
1458 /* Return some of text plus ptr->name. */
1459 strncpy (matchlist[matches], word, text - word);
1460 matchlist[matches][text - word] = '\0';
1461 strcat (matchlist[matches], ptr->name);
1462 }
1463 ++matches;
1464 }
1465
1466 if (matches == 0)
1467 {
c5aa993b 1468 free ((PTR) matchlist);
c906108c
SS
1469 matchlist = 0;
1470 }
1471 else
1472 {
c5aa993b
JM
1473 matchlist = (char **) xrealloc ((char *) matchlist, ((matches + 1)
1474 * sizeof (char *)));
c906108c
SS
1475 matchlist[matches] = (char *) 0;
1476 }
1477
1478 return matchlist;
1479}
1480
1481/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
1482
1483/* Return a vector of char pointers which point to the different
1484 possible completions in CMD of TEXT.
1485
1486 WORD points in the same buffer as TEXT, and completions should be
1487 returned relative to this position. For example, suppose TEXT is "foo"
1488 and we want to complete to "foobar". If WORD is "oo", return
1489 "oobar"; if WORD is "baz/foo", return "baz/foobar". */
1490
1491char **
53904c9e
AC
1492complete_on_enum (const char *enumlist[],
1493 char *text,
1494 char *word)
c906108c
SS
1495{
1496 char **matchlist;
1497 int sizeof_matchlist;
1498 int matches;
1499 int textlen = strlen (text);
1500 int i;
53904c9e 1501 const char *name;
c906108c
SS
1502
1503 sizeof_matchlist = 10;
1504 matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
1505 matches = 0;
1506
1507 for (i = 0; (name = enumlist[i]) != NULL; i++)
1508 if (strncmp (name, text, textlen) == 0)
1509 {
1510 if (matches == sizeof_matchlist)
1511 {
1512 sizeof_matchlist *= 2;
c5aa993b 1513 matchlist = (char **) xrealloc ((char *) matchlist,
c906108c
SS
1514 (sizeof_matchlist
1515 * sizeof (char *)));
1516 }
1517
c5aa993b 1518 matchlist[matches] = (char *)
c906108c
SS
1519 xmalloc (strlen (word) + strlen (name) + 1);
1520 if (word == text)
1521 strcpy (matchlist[matches], name);
1522 else if (word > text)
1523 {
1524 /* Return some portion of name. */
1525 strcpy (matchlist[matches], name + (word - text));
1526 }
1527 else
1528 {
1529 /* Return some of text plus name. */
1530 strncpy (matchlist[matches], word, text - word);
1531 matchlist[matches][text - word] = '\0';
1532 strcat (matchlist[matches], name);
1533 }
1534 ++matches;
1535 }
1536
1537 if (matches == 0)
1538 {
c5aa993b 1539 free ((PTR) matchlist);
c906108c
SS
1540 matchlist = 0;
1541 }
1542 else
1543 {
c5aa993b
JM
1544 matchlist = (char **) xrealloc ((char *) matchlist, ((matches + 1)
1545 * sizeof (char *)));
c906108c
SS
1546 matchlist[matches] = (char *) 0;
1547 }
1548
1549 return matchlist;
1550}
1551
97c3646f
AC
1552static enum cmd_auto_boolean
1553parse_auto_binary_operation (const char *arg)
1554{
1555 if (arg != NULL && *arg != '\0')
1556 {
1557 int length = strlen (arg);
1558 while (isspace (arg[length - 1]) && length > 0)
1559 length--;
1560 if (strncmp (arg, "on", length) == 0
1561 || strncmp (arg, "1", length) == 0
1562 || strncmp (arg, "yes", length) == 0
1563 || strncmp (arg, "enable", length) == 0)
1564 return CMD_AUTO_BOOLEAN_TRUE;
1565 else if (strncmp (arg, "off", length) == 0
1566 || strncmp (arg, "0", length) == 0
1567 || strncmp (arg, "no", length) == 0
1568 || strncmp (arg, "disable", length) == 0)
1569 return CMD_AUTO_BOOLEAN_FALSE;
1570 else if (strncmp (arg, "auto", length) == 0
1571 || (strncmp (arg, "-1", length) == 0 && length > 1))
1572 return CMD_AUTO_BOOLEAN_AUTO;
1573 }
1574 error ("\"on\", \"off\" or \"auto\" expected.");
1575 return CMD_AUTO_BOOLEAN_AUTO; /* pacify GCC */
1576}
1577
c906108c
SS
1578static int
1579parse_binary_operation (arg)
1580 char *arg;
1581{
1582 int length;
1583
1584 if (!arg || !*arg)
1585 return 1;
1586
1587 length = strlen (arg);
1588
1589 while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
1590 length--;
1591
97c3646f
AC
1592 if (strncmp (arg, "on", length) == 0
1593 || strncmp (arg, "1", length) == 0
1594 || strncmp (arg, "yes", length) == 0
1595 || strncmp (arg, "enable", length) == 0)
c906108c 1596 return 1;
97c3646f
AC
1597 else if (strncmp (arg, "off", length) == 0
1598 || strncmp (arg, "0", length) == 0
1599 || strncmp (arg, "no", length) == 0
1600 || strncmp (arg, "disable", length) == 0)
c5aa993b 1601 return 0;
c906108c 1602 else
c5aa993b
JM
1603 {
1604 error ("\"on\" or \"off\" expected.");
c906108c 1605 return 0;
c5aa993b 1606 }
c906108c
SS
1607}
1608
1609/* Do a "set" or "show" command. ARG is NULL if no argument, or the text
1610 of the argument, and FROM_TTY is nonzero if this command is being entered
1611 directly by the user (i.e. these are just like any other
1612 command). C is the command list element for the command. */
1613void
1614do_setshow_command (arg, from_tty, c)
1615 char *arg;
1616 int from_tty;
1617 struct cmd_list_element *c;
1618{
1619 if (c->type == set_cmd)
1620 {
1621 switch (c->var_type)
1622 {
1623 case var_string:
1624 {
1625 char *new;
1626 char *p;
1627 char *q;
1628 int ch;
c5aa993b 1629
c906108c
SS
1630 if (arg == NULL)
1631 arg = "";
1632 new = (char *) xmalloc (strlen (arg) + 2);
c5aa993b
JM
1633 p = arg;
1634 q = new;
c906108c
SS
1635 while ((ch = *p++) != '\000')
1636 {
1637 if (ch == '\\')
1638 {
1639 /* \ at end of argument is used after spaces
1640 so they won't be lost. */
1641 /* This is obsolete now that we no longer strip
1642 trailing whitespace and actually, the backslash
1643 didn't get here in my test, readline or
1644 something did something funky with a backslash
1645 right before a newline. */
1646 if (*p == 0)
1647 break;
1648 ch = parse_escape (&p);
1649 if (ch == 0)
c5aa993b 1650 break; /* C loses */
c906108c
SS
1651 else if (ch > 0)
1652 *q++ = ch;
1653 }
1654 else
1655 *q++ = ch;
1656 }
1657#if 0
1658 if (*(p - 1) != '\\')
1659 *q++ = ' ';
1660#endif
1661 *q++ = '\0';
1662 new = (char *) xrealloc (new, q - new);
c5aa993b
JM
1663 if (*(char **) c->var != NULL)
1664 free (*(char **) c->var);
c906108c
SS
1665 *(char **) c->var = new;
1666 }
1667 break;
1668 case var_string_noescape:
1669 if (arg == NULL)
1670 arg = "";
c5aa993b
JM
1671 if (*(char **) c->var != NULL)
1672 free (*(char **) c->var);
c906108c
SS
1673 *(char **) c->var = savestring (arg, strlen (arg));
1674 break;
1675 case var_filename:
1676 if (arg == NULL)
1677 error_no_arg ("filename to set it to.");
c5aa993b
JM
1678 if (*(char **) c->var != NULL)
1679 free (*(char **) c->var);
1680 *(char **) c->var = tilde_expand (arg);
c906108c
SS
1681 break;
1682 case var_boolean:
1683 *(int *) c->var = parse_binary_operation (arg);
1684 break;
97c3646f
AC
1685 case var_auto_boolean:
1686 *(enum cmd_auto_boolean *) c->var = parse_auto_binary_operation (arg);
1687 break;
c906108c
SS
1688 case var_uinteger:
1689 if (arg == NULL)
1690 error_no_arg ("integer to set it to.");
1691 *(unsigned int *) c->var = parse_and_eval_address (arg);
1692 if (*(unsigned int *) c->var == 0)
1693 *(unsigned int *) c->var = UINT_MAX;
1694 break;
1695 case var_integer:
1696 {
1697 unsigned int val;
1698 if (arg == NULL)
1699 error_no_arg ("integer to set it to.");
1700 val = parse_and_eval_address (arg);
1701 if (val == 0)
1702 *(int *) c->var = INT_MAX;
1703 else if (val >= INT_MAX)
1704 error ("integer %u out of range", val);
1705 else
1706 *(int *) c->var = val;
1707 break;
1708 }
1709 case var_zinteger:
1710 if (arg == NULL)
1711 error_no_arg ("integer to set it to.");
1712 *(int *) c->var = parse_and_eval_address (arg);
1713 break;
1714 case var_enum:
1715 {
1716 int i;
1717 int len;
1718 int nmatches;
53904c9e 1719 const char *match = NULL;
c906108c
SS
1720 char *p;
1721
1722 /* if no argument was supplied, print an informative error message */
1723 if (arg == NULL)
1724 {
1725 char msg[1024];
1726 strcpy (msg, "Requires an argument. Valid arguments are ");
1727 for (i = 0; c->enums[i]; i++)
1728 {
1729 if (i != 0)
1730 strcat (msg, ", ");
1731 strcat (msg, c->enums[i]);
1732 }
1733 strcat (msg, ".");
1734 error (msg);
1735 }
1736
1737 p = strchr (arg, ' ');
c5aa993b 1738
c906108c
SS
1739 if (p)
1740 len = p - arg;
1741 else
1742 len = strlen (arg);
1743
1744 nmatches = 0;
1745 for (i = 0; c->enums[i]; i++)
1746 if (strncmp (arg, c->enums[i], len) == 0)
1747 {
aa891095
AC
1748 if (c->enums[i][len] == '\0')
1749 {
1750 match = c->enums[i];
1751 nmatches = 1;
1752 break; /* exact match. */
1753 }
1754 else
1755 {
1756 match = c->enums[i];
1757 nmatches++;
1758 }
c906108c
SS
1759 }
1760
1761 if (nmatches <= 0)
1762 error ("Undefined item: \"%s\".", arg);
1763
1764 if (nmatches > 1)
1765 error ("Ambiguous item \"%s\".", arg);
1766
53904c9e 1767 *(const char **) c->var = match;
c906108c
SS
1768 }
1769 break;
1770 default:
1771 error ("gdb internal error: bad var_type in do_setshow_command");
1772 }
1773 }
1774 else if (c->type == show_cmd)
1775 {
8b93c638
JM
1776#ifdef UI_OUT
1777 struct cleanup *old_chain;
1778 struct ui_stream *stb;
1779 int quote;
1780
1781 stb = ui_out_stream_new (uiout);
b02eeafb 1782 old_chain = make_cleanup_ui_out_stream_delete (stb);
8b93c638
JM
1783#endif /* UI_OUT */
1784
c906108c
SS
1785 /* Print doc minus "show" at start. */
1786 print_doc_line (gdb_stdout, c->doc + 5);
c5aa993b 1787
8b93c638
JM
1788#ifdef UI_OUT
1789 ui_out_text (uiout, " is ");
1790 ui_out_wrap_hint (uiout, " ");
1791 quote = 0;
1792 switch (c->var_type)
1793 {
1794 case var_string:
1795 {
1796 unsigned char *p;
1797
1798 if (*(unsigned char **) c->var)
1799 fputstr_filtered (*(unsigned char **) c->var, '"', stb->stream);
1800 quote = 1;
1801 }
1802 break;
1803 case var_string_noescape:
1804 case var_filename:
1805 case var_enum:
1806 if (*(char **) c->var)
1807 fputs_filtered (*(char **) c->var, stb->stream);
1808 quote = 1;
1809 break;
1810 case var_boolean:
1811 fputs_filtered (*(int *) c->var ? "on" : "off", stb->stream);
1812 break;
97c3646f
AC
1813 case var_auto_boolean:
1814 switch (*(enum auto_boolean*) c->var)
1815 {
1816 case CMD_AUTO_BOOLEAN_TRUE:
1817 fputs_filtered ("on", stb->stream);
1818 break;
1819 case CMD_AUTO_BOOLEAN_FALSE:
1820 fputs_filtered ("off", stb->stream);
1821 break;
1822 case CMD_AUTO_BOOLEAN_AUTO:
1823 fputs_filtered ("auto", stb->stream);
1824 break;
1825 default:
1826 internal_error ("do_setshow_command: invalid var_auto_boolean");
1827 break;
1828 }
1829 break;
8b93c638
JM
1830 case var_uinteger:
1831 if (*(unsigned int *) c->var == UINT_MAX)
1832 {
1833 fputs_filtered ("unlimited", stb->stream);
1834 break;
1835 }
1836 /* else fall through */
1837 case var_zinteger:
1838 fprintf_filtered (stb->stream, "%u", *(unsigned int *) c->var);
1839 break;
1840 case var_integer:
1841 if (*(int *) c->var == INT_MAX)
1842 {
1843 fputs_filtered ("unlimited", stb->stream);
1844 }
1845 else
1846 fprintf_filtered (stb->stream, "%d", *(int *) c->var);
1847 break;
1848
1849 default:
1850 error ("gdb internal error: bad var_type in do_setshow_command");
1851 }
1852 if (quote)
1853 ui_out_text (uiout, "\"");
1854 ui_out_field_stream (uiout, "value", stb);
1855 if (quote)
1856 ui_out_text (uiout, "\"");
1857 ui_out_text (uiout, ".\n");
1858 do_cleanups (old_chain);
1859#else
c906108c
SS
1860 fputs_filtered (" is ", gdb_stdout);
1861 wrap_here (" ");
1862 switch (c->var_type)
1863 {
c5aa993b
JM
1864 case var_string:
1865 {
c5aa993b
JM
1866 fputs_filtered ("\"", gdb_stdout);
1867 if (*(unsigned char **) c->var)
43e526b9 1868 fputstr_filtered (*(unsigned char **) c->var, '"', gdb_stdout);
c5aa993b
JM
1869 fputs_filtered ("\"", gdb_stdout);
1870 }
1871 break;
1872 case var_string_noescape:
1873 case var_filename:
1874 case var_enum:
c906108c 1875 fputs_filtered ("\"", gdb_stdout);
c5aa993b
JM
1876 if (*(char **) c->var)
1877 fputs_filtered (*(char **) c->var, gdb_stdout);
c906108c 1878 fputs_filtered ("\"", gdb_stdout);
c906108c 1879 break;
c5aa993b
JM
1880 case var_boolean:
1881 fputs_filtered (*(int *) c->var ? "on" : "off", gdb_stdout);
1882 break;
97c3646f
AC
1883 case var_auto_boolean:
1884 switch (*(enum cmd_auto_boolean*) c->var)
1885 {
1886 case CMD_AUTO_BOOLEAN_TRUE:
1887 fputs_filtered ("on", gdb_stdout);
1888 break;
1889 case CMD_AUTO_BOOLEAN_FALSE:
1890 fputs_filtered ("off", gdb_stdout);
1891 break;
1892 case CMD_AUTO_BOOLEAN_AUTO:
1893 fputs_filtered ("auto", gdb_stdout);
1894 break;
1895 default:
1896 internal_error ("do_setshow_command: invalid var_auto_boolean");
1897 break;
1898 }
1899 break;
c5aa993b
JM
1900 case var_uinteger:
1901 if (*(unsigned int *) c->var == UINT_MAX)
1902 {
1903 fputs_filtered ("unlimited", gdb_stdout);
1904 break;
1905 }
1906 /* else fall through */
1907 case var_zinteger:
1908 fprintf_filtered (gdb_stdout, "%u", *(unsigned int *) c->var);
1909 break;
1910 case var_integer:
1911 if (*(int *) c->var == INT_MAX)
1912 {
1913 fputs_filtered ("unlimited", gdb_stdout);
1914 }
1915 else
1916 fprintf_filtered (gdb_stdout, "%d", *(int *) c->var);
1917 break;
1918
1919 default:
1920 error ("gdb internal error: bad var_type in do_setshow_command");
c906108c 1921 }
c906108c 1922 fputs_filtered (".\n", gdb_stdout);
8b93c638 1923#endif
c906108c
SS
1924 }
1925 else
1926 error ("gdb internal error: bad cmd_type in do_setshow_command");
1927 (*c->function.sfunc) (NULL, from_tty, c);
96baa820
JM
1928 if (c->type == set_cmd && set_hook)
1929 set_hook (c);
c906108c
SS
1930}
1931
1932/* Show all the settings in a list of show commands. */
1933
1934void
1935cmd_show_list (list, from_tty, prefix)
1936 struct cmd_list_element *list;
1937 int from_tty;
1938 char *prefix;
1939{
8b93c638
JM
1940#ifdef UI_OUT
1941 ui_out_list_begin (uiout, "showlist");
1942#endif
c5aa993b
JM
1943 for (; list != NULL; list = list->next)
1944 {
1945 /* If we find a prefix, run its list, prefixing our output by its
1946 prefix (with "show " skipped). */
8b93c638
JM
1947#ifdef UI_OUT
1948 if (list->prefixlist && !list->abbrev_flag)
1949 {
1950 ui_out_list_begin (uiout, "optionlist");
1951 ui_out_field_string (uiout, "prefix", list->prefixname + 5);
1952 cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5);
1953 ui_out_list_end (uiout);
1954 }
1955 if (list->type == show_cmd)
1956 {
1957 ui_out_list_begin (uiout, "option");
1958 ui_out_text (uiout, prefix);
1959 ui_out_field_string (uiout, "name", list->name);
1960 ui_out_text (uiout, ": ");
1961 do_setshow_command ((char *) NULL, from_tty, list);
1962 ui_out_list_end (uiout);
1963 }
1964#else
c5aa993b
JM
1965 if (list->prefixlist && !list->abbrev_flag)
1966 cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5);
1967 if (list->type == show_cmd)
1968 {
1969 fputs_filtered (prefix, gdb_stdout);
1970 fputs_filtered (list->name, gdb_stdout);
1971 fputs_filtered (": ", gdb_stdout);
1972 do_setshow_command ((char *) NULL, from_tty, list);
1973 }
8b93c638 1974#endif
c5aa993b 1975 }
8b93c638
JM
1976#ifdef UI_OUT
1977 ui_out_list_end (uiout);
1978#endif
c906108c
SS
1979}
1980
1981/* ARGSUSED */
1982static void
1983shell_escape (arg, from_tty)
1984 char *arg;
1985 int from_tty;
1986{
1987#ifdef CANT_FORK
53a5351d
JM
1988 /* If ARG is NULL, they want an inferior shell, but `system' just
1989 reports if the shell is available when passed a NULL arg. */
1990 int rc = system (arg ? arg : "");
1991
1992 if (!arg)
1993 arg = "inferior shell";
1994
1995 if (rc == -1)
1996 {
1997 fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", arg,
1998 safe_strerror (errno));
1999 gdb_flush (gdb_stderr);
2000 }
2001 else if (rc)
2002 {
2003 fprintf_unfiltered (gdb_stderr, "%s exited with status %d\n", arg, rc);
2004 gdb_flush (gdb_stderr);
2005 }
2006#ifdef __DJGPP__
2007 /* Make sure to return to the directory GDB thinks it is, in case the
2008 shell command we just ran changed it. */
2009 chdir (current_directory);
2010#endif
c906108c
SS
2011#else /* Can fork. */
2012 int rc, status, pid;
2013 char *p, *user_shell;
2014
2015 if ((user_shell = (char *) getenv ("SHELL")) == NULL)
2016 user_shell = "/bin/sh";
2017
2018 /* Get the name of the shell for arg0 */
2019 if ((p = strrchr (user_shell, '/')) == NULL)
2020 p = user_shell;
2021 else
2022 p++; /* Get past '/' */
2023
c5aa993b 2024 if ((pid = fork ()) == 0)
c906108c
SS
2025 {
2026 if (!arg)
2027 execl (user_shell, p, 0);
2028 else
2029 execl (user_shell, p, "-c", arg, 0);
2030
2031 fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", user_shell,
2032 safe_strerror (errno));
2033 gdb_flush (gdb_stderr);
2034 _exit (0177);
2035 }
2036
2037 if (pid != -1)
2038 while ((rc = wait (&status)) != pid && rc != -1)
2039 ;
2040 else
2041 error ("Fork failed");
2042#endif /* Can fork. */
2043}
2044
2045static void
2046make_command (arg, from_tty)
2047 char *arg;
2048 int from_tty;
2049{
2050 char *p;
2051
2052 if (arg == 0)
2053 p = "make";
2054 else
2055 {
c5aa993b 2056 p = xmalloc (sizeof ("make ") + strlen (arg));
c906108c 2057 strcpy (p, "make ");
c5aa993b 2058 strcpy (p + sizeof ("make ") - 1, arg);
c906108c 2059 }
c5aa993b 2060
c906108c
SS
2061 shell_escape (p, from_tty);
2062}
2063
2064static void
2065show_user_1 (c, stream)
2066 struct cmd_list_element *c;
d9fcf2fb 2067 struct ui_file *stream;
c906108c
SS
2068{
2069 register struct command_line *cmdlines;
2070
2071 cmdlines = c->user_commands;
2072 if (!cmdlines)
2073 return;
2074 fputs_filtered ("User command ", stream);
2075 fputs_filtered (c->name, stream);
2076 fputs_filtered (":\n", stream);
2077
8b93c638
JM
2078#ifdef UI_OUT
2079 print_command_lines (uiout, cmdlines, 1);
2080 fputs_filtered ("\n", stream);
2081#else
c906108c
SS
2082 while (cmdlines)
2083 {
9e086581 2084 print_command_line (cmdlines, 4, stream);
c906108c
SS
2085 cmdlines = cmdlines->next;
2086 }
2087 fputs_filtered ("\n", stream);
8b93c638 2088#endif
c906108c
SS
2089}
2090
2091/* ARGSUSED */
2092static void
2093show_user (args, from_tty)
2094 char *args;
2095 int from_tty;
2096{
2097 struct cmd_list_element *c;
2098 extern struct cmd_list_element *cmdlist;
2099
2100 if (args)
2101 {
2102 c = lookup_cmd (&args, cmdlist, "", 0, 1);
2103 if (c->class != class_user)
2104 error ("Not a user command.");
2105 show_user_1 (c, gdb_stdout);
2106 }
2107 else
2108 {
2109 for (c = cmdlist; c; c = c->next)
2110 {
2111 if (c->class == class_user)
2112 show_user_1 (c, gdb_stdout);
2113 }
2114 }
2115}
2116
2117void
2118_initialize_command ()
2119{
2120 add_com ("shell", class_support, shell_escape,
2121 "Execute the rest of the line as a shell command. \n\
2122With no arguments, run an inferior shell.");
2123
acd46a93
AC
2124 /* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would
2125 be a really useful feature. Unfortunatly, the below wont do
2126 this. Instead it adds support for the form ``(gdb) ! ls''
2127 (i.e. the space is required). If the ``!'' command below is
2128 added the complains about no ``!'' command would be replaced by
2129 complains about how the ``!'' command is broken :-) */
c906108c 2130 if (xdb_commands)
c5aa993b 2131 add_com_alias ("!", "shell", class_support, 0);
c906108c
SS
2132
2133 add_com ("make", class_support, make_command,
c5aa993b
JM
2134 "Run the ``make'' program using the rest of the line as arguments.");
2135 add_cmd ("user", no_class, show_user,
c906108c
SS
2136 "Show definitions of user defined commands.\n\
2137Argument is the name of the user defined command.\n\
2138With no argument, show definitions of all user defined commands.", &showlist);
6837a0a2 2139 add_com ("apropos", class_support, apropos_command, "Search for commands matching a REGEXP");
c906108c 2140}
This page took 0.166439 seconds and 4 git commands to generate.