[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.56 and 1.62

version 1.56, 2005/06/10 20:21:00 version 1.62, 2006/03/18 09:15:57
Line 160  static Function *map[256];
Line 160  static Function *map[256];
 static unsigned char     _el_rl_complete(EditLine *, int);  static unsigned char     _el_rl_complete(EditLine *, int);
 static unsigned char     _el_rl_tstp(EditLine *, int);  static unsigned char     _el_rl_tstp(EditLine *, int);
 static char             *_get_prompt(EditLine *);  static char             *_get_prompt(EditLine *);
   static int               _getc_function(EditLine *, char *);
 static HIST_ENTRY       *_move_history(int);  static HIST_ENTRY       *_move_history(int);
 static int               _history_expand_command(const char *, size_t, size_t,  static int               _history_expand_command(const char *, size_t, size_t,
     char **);      char **);
Line 198  _move_history(int op)
Line 199  _move_history(int op)
   
   
 /*  /*
    * read one key from user defined input function
    */
   static int
   /*ARGSUSED*/
   _getc_function(EditLine *el, char *c)
   {
           int i;
   
           i = (*rl_getc_function)(NULL, 0);
           if (i == -1)
                   return 0;
           *c = i;
           return 1;
   }
   
   
   /*
  * READLINE compatibility stuff   * READLINE compatibility stuff
  */   */
   
Line 242  rl_initialize(void)
Line 260  rl_initialize(void)
         max_input_history = INT_MAX;          max_input_history = INT_MAX;
         el_set(e, EL_HIST, history, h);          el_set(e, EL_HIST, history, h);
   
           /* setup getc function if valid */
           if (rl_getc_function)
                   el_set(e, EL_GETCFN, _getc_function);
   
         /* for proper prompt printing in readline() */          /* for proper prompt printing in readline() */
         rl_prompt = strdup("");          rl_prompt = strdup("");
         if (rl_prompt == NULL) {          if (rl_prompt == NULL) {
Line 706  _history_expand_command(const char *comm
Line 728  _history_expand_command(const char *comm
                                 what = realloc(from, size);                                  what = realloc(from, size);
                                 if (what == NULL) {                                  if (what == NULL) {
                                         free(from);                                          free(from);
                                           free(tmp);
                                         return 0;                                          return 0;
                                 }                                  }
                                 len = 0;                                  len = 0;
Line 718  _history_expand_command(const char *comm
Line 741  _history_expand_command(const char *comm
                                                                 (size <<= 1));                                                                  (size <<= 1));
                                                 if (nwhat == NULL) {                                                  if (nwhat == NULL) {
                                                         free(what);                                                          free(what);
                                                           free(tmp);
                                                         return 0;                                                          return 0;
                                                 }                                                  }
                                                 what = nwhat;                                                  what = nwhat;
Line 730  _history_expand_command(const char *comm
Line 754  _history_expand_command(const char *comm
                                         free(what);                                          free(what);
                                         if (search) {                                          if (search) {
                                                 from = strdup(search);                                                  from = strdup(search);
                                                 if (from == NULL)                                                  if (from == NULL) {
                                                           free(tmp);
                                                         return 0;                                                          return 0;
                                                   }
                                         } else {                                          } else {
                                                 from = NULL;                                                  from = NULL;
                                                   free(tmp);
                                                 return (-1);                                                  return (-1);
                                         }                                          }
                                 }                                  }
Line 745  _history_expand_command(const char *comm
Line 772  _history_expand_command(const char *comm
                                 with = realloc(to, size);                                  with = realloc(to, size);
                                 if (with == NULL) {                                  if (with == NULL) {
                                         free(to);                                          free(to);
                                           free(tmp);
                                         return -1;                                          return -1;
                                 }                                  }
                                 len = 0;                                  len = 0;
Line 756  _history_expand_command(const char *comm
Line 784  _history_expand_command(const char *comm
                                                 nwith = realloc(with, size);                                                  nwith = realloc(with, size);
                                                 if (nwith == NULL) {                                                  if (nwith == NULL) {
                                                         free(with);                                                          free(with);
                                                           free(tmp);
                                                         return -1;                                                          return -1;
                                                 }                                                  }
                                                 with = nwith;                                                  with = nwith;
Line 1083  read_history(const char *filename)
Line 1112  read_history(const char *filename)
   
         if (h == NULL || e == NULL)          if (h == NULL || e == NULL)
                 rl_initialize();                  rl_initialize();
         return (history(h, &ev, H_LOAD, filename));          return (history(h, &ev, H_LOAD, filename) == -1);
 }  }
   
   
Line 1097  write_history(const char *filename)
Line 1126  write_history(const char *filename)
   
         if (h == NULL || e == NULL)          if (h == NULL || e == NULL)
                 rl_initialize();                  rl_initialize();
         return (history(h, &ev, H_SAVE, filename));          return (history(h, &ev, H_SAVE, filename) == -1);
 }  }
   
   
Line 1159  add_history(const char *line)
Line 1188  add_history(const char *line)
   
   
 /*  /*
    * remove the specified entry from the history list and return it.
    */
   HIST_ENTRY *
   remove_history(int num)
   {
           static HIST_ENTRY she;
           HistEvent ev;
   
           if (h == NULL || e == NULL)
                   rl_initialize();
   
           if (history(h, &ev, H_DEL, num) != 0)
                   return NULL;
   
           she.line = ev.str;
           she.data = NULL;
   
           return &she;
   }
   
   
   /*
  * clear the history list - delete all entries   * clear the history list - delete all entries
  */   */
 void  void
Line 1351  history_search_pos(const char *str,
Line 1402  history_search_pos(const char *str,
 /********************************/  /********************************/
 /* completion functions */  /* completion functions */
   
   char *
   tilde_expand(char *name)
   {
           return fn_tilde_expand(name);
   }
   
   char *
   filename_completion_function(const char *name, int state)
   {
           return fn_filename_completion_function(name, state);
   }
   
 /*  /*
  * a completion generator for usernames; returns _first_ username   * a completion generator for usernames; returns _first_ username
  * which starts with supplied text   * which starts with supplied text
Line 1580  rl_callback_read_char()
Line 1643  rl_callback_read_char()
   
         if (buf == NULL || count-- <= 0)          if (buf == NULL || count-- <= 0)
                 return;                  return;
         if (count == 0 && buf[0] == CTRL('d'))          if (count == 0 && buf[0] == e->el_tty.t_c[TS_IO][C_EOF])
                 done = 1;                  done = 1;
         if (buf[count] == '\n' || buf[count] == '\r')          if (buf[count] == '\n' || buf[count] == '\r')
                 done = 2;                  done = 2;
Line 1620  void
Line 1683  void
 rl_redisplay(void)  rl_redisplay(void)
 {  {
         char a[2];          char a[2];
         a[0] = CTRL('r');          a[0] = e->el_tty.t_c[TS_IO][C_REPRINT];
         a[1] = '\0';          a[1] = '\0';
         el_push(e, a);          el_push(e, a);
 }  }

Legend:
Removed from v.1.56  
changed lines
  Added in v.1.62

CVSweb <webmaster@jp.NetBSD.org>