From bd50d1b077d0089f23c1957e5fbe754ad4ed9c03 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Mon, 14 Jun 1993 19:23:37 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 6 ++++++ gdb/main.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9a6cda287af..4b6b14f4d4e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ Mon Jun 14 09:23:51 1993 Jim Kingdon (kingdon@cygnus.com) + * main.c, gdbcmd.h: Add function filename_completer. + source.c: Use it for "directory" command. + (This will be more useful if the word break stuff is fixed). + + * source.c (mod_path): Warning not error if can't find directory. + * isi-xdep.c: New file. * config/m68k/isi.mh (XDEPFILES): Add isi-xdep.o diff --git a/gdb/main.c b/gdb/main.c index cccf6697cc5..e1758a3e422 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" 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; -- 2.30.2