This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa] add_set_boolean_cmd() with tab expansion
- To: gdb-patches at sources dot redhat dot com
- Subject: [rfa] add_set_boolean_cmd() with tab expansion
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 24 Sep 2001 00:31:22 -0400
Hello,
Per my e-mail to gdb@, the attached introduces a add_set_boolean_cmd()
function that will tab expand to the choice on/off. I've updated the
``set remotebreak'' command so that it uses this. It lets people get a
feel for its general affect. Assuming this change ok, I think updating
all the other boolean commands can done in a second (obvious change)
pass (I'll add it to the ari).
I should note that the behavour is interesting but correct. A typical
sequence is:
(gdb) set remotebre<tab>
gives:
(gdb) set remotebreak <cursor>
(gdb) set remotebreak <tab>
gives:
off on
(gdb) set remotebreak o<cursor>
(yes you get the ``o'')
ok?
Andrew
2001-09-22 Andrew Cagney <ac131313@redhat.com>
* cli/cli-decode.c (add_set_boolean_cmd): Define.
* command.h (add_set_boolean_cmd): Declare.
* remote.c (_initialize_remote): Use add_set_boolean_cmd for "set
remotebreak"
Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.18
diff -p -r1.18 command.h
*** command.h 2001/07/16 14:46:34 1.18
--- command.h 2001/09/24 04:18:29
*************** extern struct cmd_list_element *add_set_
*** 340,345 ****
--- 340,351 ----
char *doc,
struct cmd_list_element **list);
+ extern struct cmd_list_element *add_set_boolean_cmd (char *name,
+ enum command_class class,
+ int *var,
+ char *doc,
+ struct cmd_list_element **list);
+
extern struct cmd_list_element *add_show_from_set (struct cmd_list_element *,
struct cmd_list_element
**);
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.62
diff -p -r1.62 remote.c
*** remote.c 2001/08/10 09:59:32 1.62
--- remote.c 2001/09/24 04:18:30
*************** terminating `#' character and checksum."
*** 5877,5886 ****
&maintenancelist);
add_show_from_set
! (add_set_cmd ("remotebreak", no_class,
! var_boolean, (char *) &remote_break,
! "Set whether to send break if interrupted.\n",
! &setlist),
&showlist);
/* Install commands for configuring memory read/write packets. */
--- 5877,5885 ----
&maintenancelist);
add_show_from_set
! (add_set_boolean_cmd ("remotebreak", no_class, &remote_break,
! "Set whether to send break if interrupted.\n",
! &setlist),
&showlist);
/* Install commands for configuring memory read/write packets. */
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.8
diff -p -r1.8 cli-decode.c
*** cli-decode.c 2001/09/01 21:38:05 1.8
--- cli-decode.c 2001/09/24 04:18:31
*************** add_set_auto_boolean_cmd (char *name,
*** 291,296 ****
--- 291,315 ----
return c;
}
+ /* Add element named NAME to command list LIST (the list for set
+ or some sublist thereof).
+ CLASS is as in add_cmd.
+ VAR is address of the variable which will contain the value.
+ DOC is the documentation string. */
+ struct cmd_list_element *
+ add_set_boolean_cmd (char *name,
+ enum command_class class,
+ int *var,
+ char *doc,
+ struct cmd_list_element **list)
+ {
+ static const char *boolean_enums[] = { "on", "off", NULL };
+ struct cmd_list_element *c;
+ c = add_set_cmd (name, class, var_boolean, var, doc, list);
+ c->enums = boolean_enums;
+ return c;
+ }
+
/* Where SETCMD has already been added, add the corresponding show
command to LIST and return a pointer to the added command (not
necessarily the head of LIST). */