From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9705 invoked by alias); 24 Sep 2003 23:14:04 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9678 invoked from network); 24 Sep 2003 23:14:03 -0000 Received: from unknown (HELO mail-out3.apple.com) (17.254.13.22) by sources.redhat.com with SMTP; 24 Sep 2003 23:14:03 -0000 Received: from mailgate1.apple.com (a17-128-100-225.apple.com [17.128.100.225]) by mail-out3.apple.com (8.12.10/8.12.9) with ESMTP id h8ONE3mj011782 for ; Wed, 24 Sep 2003 16:14:03 -0700 (PDT) Received: from scv1.apple.com (scv1.apple.com) by mailgate1.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Wed, 24 Sep 2003 16:13:35 -0700 Received: from [17.201.22.240] (inghji.apple.com [17.201.22.240]) by scv1.apple.com (8.12.9/8.12.9) with ESMTP id h8ONDhsH022480 for ; Wed, 24 Sep 2003 16:13:43 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v605) To: gdb-patches@sources.redhat.com Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-7-238699350 From: Jim Ingham Subject: complete command doesn't work for files... Date: Wed, 24 Sep 2003 23:14:00 -0000 X-SW-Source: 2003-09/txt/msg00543.txt.bz2 --Apple-Mail-7-238699350 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 2304 I was looking at this for some other reason (I want to add an "interpreter-complete console" type command), and I noticed that "complete" and the complete_line function that it relies on don't work when the input text is a filename, and contains more that just the filename. You can see this easily, do: (gdb) file /usr/ X11R6 etc info local share bin games kerberos lost+found src dict i386-glibc21-linux lib man tmp doc include libexec sbin (gdb) complete file /usr/ (gdb) That isn't right, you should get: (gdb) complete file /usr/ file /usr/X11R6 file /usr/bin file /usr/dict file /usr/doc file /usr/etc file /usr/games file /usr/i386-glibc21-linux file /usr/include file /usr/info file /usr/kerberos file /usr/lib file /usr/libexec file /usr/local file /usr/lost+found file /usr/man file /usr/sbin file /usr/share file /usr/src file /usr/tmp The attached patch fixes the bug. The case works because readline advances the first argument of complete_line past the initial command. But "complete" always passes both TEXT and LINE_BUFFER as the whole command. This patch actually does what the comment about file completers above it says it intends, namely that we should go to the cursor, and then back up to the first file-wordbreak we find. The old code clearly didn't do that... Both the case and the complete case work now. This also makes emacs behave a little better when you try to complete files. I added a test case for this failure. ChangeLog 2003-09-24 Jim Ingham * completer.c (complete_line): For filename completions, when you look for the last word before the cursor, actually start from the cursor & work backwards, rather than starting from the word you were handed. Starting from the word doesn't work if the input contains more than one word - as it does in the complete command. testsuite/ChangeLog 2003-09-24 Jim Ingham * completion.exp: Test that "complete file ./gdb.base/compl" agrees with the result from sending a tab. --Apple-Mail-7-238699350 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="complete.patch" Content-Disposition: attachment; filename=complete.patch Content-length: 2032 Index: completer.c =================================================================== RCS file: /cvs/src/src/gdb/completer.c,v retrieving revision 1.13 diff -p -r1.13 completer.c *** completer.c 9 Dec 2002 00:59:26 -0000 1.13 --- completer.c 24 Sep 2003 22:50:34 -0000 *************** complete_line (const char *text, char *l *** 584,590 **** { /* See the commentary above about the specifics of file-name completion. */ ! for (p = word; p > tmp_command && strchr (gdb_completer_file_name_break_characters, p[-1]) == NULL; p--) --- 584,590 ---- { /* See the commentary above about the specifics of file-name completion. */ ! for (p = tmp_command + point - 1; p > tmp_command && strchr (gdb_completer_file_name_break_characters, p[-1]) == NULL; p--) Index: testsuite/gdb.base/completion.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/completion.exp,v retrieving revision 1.18 diff -p -r1.18 completion.exp *** testsuite/gdb.base/completion.exp 7 Aug 2003 17:58:44 -0000 1.18 --- testsuite/gdb.base/completion.exp 24 Sep 2003 22:50:36 -0000 *************** gdb_test "cd ${fullsrcdir}" \ *** 647,652 **** --- 647,661 ---- "Working directory [string_to_regexp ${fullsrcdir}].*" \ "cd to \${srcdir}" + send_gdb "complete file ./gdb.base/compl\n" + sleep 1 + gdb_expect { + -re "file ./gdb.base/completion\\.exp.*$gdb_prompt $"\ + { pass "complete-command 'file ./gdb.base/compl'"} + -re ".*$gdb_prompt $" { fail "complete-command 'file ./gdb.base/compl'" } + timeout { fail "(timeout) complete-command 'file ./gdb.base/compl'" } + } + send_gdb "file ./gdb.base/complet\t" sleep 1 gdb_expect { --Apple-Mail-7-238699350 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 103 Jim -- Jim Ingham jingham@apple.com Developer Tools Apple Computer --Apple-Mail-7-238699350--