X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=client%2Fclient.c;h=b2d50c451bd94da5543a52b9e3d39d29bec261f2;hb=821e247a6d064e29703c74b21f755baaf4cc1e6e;hp=ffb1b3184729faa089d5417b60838e94b2ff6e0d;hpb=310bcbad07ab48568d6f82176241ba304192a43d;p=yaz-moved-to-github.git diff --git a/client/client.c b/client/client.c index ffb1b31..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.306 2006-05-07 19:13:55 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** curret_global_list=NULL; int cmd_register_tab(const char* arg); static void close_session (void); @@ -4539,6 +4541,7 @@ void process_cmd_line(char* line) static char *command_generator(const char *text, int state) { +#if HAVE_READLINE_READLINE_H static int idx; if (state==0) { idx = 0; @@ -4549,10 +4552,20 @@ static char *command_generator(const char *text, int state) return strdup(cmd_array[idx-1].cmd); } } +#endif return NULL; } #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 @@ -4578,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; - curret_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; }