From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27127 invoked by alias); 21 Nov 2005 19:13:07 -0000 Received: (qmail 27116 invoked by uid 22791); 21 Nov 2005 19:13:06 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-03.spheriq.net (HELO lon-del-03.spheriq.net) (195.46.50.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 21 Nov 2005 19:13:04 +0000 Received: from lon-out-02.spheriq.net ([195.46.50.130]) by lon-del-03.spheriq.net with ESMTP id jALJD1h4030490 for ; Mon, 21 Nov 2005 19:13:01 GMT Received: from lon-cus-02.spheriq.net (lon-cus-02.spheriq.net [195.46.50.38]) by lon-out-02.spheriq.net with ESMTP id jALJD0gY015628 for ; Mon, 21 Nov 2005 19:13:00 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-02.spheriq.net with ESMTP id jALJCt26013941 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Mon, 21 Nov 2005 19:12:57 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BC9AAEB45; Mon, 21 Nov 2005 17:45:56 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 81CB247524; Mon, 21 Nov 2005 17:48:57 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 17E7B7599B; Mon, 21 Nov 2005 17:48:57 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 94C7A47528; Mon, 21 Nov 2005 17:48:55 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CGZ70626 (AUTH "andrew stubbs"); Mon, 21 Nov 2005 17:45:51 GMT Message-ID: <4382072A.1010402@st.com> Date: Tue, 22 Nov 2005 02:17:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: Eli Zaretskii Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] Fix 'Undefined command' error message References: <4379EC0A.3060601@st.com> <20051116201300.GA23472@nevyn.them.org> In-Reply-To: Content-Type: multipart/mixed; boundary="------------080000090807010707030204" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.1.07 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00396.txt.bz2 This is a multi-part message in MIME format. --------------080000090807010707030204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 689 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 --------------080000090807010707030204 Content-Type: text/plain; name="cli-decode-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cli-decode-2.patch" Content-length: 5520 2005-11-21 Andrew Stubbs * 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; } } --------------080000090807010707030204--