aboutsummaryrefslogtreecommitdiff
path: root/gdb/main.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-06-14 19:23:37 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-06-14 19:23:37 +0000
commitbd50d1b077d0089f23c1957e5fbe754ad4ed9c03 (patch)
treeca0b30a6a197f5da374a44197253139a43d702bd /gdb/main.c
parent75217b369eaa9cc748a75831156e015dc3c57488 (diff)
downloadgdb-bd50d1b077d0089f23c1957e5fbe754ad4ed9c03.zip
gdb-bd50d1b077d0089f23c1957e5fbe754ad4ed9c03.tar.gz
gdb-bd50d1b077d0089f23c1957e5fbe754ad4ed9c03.tar.bz2
* main.c, gdbcmd.h: Add function filename_completer.
source.c: Use it for "directory" command. (But '/' is a word break, limiting usefulness; see comments). * source.c (mod_path): Warning not error if can't find directory.
Diffstat (limited to 'gdb/main.c')
-rw-r--r--gdb/main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/main.c b/gdb/main.c
index cccf669..e1758a3 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1148,6 +1148,48 @@ noop_completer (text)
return NULL;
}
+/* Complete on filenames. */
+/* FIXME: This would be a lot more useful if the word breaks got set
+ to not include '/'. Probably best to make it up to each completer
+ to do its own word breaking. */
+char **
+filename_completer (text)
+ char *text;
+{
+ /* From readline. */
+ extern char *filename_completion_function ();
+ int subsequent_name;
+ char **return_val;
+ int return_val_used;
+ int return_val_alloced;
+
+ return_val_used = 0;
+ /* Small for testing. */
+ return_val_alloced = 1;
+ return_val = (char **) xmalloc (return_val_alloced * sizeof (char *));
+
+ subsequent_name = 0;
+ while (1)
+ {
+ char *p;
+ p = filename_completion_function (text, subsequent_name);
+ if (return_val_used >= return_val_alloced)
+ {
+ return_val_alloced *= 2;
+ return_val =
+ (char **) xrealloc (return_val,
+ return_val_alloced * sizeof (char *));
+ }
+ /* The string itself has already been stored in newly malloc'd space
+ for us by filename_completion_function. */
+ return_val[return_val_used++] = p;
+ if (p == NULL)
+ break;
+ subsequent_name = 1;
+ }
+ return return_val;
+}
+
/* Generate symbol names one by one for the completer. Each time we are
called return another potential completion to the caller.
@@ -1200,6 +1242,11 @@ symbol_completion_function (text, matches)
special word break set for command strings, which leaves out the
'-' character used in some commands. */
+ /* FIXME: Using rl_completer_word_break_characters is the wrong
+ approach, because "show foo-bar<TAB>" won't know to use the
+ new set until too late. Better approach is to do the word breaking
+ ourself. */
+
rl_completer_word_break_characters =
gdb_completer_word_break_characters;