diff options
author | Andrew Stubbs <andrew.stubbs@st.com> | 2005-11-25 11:45:49 +0000 |
---|---|---|
committer | Andrew Stubbs <andrew.stubbs@st.com> | 2005-11-25 11:45:49 +0000 |
commit | 3386243e487ef3b023f3db2a1d0c51c1f96c9b77 (patch) | |
tree | 7f352ab1d0062257f835315464dfc59ae5af5fde /gdb/cli/cli-decode.c | |
parent | b251bf6fa695361fc1721260052bd97a3028d7c5 (diff) | |
download | gdb-3386243e487ef3b023f3db2a1d0c51c1f96c9b77.zip gdb-3386243e487ef3b023f3db2a1d0c51c1f96c9b77.tar.gz gdb-3386243e487ef3b023f3db2a1d0c51c1f96c9b77.tar.bz2 |
2005-11-25 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.
Diffstat (limited to 'gdb/cli/cli-decode.c')
-rw-r--r-- | gdb/cli/cli-decode.c | 89 |
1 files changed, 42 insertions, 47 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 9933e30..b08e82c 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -977,6 +977,31 @@ find_cmd (char *command, int len, struct cmd_list_element *clist, 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_list_element *clist, 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_list_element *clist, /* 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_element *list, char *cmdtype, error (_("Lack of needed %scommand"), cmdtype); else { - char *p = *line, *q; - - while (isalnum (*p) || *p == '-') - p++; + char *q; + int len = find_command_name_length (*line); - 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; } } |