• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisión683f7a0d02c16dfc6e8be024ac6b41bbae7a0c36 (tree)
Tiempo2019-06-05 07:30:02
AutorPedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

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:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* cli/cli-setshow.c (parse_auto_binary_operation)
(parse_cli_boolean_value): Don't allow "o".

gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* gdb.base/settings.exp (test-boolean, test-auto-boolean): Check
that "o" is ambiguous.

Cambiar Resumen

Diferencia incremental

--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -54,18 +54,21 @@ parse_auto_binary_operation (const char *arg)
5454
5555 while (isspace (arg[length - 1]) && length > 0)
5656 length--;
57- if (strncmp (arg, "on", length) == 0
57+
58+ /* Note that "o" is ambiguous. */
59+
60+ if ((length == 2 && strncmp (arg, "on", length) == 0)
5861 || strncmp (arg, "1", length) == 0
5962 || strncmp (arg, "yes", length) == 0
6063 || strncmp (arg, "enable", length) == 0)
6164 return AUTO_BOOLEAN_TRUE;
62- else if (strncmp (arg, "off", length) == 0
65+ else if ((length >= 2 && strncmp (arg, "off", length) == 0)
6366 || strncmp (arg, "0", length) == 0
6467 || strncmp (arg, "no", length) == 0
6568 || strncmp (arg, "disable", length) == 0)
6669 return AUTO_BOOLEAN_FALSE;
6770 else if (strncmp (arg, "auto", length) == 0
68- || (strncmp (arg, "-1", length) == 0 && length > 1))
71+ || (length > 1 && strncmp (arg, "-1", length) == 0))
6972 return AUTO_BOOLEAN_AUTO;
7073 }
7174 error (_("\"on\", \"off\" or \"auto\" expected."));
@@ -87,12 +90,14 @@ parse_cli_boolean_value (const char *arg)
8790 while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
8891 length--;
8992
90- if (strncmp (arg, "on", length) == 0
93+ /* Note that "o" is ambiguous. */
94+
95+ if ((length == 2 && strncmp (arg, "on", length) == 0)
9196 || strncmp (arg, "1", length) == 0
9297 || strncmp (arg, "yes", length) == 0
9398 || strncmp (arg, "enable", length) == 0)
9499 return 1;
95- else if (strncmp (arg, "off", length) == 0
100+ else if ((length >= 2 && strncmp (arg, "off", length) == 0)
96101 || strncmp (arg, "0", length) == 0
97102 || strncmp (arg, "no", length) == 0
98103 || strncmp (arg, "disable", length) == 0)
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -194,13 +194,16 @@ proc_with_prefix test-boolean {} {
194194 gdb_test "$set_cmd auto" \
195195 "\"on\" or \"off\" expected\\."
196196
197+ # "o" is ambiguous.
198+ gdb_test "$set_cmd o" \
199+ "\"on\" or \"off\" expected\\."
200+
197201 # Various valid values. Test both full value names and
198202 # abbreviations.
199203
200204 # Note that unlike with auto-bool, empty value implies "on".
201205 foreach_with_prefix value {
202206 ""
203- "o"
204207 "on"
205208 "1"
206209 "y"
@@ -278,11 +281,14 @@ proc_with_prefix test-auto-boolean {} {
278281 gdb_test "$set_cmd on 1" \
279282 "\"on\", \"off\" or \"auto\" expected\\."
280283
284+ # "o" is ambiguous.
285+ gdb_test "$set_cmd o" \
286+ "\"on\", \"off\" or \"auto\" expected\\."
287+
281288 # Various valid values. Test both full value names and
282289 # abbreviations.
283290
284291 foreach_with_prefix value {
285- "o"
286292 "on"
287293 "1"
288294 "y"