[BACK]Return to readline.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libedit

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libedit/readline.c between version 1.18 and 1.31

version 1.18, 2001/01/05 22:45:30 version 1.31, 2003/06/19 16:04:57
Line 36 
Line 36 
  * POSSIBILITY OF SUCH DAMAGE.   * POSSIBILITY OF SUCH DAMAGE.
  */   */
   
 #include <sys/cdefs.h>  #include "config.h"
 #if !defined(lint) && !defined(SCCSID)  #if !defined(lint) && !defined(SCCSID)
 __RCSID("$NetBSD$");  __RCSID("$NetBSD$");
 #endif /* not lint && not SCCSID */  #endif /* not lint && not SCCSID */
Line 51  __RCSID("$NetBSD$");
Line 51  __RCSID("$NetBSD$");
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  #include <unistd.h>
 #include <limits.h>  #include <limits.h>
   #ifdef HAVE_ALLOCA_H
   #include <alloca.h>
   #endif
 #include "histedit.h"  #include "histedit.h"
 #include "readline/readline.h"  #include "readline/readline.h"
 #include "sys.h"  
 #include "el.h"  #include "el.h"
 #include "fcns.h"               /* for EL_NUM_FCNS */  #include "fcns.h"               /* for EL_NUM_FCNS */
   
Line 66  __RCSID("$NetBSD$");
Line 68  __RCSID("$NetBSD$");
 /* readline compatibility stuff - look at readline sources/documentation */  /* readline compatibility stuff - look at readline sources/documentation */
 /* to see what these variables mean */  /* to see what these variables mean */
 const char *rl_library_version = "EditLine wrapper";  const char *rl_library_version = "EditLine wrapper";
 char *rl_readline_name = "";  static char empty[] = { '\0' };
   static char expand_chars[] = { ' ', '\t', '\n', '=', '(', '\0' };
   static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
       '>', '<', '=', ';', '|', '&', '{', '(', '\0' };
   char *rl_readline_name = empty;
 FILE *rl_instream = NULL;  FILE *rl_instream = NULL;
 FILE *rl_outstream = NULL;  FILE *rl_outstream = NULL;
 int rl_point = 0;  int rl_point = 0;
Line 78  int history_length = 0;
Line 84  int history_length = 0;
 int max_input_history = 0;  int max_input_history = 0;
 char history_expansion_char = '!';  char history_expansion_char = '!';
 char history_subst_char = '^';  char history_subst_char = '^';
 char *history_no_expand_chars = " \t\n=(";  char *history_no_expand_chars = expand_chars;
 Function *history_inhibit_expansion_function = NULL;  Function *history_inhibit_expansion_function = NULL;
   
 int rl_inhibit_completion = 0;  int rl_inhibit_completion = 0;
 int rl_attempted_completion_over = 0;  int rl_attempted_completion_over = 0;
 char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(";  char *rl_basic_word_break_characters = break_chars;
 char *rl_completer_word_break_characters = NULL;  char *rl_completer_word_break_characters = NULL;
 char *rl_completer_quote_characters = NULL;  char *rl_completer_quote_characters = NULL;
 CPFunction *rl_completion_entry_function = NULL;  CPFunction *rl_completion_entry_function = NULL;
Line 143  static char *el_rl_prompt = NULL;
Line 149  static char *el_rl_prompt = NULL;
   
 /* ARGSUSED */  /* ARGSUSED */
 static char *  static char *
 _get_prompt(EditLine *el)  _get_prompt(EditLine *el __attribute__((__unused__)))
 {  {
         return (el_rl_prompt);          return (el_rl_prompt);
 }  }
Line 216  rl_initialize(void)
Line 222  rl_initialize(void)
   
         /* for proper prompt printing in readline() */          /* for proper prompt printing in readline() */
         el_rl_prompt = strdup("");          el_rl_prompt = strdup("");
           if (el_rl_prompt == NULL) {
                   history_end(h);
                   el_end(e);
                   return -1;
           }
         el_set(e, EL_PROMPT, _get_prompt);          el_set(e, EL_PROMPT, _get_prompt);
         el_set(e, EL_SIGNAL, 1);          el_set(e, EL_SIGNAL, 1);
   
Line 251  rl_initialize(void)
Line 262  rl_initialize(void)
          * and rl_line_buffer directly.           * and rl_line_buffer directly.
          */           */
         li = el_line(e);          li = el_line(e);
         /* LINTED const cast */          /* a cheesy way to get rid of const cast. */
         rl_line_buffer = (char *) li->buffer;          rl_line_buffer = memchr(li->buffer, *li->buffer, 1);
         rl_point = rl_end = 0;          rl_point = rl_end = 0;
   
         return (0);          return (0);
Line 269  readline(const char *prompt)
Line 280  readline(const char *prompt)
         HistEvent ev;          HistEvent ev;
         int count;          int count;
         const char *ret;          const char *ret;
           char *buf;
   
         if (e == NULL || h == NULL)          if (e == NULL || h == NULL)
                 rl_initialize();                  rl_initialize();
Line 279  readline(const char *prompt)
Line 291  readline(const char *prompt)
         if (strcmp(el_rl_prompt, prompt) != 0) {          if (strcmp(el_rl_prompt, prompt) != 0) {
                 free(el_rl_prompt);                  free(el_rl_prompt);
                 el_rl_prompt = strdup(prompt);                  el_rl_prompt = strdup(prompt);
                   if (el_rl_prompt == NULL)
                           return NULL;
         }          }
         /* get one line from input stream */          /* get one line from input stream */
         ret = el_gets(e, &count);          ret = el_gets(e, &count);
   
         if (ret && count > 0) {          if (ret && count > 0) {
                 char *foo;  
                 int lastidx;                  int lastidx;
   
                 foo = strdup(ret);                  buf = strdup(ret);
                   if (buf == NULL)
                           return NULL;
                 lastidx = count - 1;                  lastidx = count - 1;
                 if (foo[lastidx] == '\n')                  if (buf[lastidx] == '\n')
                         foo[lastidx] = '\0';                          buf[lastidx] = '\0';
   
                 ret = foo;  
         } else          } else
                 ret = NULL;                  buf = NULL;
   
         history(h, &ev, H_GETSIZE);          history(h, &ev, H_GETSIZE);
         history_length = ev.num;          history_length = ev.num;
   
         /* LINTED const cast */          return buf;
         return (char *) ret;  
 }  }
   
 /*  /*
Line 321  using_history(void)
Line 333  using_history(void)
   
 /*  /*
  * substitute ``what'' with ``with'', returning resulting string; if   * substitute ``what'' with ``with'', returning resulting string; if
  * globally == 1, substitutes all occurences of what, otherwise only the   * globally == 1, substitutes all occurrences of what, otherwise only the
  * first one   * first one
  */   */
 static char *  static char *
Line 330  _rl_compat_sub(const char *str, const ch
Line 342  _rl_compat_sub(const char *str, const ch
 {  {
         char *result;          char *result;
         const char *temp, *new;          const char *temp, *new;
         int len, with_len, what_len, add;          size_t len, with_len, what_len, add;
         size_t size, i;          size_t size, i;
   
         result = malloc((size = 16));          result = malloc((size = 16));
           if (result == NULL)
                   return NULL;
         temp = str;          temp = str;
         with_len = strlen(with);          with_len = strlen(with);
         what_len = strlen(what);          what_len = strlen(what);
Line 344  _rl_compat_sub(const char *str, const ch
Line 358  _rl_compat_sub(const char *str, const ch
                         i = new - temp;                          i = new - temp;
                         add = i + with_len;                          add = i + with_len;
                         if (i + add + 1 >= size) {                          if (i + add + 1 >= size) {
                                   char *nresult;
                                 size += add + 1;                                  size += add + 1;
                                 result = realloc(result, size);                                  nresult = realloc(result, size);
                                   if (nresult == NULL) {
                                           free(result);
                                           return NULL;
                                   }
                                   result = nresult;
                         }                          }
                         (void) strncpy(&result[len], temp, i);                          (void) strncpy(&result[len], temp, i);
                         len += i;                          len += i;
Line 355  _rl_compat_sub(const char *str, const ch
Line 375  _rl_compat_sub(const char *str, const ch
                 } else {                  } else {
                         add = strlen(temp);                          add = strlen(temp);
                         if (len + add + 1 >= size) {                          if (len + add + 1 >= size) {
                                   char *nresult;
                                 size += add + 1;                                  size += add + 1;
                                 result = realloc(result, size);                                  nresult = realloc(result, size);
                                   if (nresult == NULL) {
                                           free(result);
                                           return NULL;
                                   }
                                   result = nresult;
                         }                          }
                         (void) strcpy(&result[len], temp);      /* safe */                          (void) strcpy(&result[len], temp);      /* safe */
                         len += add;                          len += add;
Line 499  _history_expand_command(const char *comm
Line 525  _history_expand_command(const char *comm
                 cmd++;                  cmd++;
   
         line = strdup(event_data);          line = strdup(event_data);
           if (line == NULL)
                   return 0;
         for (; *cmd; cmd++) {          for (; *cmd; cmd++) {
                 if (*cmd == ':')                  if (*cmd == ':')
                         continue;                          continue;
Line 516  _history_expand_command(const char *comm
Line 544  _history_expand_command(const char *comm
                         g_on = 2;                          g_on = 2;
                 else if (*cmd == 's' || *cmd == '&') {                  else if (*cmd == 's' || *cmd == '&') {
                         char *what, *with, delim;                          char *what, *with, delim;
                         int len, from_len;                          size_t len, from_len;
                         size_t size;                          size_t size;
   
                         if (*cmd == '&' && (from == NULL || to == NULL))                          if (*cmd == '&' && (from == NULL || to == NULL))
Line 525  _history_expand_command(const char *comm
Line 553  _history_expand_command(const char *comm
                                 delim = *(++cmd), cmd++;                                  delim = *(++cmd), cmd++;
                                 size = 16;                                  size = 16;
                                 what = realloc(from, size);                                  what = realloc(from, size);
                                   if (what == NULL) {
                                           free(from);
                                           return 0;
                                   }
                                 len = 0;                                  len = 0;
                                 for (; *cmd && *cmd != delim; cmd++) {                                  for (; *cmd && *cmd != delim; cmd++) {
                                         if (*cmd == '\\'                                          if (*cmd == '\\'
                                             && *(cmd + 1) == delim)                                              && *(cmd + 1) == delim)
                                                 cmd++;                                                  cmd++;
                                         if (len >= size)                                          if (len >= size) {
                                                 what = realloc(what,                                                  char *nwhat;
                                                   nwhat = realloc(what,
                                                     (size <<= 1));                                                      (size <<= 1));
                                                   if (nwhat == NULL) {
                                                           free(what);
                                                           return 0;
                                                   }
                                                   what = nwhat;
                                           }
                                         what[len++] = *cmd;                                          what[len++] = *cmd;
                                 }                                  }
                                 what[len] = '\0';                                  what[len] = '\0';
                                 from = what;                                  from = what;
                                 if (*what == '\0') {                                  if (*what == '\0') {
                                         free(what);                                          free(what);
                                         if (search)                                          if (search) {
                                                 from = strdup(search);                                                  from = strdup(search);
                                         else {                                                  if (from == NULL)
                                                           return 0;
                                           } else {
                                                 from = NULL;                                                  from = NULL;
                                                 return (-1);                                                  return (-1);
                                         }                                          }
Line 552  _history_expand_command(const char *comm
Line 593  _history_expand_command(const char *comm
   
                                 size = 16;                                  size = 16;
                                 with = realloc(to, size);                                  with = realloc(to, size);
                                   if (with == NULL) {
                                           free(to);
                                           return -1;
                                   }
                                 len = 0;                                  len = 0;
                                 from_len = strlen(from);                                  from_len = strlen(from);
                                 for (; *cmd && *cmd != delim; cmd++) {                                  for (; *cmd && *cmd != delim; cmd++) {
                                         if (len + from_len + 1 >= size) {                                          if (len + from_len + 1 >= size) {
                                                   char *nwith;
                                                 size += from_len + 1;                                                  size += from_len + 1;
                                                 with = realloc(with, size);                                                  nwith = realloc(with, size);
                                                   if (nwith == NULL) {
                                                           free(with);
                                                           return -1;
                                                   }
                                                   with = nwith;
                                         }                                          }
                                         if (*cmd == '&') {                                          if (*cmd == '&') {
                                                 /* safe */                                                  /* safe */
Line 576  _history_expand_command(const char *comm
Line 627  _history_expand_command(const char *comm
   
                                 tempcmd = _rl_compat_sub(line, from, to,                                  tempcmd = _rl_compat_sub(line, from, to,
                                     (g_on) ? 1 : 0);                                      (g_on) ? 1 : 0);
                                 free(line);                                  if (tempcmd) {
                                 line = tempcmd;                                          free(line);
                                           line = tempcmd;
                                   }
                                 g_on = 0;                                  g_on = 0;
                         }                          }
                 }                  }
Line 623  _history_expand_command(const char *comm
Line 676  _history_expand_command(const char *comm
         }          }
   
         cmdsize = 1, cmdlen = 0;          cmdsize = 1, cmdlen = 0;
         tempcmd = malloc(cmdsize);          if ((tempcmd = malloc(cmdsize)) == NULL)
                   return 0;
         for (i = start; start <= i && i <= end; i++) {          for (i = start; start <= i && i <= end; i++) {
                 int arr_len;                  int arr_len;
   
                 arr_len = strlen(arr[i]);                  arr_len = strlen(arr[i]);
                 if (cmdlen + arr_len + 1 >= cmdsize) {                  if (cmdlen + arr_len + 1 >= cmdsize) {
                           char *ntempcmd;
                         cmdsize += arr_len + 1;                          cmdsize += arr_len + 1;
                         tempcmd = realloc(tempcmd, cmdsize);                          ntempcmd = realloc(tempcmd, cmdsize);
                           if (ntempcmd == NULL) {
                                   free(tempcmd);
                                   return 0;
                           }
                           tempcmd = ntempcmd;
                 }                  }
                 (void) strcpy(&tempcmd[cmdlen], arr[i]);        /* safe */                  (void) strcpy(&tempcmd[cmdlen], arr[i]);        /* safe */
                 cmdlen += arr_len;                  cmdlen += arr_len;
Line 663  history_expand(char *str, char **output)
Line 723  history_expand(char *str, char **output)
                 rl_initialize();                  rl_initialize();
   
         *output = strdup(str);  /* do it early */          *output = strdup(str);  /* do it early */
           if (*output == NULL)
                   return 0;
   
         if (str[0] == history_subst_char) {          if (str[0] == history_subst_char) {
                 /* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */                  /* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */
Line 675  history_expand(char *str, char **output)
Line 737  history_expand(char *str, char **output)
         }          }
 #define ADD_STRING(what, len)                                           \  #define ADD_STRING(what, len)                                           \
         {                                                               \          {                                                               \
                 if (idx + len + 1 > size)                               \                  if (idx + len + 1 > size) {                             \
                         result = realloc(result, (size += len + 1));    \                          char *nresult = realloc(result, (size += len + 1));\
                           if (nresult == NULL) {                          \
                                   free(*output);                          \
                                   return 0;                               \
                           }                                               \
                           result = nresult;                               \
                   }                                                       \
                 (void)strncpy(&result[idx], what, len);                 \                  (void)strncpy(&result[idx], what, len);                 \
                 idx += len;                                             \                  idx += len;                                             \
                 result[idx] = '\0';                                     \                  result[idx] = '\0';                                     \
Line 790  history_tokenize(const char *str)
Line 858  history_tokenize(const char *str)
                 }                  }
   
                 if (result_idx + 2 >= size) {                  if (result_idx + 2 >= size) {
                           char **nresult;
                         size <<= 1;                          size <<= 1;
                         result = realloc(result, size * sizeof(char *));                          nresult = realloc(result, size * sizeof(char *));
                           if (nresult == NULL) {
                                   free(result);
                                   return NULL;
                           }
                           result = nresult;
                 }                  }
                 len = i - start;                  len = i - start;
                 temp = malloc(len + 1);                  temp = malloc(len + 1);
                   if (temp == NULL) {
                           free(result);
                           return NULL;
                   }
                 (void) strncpy(temp, &str[start], len);                  (void) strncpy(temp, &str[start], len);
                 temp[len] = '\0';                  temp[len] = '\0';
                 result[result_idx++] = temp;                  result[result_idx++] = temp;
Line 1107  history_search_prefix(const char *str, i
Line 1185  history_search_prefix(const char *str, i
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 history_search_pos(const char *str, int direction, int pos)  history_search_pos(const char *str,
                      int direction __attribute__((__unused__)), int pos)
 {  {
         HistEvent ev;          HistEvent ev;
         int curr_num, off;          int curr_num, off;
Line 1158  tilde_expand(char *txt)
Line 1237  tilde_expand(char *txt)
                 return (strdup(txt));                  return (strdup(txt));
   
         temp = strchr(txt + 1, '/');          temp = strchr(txt + 1, '/');
         if (temp == NULL)          if (temp == NULL) {
                 temp = strdup(txt + 1);                  temp = strdup(txt + 1);
         else {                  if (temp == NULL)
                           return NULL;
           } else {
                 len = temp - txt + 1;   /* text until string after slash */                  len = temp - txt + 1;   /* text until string after slash */
                 temp = malloc(len);                  temp = malloc(len);
                   if (temp == NULL)
                           return NULL;
                 (void) strncpy(temp, txt + 1, len - 2);                  (void) strncpy(temp, txt + 1, len - 2);
                 temp[len - 2] = '\0';                  temp[len - 2] = '\0';
         }          }
Line 1176  tilde_expand(char *txt)
Line 1259  tilde_expand(char *txt)
         txt += len;          txt += len;
   
         temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);          temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
           if (temp == NULL)
                   return NULL;
         (void) sprintf(temp, "%s/%s", pass->pw_dir, txt);          (void) sprintf(temp, "%s/%s", pass->pw_dir, txt);
   
         return (temp);          return (temp);
Line 1200  filename_completion_function(const char 
Line 1285  filename_completion_function(const char 
         size_t len;          size_t len;
   
         if (state == 0 || dir == NULL) {          if (state == 0 || dir == NULL) {
                 if (dir != NULL) {  
                         closedir(dir);  
                         dir = NULL;  
                 }  
                 temp = strrchr(text, '/');                  temp = strrchr(text, '/');
                 if (temp) {                  if (temp) {
                           char *nptr;
                         temp++;                          temp++;
                         filename = realloc(filename, strlen(temp) + 1);                          nptr = realloc(filename, strlen(temp) + 1);
                           if (nptr == NULL) {
                                   free(filename);
                                   return NULL;
                           }
                           filename = nptr;
                         (void) strcpy(filename, temp);                          (void) strcpy(filename, temp);
                         len = temp - text;      /* including last slash */                          len = temp - text;      /* including last slash */
                         dirname = realloc(dirname, len + 1);                          nptr = realloc(dirname, len + 1);
                           if (nptr == NULL) {
                                   free(filename);
                                   return NULL;
                           }
                           dirname = nptr;
                         (void) strncpy(dirname, text, len);                          (void) strncpy(dirname, text, len);
                         dirname[len] = '\0';                          dirname[len] = '\0';
                 } else {                  } else {
                         filename = strdup(text);                          filename = strdup(text);
                           if (filename == NULL)
                                   return NULL;
                         dirname = NULL;                          dirname = NULL;
                 }                  }
   
                 /* support for ``~user'' syntax */                  /* support for ``~user'' syntax */
                 if (dirname && *dirname == '~') {                  if (dirname && *dirname == '~') {
                           char *nptr;
                         temp = tilde_expand(dirname);                          temp = tilde_expand(dirname);
                         dirname = realloc(dirname, strlen(temp) + 1);                          if (temp == NULL)
                                   return NULL;
                           nptr = realloc(dirname, strlen(temp) + 1);
                           if (nptr == NULL) {
                                   free(dirname);
                                   return NULL;
                           }
                           dirname = nptr;
                         (void) strcpy(dirname, temp);   /* safe */                          (void) strcpy(dirname, temp);   /* safe */
                         free(temp);     /* no longer needed */                          free(temp);     /* no longer needed */
                 }                  }
Line 1230  filename_completion_function(const char 
Line 1332  filename_completion_function(const char 
                 if (filename_len == 0)                  if (filename_len == 0)
                         return (NULL);  /* no expansion possible */                          return (NULL);  /* no expansion possible */
   
                   if (dir != NULL) {
                           (void)closedir(dir);
                           dir = NULL;
                   }
                 dir = opendir(dirname ? dirname : ".");                  dir = opendir(dirname ? dirname : ".");
                 if (!dir)                  if (!dir)
                         return (NULL);  /* cannot open the directory */                          return (NULL);  /* cannot open the directory */
Line 1259  filename_completion_function(const char 
Line 1365  filename_completion_function(const char 
 #endif  #endif
                     ((dirname) ? strlen(dirname) : 0) + 1 + 1;                      ((dirname) ? strlen(dirname) : 0) + 1 + 1;
                 temp = malloc(len);                  temp = malloc(len);
                   if (temp == NULL)
                           return NULL;
                 (void) sprintf(temp, "%s%s",                  (void) sprintf(temp, "%s%s",
                     dirname ? dirname : "", entry->d_name);     /* safe */                      dirname ? dirname : "", entry->d_name);     /* safe */
   
                 /* test, if it's directory */                  /* test, if it's directory */
                 if (stat(temp, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))                  if (stat(temp, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
                         strcat(temp, "/");      /* safe */                          strcat(temp, "/");      /* safe */
         } else          } else {
                   (void)closedir(dir);
                   dir = NULL;
                 temp = NULL;                  temp = NULL;
           }
   
         return (temp);          return (temp);
 }  }
Line 1309  username_completion_function(const char 
Line 1420  username_completion_function(const char 
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 static unsigned char  static unsigned char
 _el_rl_complete(EditLine *el, int ch)  _el_rl_complete(EditLine *el __attribute__((__unused__)), int ch)
 {  {
         return (unsigned char) rl_complete(0, ch);          return (unsigned char) rl_complete(0, ch);
 }  }
Line 1323  completion_matches(const char *text, CPF
Line 1434  completion_matches(const char *text, CPF
 {  {
         char **match_list = NULL, *retstr, *prevstr;          char **match_list = NULL, *retstr, *prevstr;
         size_t match_list_len, max_equal, which, i;          size_t match_list_len, max_equal, which, i;
         int matches;          size_t matches;
   
         if (h == NULL || e == NULL)          if (h == NULL || e == NULL)
                 rl_initialize();                  rl_initialize();
   
         matches = 0;          matches = 0;
         match_list_len = 1;          match_list_len = 1;
         while ((retstr = (*genfunc) (text, matches)) != NULL) {          while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
                 if (matches + 1 >= match_list_len) {                  /* allow for list terminator here */
                         match_list_len <<= 1;                  if (matches + 3 >= match_list_len) {
                         match_list = realloc(match_list,                          char **nmatch_list;
                           while (matches + 3 >= match_list_len)
                                   match_list_len <<= 1;
                           nmatch_list = realloc(match_list,
                             match_list_len * sizeof(char *));                              match_list_len * sizeof(char *));
                           if (nmatch_list == NULL) {
                                   free(match_list);
                                   return NULL;
                           }
                           match_list = nmatch_list;
   
                 }                  }
                 match_list[++matches] = retstr;                  match_list[++matches] = retstr;
         }          }
   
         if (!match_list)          if (!match_list)
                 return (char **) NULL;  /* nothing found */                  return NULL;    /* nothing found */
   
         /* find least denominator and insert it to match_list[0] */          /* find least denominator and insert it to match_list[0] */
         which = 2;          which = 2;
Line 1354  completion_matches(const char *text, CPF
Line 1474  completion_matches(const char *text, CPF
         }          }
   
         retstr = malloc(max_equal + 1);          retstr = malloc(max_equal + 1);
           if (retstr == NULL) {
                   free(match_list);
                   return NULL;
           }
         (void) strncpy(retstr, match_list[1], max_equal);          (void) strncpy(retstr, match_list[1], max_equal);
         retstr[max_equal] = '\0';          retstr[max_equal] = '\0';
         match_list[0] = retstr;          match_list[0] = retstr;
   
         /* add NULL as last pointer to the array */          /* add NULL as last pointer to the array */
         if (matches + 1 >= match_list_len)  
                 match_list = realloc(match_list,  
                     (match_list_len + 1) * sizeof(char *));  
         match_list[matches + 1] = (char *) NULL;          match_list[matches + 1] = (char *) NULL;
   
         return (match_list);          return (match_list);
Line 1374  static int
Line 1495  static int
 _rl_qsort_string_compare(i1, i2)  _rl_qsort_string_compare(i1, i2)
         const void *i1, *i2;          const void *i1, *i2;
 {  {
         /*LINTED const castaway*/          const char *s1 = ((const char * const *)i1)[0];
         const char *s1 = ((const char **)i1)[0];          const char *s2 = ((const char * const *)i2)[0];
         /*LINTED const castaway*/  
         const char *s2 = ((const char **)i2)[0];  
   
         return strcasecmp(s1, s2);          return strcasecmp(s1, s2);
 }  }
Line 1542  rl_complete_internal(int what_to_do)
Line 1661  rl_complete_internal(int what_to_do)
                                 rl_display_match_list(matches, matches_num,                                  rl_display_match_list(matches, matches_num,
                                         maxlen);                                          maxlen);
                         retval = CC_REDISPLAY;                          retval = CC_REDISPLAY;
                   } else if (matches[0][0]) {
                           /*
                            * There was some common match, but the name was
                            * not complete enough. Next tab will print possible
                            * completions.
                            */
                           el_beep(e);
                 } else {                  } else {
                         /* lcd is not a valid object - further specification */                          /* lcd is not a valid object - further specification */
                         /* is needed */                          /* is needed */
Line 1626  rl_read_key(void)
Line 1752  rl_read_key(void)
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 void  void
 rl_reset_terminal(const char *p)  rl_reset_terminal(const char *p __attribute__((__unused__)))
 {  {
   
         if (h == NULL || e == NULL)          if (h == NULL || e == NULL)

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.31

CVSweb <webmaster@jp.NetBSD.org>