public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] boolean/auto-boolean commands, make "o" ambiguous
@ 2019-06-12 23:28 Pedro Alves
0 siblings, 0 replies; only message in thread
From: Pedro Alves @ 2019-06-12 23:28 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dee7b4c83a636471ee321fb4fe1c3be0a16a9ea7
commit dee7b4c83a636471ee321fb4fe1c3be0a16a9ea7
Author: Pedro Alves <palves@redhat.com>
Date: Thu Jun 13 00:06:52 2019 +0100
boolean/auto-boolean commands, make "o" ambiguous
We currently accept "o" with boolean/auto-boolean commands, taking it
to mean "on". But "o" is ambiguous, between "on" and "off". I can't
imagine why assuming the user wanted to type "on" is a good idea, it
might have been a typo.
This commit makes gdb error out. We now get:
(gdb) maint test-settings set boolean o
"on" or "off" expected.
(gdb) maint test-settings set auto-boolean o
"on", "off" or "auto" expected.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-setshow.c (parse_auto_binary_operation)
(parse_cli_boolean_value): Don't allow "o".
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/settings.exp (test-boolean, test-auto-boolean): Check
that "o" is ambiguous.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/cli/cli-setshow.c | 15 ++++++++++-----
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.base/settings.exp | 10 ++++++++--
4 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1828a74..63a3690 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2019-06-13 Pedro Alves <palves@redhat.com>
+ * cli/cli-setshow.c (parse_auto_binary_operation)
+ (parse_cli_boolean_value): Don't allow "o".
+
+2019-06-13 Pedro Alves <palves@redhat.com>
+
* Makefile.in (COMMON_SFILES): Add maint-test-settings.c.
* NEWS: Mention maint test-settings KIND.
* maint-test-settings.c: New file.
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 86ebed4..9841ec1 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -54,18 +54,21 @@ parse_auto_binary_operation (const char *arg)
while (isspace (arg[length - 1]) && length > 0)
length--;
- if (strncmp (arg, "on", length) == 0
+
+ /* Note that "o" is ambiguous. */
+
+ if ((length == 2 && strncmp (arg, "on", length) == 0)
|| strncmp (arg, "1", length) == 0
|| strncmp (arg, "yes", length) == 0
|| strncmp (arg, "enable", length) == 0)
return AUTO_BOOLEAN_TRUE;
- else if (strncmp (arg, "off", length) == 0
+ else if ((length >= 2 && strncmp (arg, "off", length) == 0)
|| strncmp (arg, "0", length) == 0
|| strncmp (arg, "no", length) == 0
|| strncmp (arg, "disable", length) == 0)
return AUTO_BOOLEAN_FALSE;
else if (strncmp (arg, "auto", length) == 0
- || (strncmp (arg, "-1", length) == 0 && length > 1))
+ || (length > 1 && strncmp (arg, "-1", length) == 0))
return AUTO_BOOLEAN_AUTO;
}
error (_("\"on\", \"off\" or \"auto\" expected."));
@@ -87,12 +90,14 @@ parse_cli_boolean_value (const char *arg)
while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
length--;
- if (strncmp (arg, "on", length) == 0
+ /* Note that "o" is ambiguous. */
+
+ if ((length == 2 && strncmp (arg, "on", length) == 0)
|| strncmp (arg, "1", length) == 0
|| strncmp (arg, "yes", length) == 0
|| strncmp (arg, "enable", length) == 0)
return 1;
- else if (strncmp (arg, "off", length) == 0
+ else if ((length >= 2 && strncmp (arg, "off", length) == 0)
|| strncmp (arg, "0", length) == 0
|| strncmp (arg, "no", length) == 0
|| strncmp (arg, "disable", length) == 0)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 85fa7e0..1c362f7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2019-06-13 Pedro Alves <palves@redhat.com>
+ * gdb.base/settings.exp (test-boolean, test-auto-boolean): Check
+ that "o" is ambiguous.
+
+2019-06-13 Pedro Alves <palves@redhat.com>
+
* gdb.base/settings.c: New file.
* gdb.base/settings.exp: New file.
diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
index f96e9f6..4a7319d 100644
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -194,13 +194,16 @@ proc_with_prefix test-boolean {} {
gdb_test "$set_cmd auto" \
"\"on\" or \"off\" expected\\."
+ # "o" is ambiguous.
+ gdb_test "$set_cmd o" \
+ "\"on\" or \"off\" expected\\."
+
# Various valid values. Test both full value names and
# abbreviations.
# Note that unlike with auto-bool, empty value implies "on".
foreach_with_prefix value {
""
- "o"
"on"
"1"
"y"
@@ -278,11 +281,14 @@ proc_with_prefix test-auto-boolean {} {
gdb_test "$set_cmd on 1" \
"\"on\", \"off\" or \"auto\" expected\\."
+ # "o" is ambiguous.
+ gdb_test "$set_cmd o" \
+ "\"on\", \"off\" or \"auto\" expected\\."
+
# Various valid values. Test both full value names and
# abbreviations.
foreach_with_prefix value {
- "o"
"on"
"1"
"y"
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-12 23:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 23:28 [binutils-gdb] boolean/auto-boolean commands, make "o" ambiguous Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).