From: Jim Ingham <jingham@apple.com>
To: gdb-patches@sources.redhat.com
Subject: complete command doesn't work for files...
Date: Wed, 24 Sep 2003 23:14:00 -0000 [thread overview]
Message-ID: <CAC0B9EB-EEE4-11D7-BEC8-00039379E320@apple.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]
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/<TAB><TAB>
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 <TAB><TAB> 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 <TAB> 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 <jingham@apple.com>
* 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 <jingham@apple.com>
* completion.exp: Test that "complete file ./gdb.base/compl"
agrees with the
result from sending a tab.
[-- Attachment #2: complete.patch --]
[-- Type: application/octet-stream, Size: 2032 bytes --]
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 {
[-- Attachment #3: Type: text/plain, Size: 103 bytes --]
Jim
--
Jim Ingham jingham@apple.com
Developer Tools
Apple Computer
next reply other threads:[~2003-09-24 23:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-24 23:14 Jim Ingham [this message]
2003-09-24 23:25 ` Joel Brobecker
2003-09-24 23:30 ` Andrew Cagney
2003-09-25 19:04 ` Jim Ingham
2003-09-25 19:41 ` Andrew Cagney
2003-09-27 4:36 ` Jim Blandy
2004-01-19 16:22 ` Daniel Jacobowitz
2004-01-20 22:19 ` Jim Ingham
2004-02-01 5:51 ` Daniel Jacobowitz
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=CAC0B9EB-EEE4-11D7-BEC8-00039379E320@apple.com \
--to=jingham@apple.com \
--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