]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
define_command: Don't convert command name to lower case
authorSimon Marchi <simon.marchi@ericsson.com>
Mon, 28 Aug 2017 21:05:04 +0000 (23:05 +0200)
committerSimon Marchi <simon.marchi@ericsson.com>
Mon, 28 Aug 2017 21:11:15 +0000 (23:11 +0200)
Commit

  Command names: make them case sensitive
  3d7b173c29900879c9a5958dd6029fd36666e57c

made command name lookup case sensitive.  However, define_command, used
when creating a user-defined command, converts the command name to
lowercase, assuming that the command name lookup works in a case
insensitive way.  This causes user-defined commands with capital letters
in their name to only be callable with a lowercase version:

  (gdb) define Foo
  Type commands for definition of "Foo".
  End with a line saying just "end".
  >print 1
  >end
  (gdb) Foo
  Undefined command: "Foo".  Try "help".
  (gdb) foo
  $1 = 1

This patch removes that conversion to lowercase, so that the user can
call the command with the same name they provided.

gdb/ChangeLog:

* cli/cli-script.c (define_command): Don't convert command name
to lower case.

gdb/testsuite/ChangeLog:

* gdb.base/commands.exp (user_defined_command_case_sensitivity):
New proc, call it from toplevel.

gdb/ChangeLog
gdb/cli/cli-script.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/commands.exp

index 9ce59c16684fa2951a13f5ddf0e8cd8c43157683..97299e6180c9cef3acf3617fa3553a2c03dc9f10 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-28  Simon Marchi  <simon.marchi@ericsson.com>
+
+       PR gdb/21827
+       * cli/cli-script.c (define_command): Don't convert command name
+       to lower case.
+
 2017-08-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        PR symtab/22003
index 3a2ae15fd04566dec20414388dc74c8b67ffac96..f1db954a690c93dbaa5c4485d65b6b68452a0999 100644 (file)
@@ -1498,12 +1498,6 @@ define_command (char *comname, int from_tty)
 
   comname = xstrdup (comname);
 
-  /* If the rest of the commands will be case insensitive, this one
-     should behave in the same manner.  */
-  for (tem = comname; *tem; tem++)
-    if (isupper (*tem))
-      *tem = tolower (*tem);
-
   xsnprintf (tmpbuf, sizeof (tmpbuf),
             "Type commands for definition of \"%s\".", comfull);
   command_line_up cmds = read_command_lines (tmpbuf, from_tty, 1, 0, 0);
index 689e44e058de09d035d8bf9ce28ce3cb956888bf..9a656b681825e6a70ecf109d7327bc242e3b6490 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-28  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb.base/commands.exp (user_defined_command_case_sensitivity):
+       New proc, call it from toplevel.
+
 2017-07-25  Yao Qi  <yao.qi@linaro.org>
 
        PR gdb/21555
index 4963743d2b63de3e67b31ec92a1850303b2061cd..4cd5f46431f6cb9658403a9e47ee35947c648e09 100644 (file)
@@ -352,6 +352,35 @@ proc_with_prefix user_defined_command_test {} {
        "display user-defined empty command"
 }
 
+# Test that the case with which the command was defined is preserved.
+
+proc_with_prefix user_defined_command_case_sensitivity {} {
+    # Define a first command with mixed case name.
+    set test "define Homer-Simpson"
+    gdb_test_multiple $test $test {
+           -re "End with"  {
+               pass $test
+           }
+       }
+
+    gdb_test "print 123\nend" "" "enter commands 1"
+
+    # Define a second command, same name but different case.
+    set test "define HomeR-SimpsoN"
+    gdb_test_multiple $test $test {
+           -re "End with"  {
+               pass $test
+           }
+       }
+
+    gdb_test "print 456\nend" "" "enter commands 2"
+
+    gdb_test "Homer-Simpson" " = 123" "execute command"
+    gdb_test "HomeR-SimpsoN" " = 456" "execute command"
+    gdb_test "HOMER-SIMPSON" "Undefined command.*" "try to call in upper case"
+    gdb_test "homer-simpson" "Undefined command.*" "try to call in lower case"
+}
+
 # Test that "eval" in a user-defined command expands $argc/$argN.
 
 proc_with_prefix user_defined_command_args_eval {} {
@@ -1052,6 +1081,7 @@ if_while_breakpoint_command_test
 infrun_breakpoint_command_test
 breakpoint_command_test
 user_defined_command_test
+user_defined_command_case_sensitivity
 user_defined_command_args_eval
 user_defined_command_args_stack_test
 user_defined_command_manyargs_test