From: Andrew STUBBS <andrew.stubbs@st.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Fix 'Undefined command' error message
Date: Tue, 22 Nov 2005 02:17:00 -0000 [thread overview]
Message-ID: <4382072A.1010402@st.com> (raw)
In-Reply-To: <uzmo45ohe.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
Eli Zaretskii wrote:
> I'd prefer to have the same characters allowed in all CLI commands.
> Any other way would be very confusing to users.
>
> Thanks for the other clarifications. I think we should at least add
> comments that explain the respective characters.
I have moved all three instances of this code in to one function, added
comments, removed the pointless '*p' and allowed the TUI characters all
the time.
The XDB characters clash with existing GDB commands so I have left those
disabled unless in XDB mode. Specifically commands such as 'x/i' fail
because the command there is actually only 'x'. Obviously this does not
affect commands such as 'x /i'.
Andrew Stubbs
[-- Attachment #2: cli-decode-2.patch --]
[-- Type: text/plain, Size: 5520 bytes --]
2005-11-21 Andrew Stubbs <andrew.stubbs@st.com>
* cli-decode.c (find_command_name_length): New function.
(lookup_cmd_1): Replace loop reading command name with
find_command_name_length().
(lookup_cmd): Likewise.
(lookup_cmd_composition): Likewise.
Index: src/gdb/cli/cli-decode.c
===================================================================
--- src.orig/gdb/cli/cli-decode.c 2005-11-18 16:30:29.000000000 +0000
+++ src/gdb/cli/cli-decode.c 2005-11-21 16:41:02.000000000 +0000
@@ -977,6 +977,31 @@ find_cmd (char *command, int len, struct
return found;
}
+static int
+find_command_name_length (const char *text)
+{
+ const char *p = text;
+
+ /* Treating underscores as part of command words is important
+ so that "set args_foo()" doesn't get interpreted as
+ "set args _foo()". */
+ /* Some characters are only used for TUI specific commands. However, they
+ are always allowed for the sake of consistency.
+ The XDB compatibility characters are only allowed when using the right
+ mode because they clash with other GDB commands - specifically '/' is
+ used as a suffix for print, examine and display.
+ Note that this is larger than the character set allowed when creating
+ user-defined commands. */
+ while (isalnum (*p) || *p == '-' || *p == '_' ||
+ /* Characters used by TUI specific commands. */
+ *p == '+' || *p == '<' || *p == '>' || *p == '$' ||
+ /* Characters used for XDB compatibility. */
+ (xdb_commands && (*p == '!' || *p == '/' || *p == '?')))
+ p++;
+
+ return p - text;
+}
+
/* This routine takes a line of TEXT and a CLIST in which to start the
lookup. When it returns it will have incremented the text pointer past
the section of text it matched, set *RESULT_LIST to point to the list in
@@ -1017,7 +1042,7 @@ struct cmd_list_element *
lookup_cmd_1 (char **text, struct cmd_list_element *clist,
struct cmd_list_element **result_list, int ignore_help_classes)
{
- char *p, *command;
+ char *command;
int len, tmp, nfound;
struct cmd_list_element *found, *c;
char *line = *text;
@@ -1025,27 +1050,13 @@ lookup_cmd_1 (char **text, struct cmd_li
while (**text == ' ' || **text == '\t')
(*text)++;
- /* Treating underscores as part of command words is important
- so that "set args_foo()" doesn't get interpreted as
- "set args _foo()". */
- /* NOTE: cagney/2003-02-13 The `tui_active' was previously
- `tui_version'. */
- for (p = *text;
- *p && (isalnum (*p) || *p == '-' || *p == '_' ||
-#if defined(TUI)
- (tui_active &&
- (*p == '+' || *p == '<' || *p == '>' || *p == '$')) ||
-#endif
- (xdb_commands && (*p == '!' || *p == '/' || *p == '?')));
- p++)
- ;
+ /* Identify the name of the command. */
+ len = find_command_name_length (*text);
/* If nothing but whitespace, return 0. */
- if (p == *text)
+ if (len == 0)
return 0;
- len = p - *text;
-
/* *text and p now bracket the first command word to lookup (and
it's length is len). We copy this into a local temporary */
@@ -1092,7 +1103,7 @@ lookup_cmd_1 (char **text, struct cmd_li
/* We've matched something on this list. Move text pointer forward. */
- *text = p;
+ *text += len;
if (found->cmd_pointer)
{
@@ -1194,14 +1205,12 @@ lookup_cmd (char **line, struct cmd_list
error (_("Lack of needed %scommand"), cmdtype);
else
{
- char *p = *line, *q;
+ char *q;
+ int len = find_command_name_length (*line);
- while (isalnum (*p) || *p == '-')
- p++;
-
- q = (char *) alloca (p - *line + 1);
- strncpy (q, *line, p - *line);
- q[p - *line] = '\0';
+ q = (char *) alloca (len + 1);
+ strncpy (q, *line, len);
+ q[len] = '\0';
undef_cmd_error (cmdtype, q);
}
}
@@ -1379,7 +1388,7 @@ lookup_cmd_composition (char *text,
struct cmd_list_element **prefix_cmd,
struct cmd_list_element **cmd)
{
- char *p, *command;
+ char *command;
int len, tmp, nfound;
struct cmd_list_element *cur_list;
struct cmd_list_element *prev_cmd;
@@ -1399,28 +1408,14 @@ lookup_cmd_composition (char *text,
while (*text == ' ' || *text == '\t')
(text)++;
- /* Treating underscores as part of command words is important
- so that "set args_foo()" doesn't get interpreted as
- "set args _foo()". */
- /* NOTE: cagney/2003-02-13 The `tui_active' was previously
- `tui_version'. */
- for (p = text;
- *p && (isalnum (*p) || *p == '-' || *p == '_' ||
-#if defined(TUI)
- (tui_active &&
- (*p == '+' || *p == '<' || *p == '>' || *p == '$')) ||
-#endif
- (xdb_commands && (*p == '!' || *p == '/' || *p == '?')));
- p++)
- ;
+ /* Identify the name of the command. */
+ len = find_command_name_length (text);
/* If nothing but whitespace, return. */
- if (p == text)
- return 0;
-
- len = p - text;
+ if (len == 0)
+ return 0;
- /* text and p now bracket the first command word to lookup (and
+ /* text is the start of the first command word to lookup (and
it's length is len). We copy this into a local temporary */
command = (char *) alloca (len + 1);
@@ -1473,7 +1468,7 @@ lookup_cmd_composition (char *text,
else
return 1;
- text = p;
+ text += len;
}
}
next prev parent reply other threads:[~2005-11-21 19:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-15 18:11 Andrew STUBBS
2005-11-16 4:52 ` Eli Zaretskii
2005-11-16 14:56 ` Andrew STUBBS
2005-11-16 20:19 ` Eli Zaretskii
2005-11-16 23:28 ` Daniel Jacobowitz
2005-11-17 0:10 ` Eli Zaretskii
2005-11-22 2:17 ` Andrew STUBBS [this message]
2005-11-22 2:31 ` Andreas Schwab
2005-11-23 18:58 ` Andrew STUBBS
2005-11-23 19:19 ` Eli Zaretskii
2005-11-23 21:07 ` Andrew STUBBS
2005-11-24 4:33 ` Daniel Jacobowitz
2005-11-24 17:29 ` Eli Zaretskii
2005-11-24 18:11 ` Daniel Jacobowitz
2005-11-24 20:31 ` Eli Zaretskii
2005-11-24 22:37 ` Andrew STUBBS
2005-11-24 23:57 ` Eli Zaretskii
2005-11-24 10:34 ` Eli Zaretskii
2005-11-22 5:38 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4382072A.1010402@st.com \
--to=andrew.stubbs@st.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox