From 96a07bee0a27a24ba02657132fbe702f6c7beb5d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 7 May 2006 20:57:26 +0000 Subject: [PATCH] Rename current_global_list to default_completer_list and localize it --- client/client.c | 28 +++++++++++++++++++--------- client/tabcomplete.c | 11 ++--------- client/tabcomplete.h | 6 +++--- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/client/client.c b/client/client.c index 991bc06..b2d50c4 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,10 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.308 2006-05-07 19:43:00 adam Exp $ + * $Id: client.c,v 1.309 2006-05-07 20:57:26 adam Exp $ + */ +/** \file client.c + * \brief yaz-client program */ #include @@ -173,7 +176,6 @@ void process_cmd_line(char* line); char **readline_completer(char *text, int start, int end); #endif static char *command_generator(const char *text, int state); -char** current_global_list = NULL; int cmd_register_tab(const char* arg); static void close_session (void); @@ -4555,6 +4557,15 @@ static char *command_generator(const char *text, int state) } #if HAVE_READLINE_READLINE_H +static char** default_completer_list = NULL; + +static char* default_completer(const char* text, int state) +{ + return complete_from_list(default_completer_list, text, state); +} +#endif + +#if HAVE_READLINE_READLINE_H /* This function only known how to complete on the first word @@ -4580,18 +4591,17 @@ char **readline_completer(char *text, int start, int end) return NULL; } - for (i = 0; cmd_array[i].cmd; i++) { - if (!strncmp(cmd_array[i].cmd, word, strlen(word))) { + for (i = 0; cmd_array[i].cmd; i++) + if (!strncmp(cmd_array[i].cmd, word, strlen(word))) break; - } - } - if(!cmd_array[i].cmd) return NULL; + if(!cmd_array[i].cmd) + return NULL; - current_global_list = cmd_array[i].local_tabcompletes; + default_completer_list = cmd_array[i].local_tabcompletes; completerToUse = cmd_array[i].rl_completerfunction; - if (completerToUse==NULL) + if (!completerToUse) { /* if command completer is not defined use the default completer */ completerToUse = default_completer; } diff --git a/client/tabcomplete.c b/client/tabcomplete.c index 870188a..28faedf 100644 --- a/client/tabcomplete.c +++ b/client/tabcomplete.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: tabcomplete.c,v 1.15 2006-05-07 19:43:00 adam Exp $ + * $Id: tabcomplete.c,v 1.16 2006-05-07 20:57:26 adam Exp $ */ #include @@ -12,15 +12,13 @@ #include #include "tabcomplete.h" -extern char** current_global_list; - /* *************************************************************************** * * generic completer * * ***************************************************************************/ -char* complete_from_list(char* completions[], const char *text, int state) +char *complete_from_list(char* completions[], const char *text, int state) { #if HAVE_READLINE_READLINE_H static int idx; @@ -142,11 +140,6 @@ char* complete_attributeset(const char* text, int state) } -char* default_completer(const char* text, int state) -{ - return complete_from_list(current_global_list, text, state); -} - /* * Local variables: * c-basic-offset: 4 diff --git a/client/tabcomplete.h b/client/tabcomplete.h index aff7707..62ba0e6 100644 --- a/client/tabcomplete.h +++ b/client/tabcomplete.h @@ -1,8 +1,8 @@ /* - * Copyright (C) 1995-2005, Index Data ApS + * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: tabcomplete.h,v 1.6 2005-06-25 15:46:01 adam Exp $ + * $Id: tabcomplete.h,v 1.7 2006-05-07 20:57:26 adam Exp $ */ /* @@ -13,8 +13,8 @@ char* complete_querytype(const char* text, int state); char* complete_format(const char* text, int state); char* complete_schema(const char* text, int state); char* complete_attributeset(const char* text, int state); -char* default_completer(const char* text, int state); char* complete_auto_reconnect(const char *text, int state); +char *complete_from_list(char* completions[], const char *text, int state); /* * Local variables: * c-basic-offset: 4 -- 1.7.10.4