[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.45 and 1.51

version 1.45, 2004/01/17 17:57:40 version 1.51, 2005/04/12 22:01:40
Line 161  static int el_rl_complete_cmdnum = 0;
Line 161  static int el_rl_complete_cmdnum = 0;
   
 /* internal functions */  /* internal functions */
 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 char             *_get_prompt(EditLine *);  static char             *_get_prompt(EditLine *);
 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 **);
 static char             *_rl_compat_sub(const char *, const char *,  static char             *_rl_compat_sub(const char *, const char *,
     const char *, int);      const char *, int);
 static int               rl_complete_internal(int);  static int               _rl_complete_internal(int);
 static int               _rl_qsort_string_compare(const void *, const void *);  static int               _rl_qsort_string_compare(const void *, const void *);
 static int               _rl_event_read_char(EditLine *, char *);  static int               _rl_event_read_char(EditLine *, char *);
   static void              _rl_update_pos(void);
   
   
 /* ARGSUSED */  /* ARGSUSED */
Line 272  rl_initialize(void)
Line 274  rl_initialize(void)
             "ReadLine compatible completion function",              "ReadLine compatible completion function",
             _el_rl_complete);              _el_rl_complete);
         el_set(e, EL_BIND, "^I", "rl_complete", NULL);          el_set(e, EL_BIND, "^I", "rl_complete", NULL);
   
           /*
            * Send TSTP when ^Z is pressed.
            */
           el_set(e, EL_ADDFN, "rl_tstp",
               "ReadLine compatible suspend function",
               _el_rl_tstp);
           el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
   
         /*          /*
          * Find out where the rl_complete function was added; this is           * Find out where the rl_complete function was added; this is
          * used later to detect that lastcmd was also rl_complete.           * used later to detect that lastcmd was also rl_complete.
Line 293  rl_initialize(void)
Line 304  rl_initialize(void)
         li = el_line(e);          li = el_line(e);
         /* a cheesy way to get rid of const cast. */          /* a cheesy way to get rid of const cast. */
         rl_line_buffer = memchr(li->buffer, *li->buffer, 1);          rl_line_buffer = memchr(li->buffer, *li->buffer, 1);
         rl_point = rl_end = 0;          _rl_update_pos();
   
         if (rl_startup_hook)          if (rl_startup_hook)
                 (*rl_startup_hook)(NULL, 0);                  (*rl_startup_hook)(NULL, 0);
Line 1539  filename_completion_function(const char 
Line 1550  filename_completion_function(const char 
 char *  char *
 username_completion_function(const char *text, int state)  username_completion_function(const char *text, int state)
 {  {
         struct passwd *pwd;          struct passwd *pwd, pwres;
           char pwbuf[1024];
   
         if (text[0] == '\0')          if (text[0] == '\0')
                 return (NULL);                  return (NULL);
Line 1550  username_completion_function(const char 
Line 1562  username_completion_function(const char 
         if (state == 0)          if (state == 0)
                 setpwent();                  setpwent();
   
         while ((pwd = getpwent()) && text[0] == pwd->pw_name[0]          while (getpwent_r(&pwres, pwbuf, sizeof(pwbuf), &pwd) == 0
               && text[0] == pwd->pw_name[0]
             && strcmp(text, pwd->pw_name) == 0);              && strcmp(text, pwd->pw_name) == 0);
   
         if (pwd == NULL) {          if (pwd == NULL) {
Line 1571  _el_rl_complete(EditLine *el __attribute
Line 1584  _el_rl_complete(EditLine *el __attribute
         return (unsigned char) rl_complete(0, ch);          return (unsigned char) rl_complete(0, ch);
 }  }
   
   /*
    * el-compatible wrapper to send TSTP on ^Z
    */
   /* ARGSUSED */
   static unsigned char
   _el_rl_tstp(EditLine *el __attribute__((__unused__)), int ch __attribute__((__unused__)))
   {
           (void)kill(0, SIGTSTP);
           return CC_NORM;
   }
   
 /*  /*
  * returns list of completions for text given   * returns list of completions for text given
Line 1698  rl_display_match_list (matches, len, max
Line 1721  rl_display_match_list (matches, len, max
  * Note: '*' support is not implemented   * Note: '*' support is not implemented
  */   */
 static int  static int
 rl_complete_internal(int what_to_do)  _rl_complete_internal(int what_to_do)
 {  {
         Function *complet_func;          Function *complet_func;
         const LineInfo *li;          const LineInfo *li;
Line 1731  rl_complete_internal(int what_to_do)
Line 1754  rl_complete_internal(int what_to_do)
   
         /* these can be used by function called in completion_matches() */          /* these can be used by function called in completion_matches() */
         /* or (*rl_attempted_completion_function)() */          /* or (*rl_attempted_completion_function)() */
         rl_point = li->cursor - li->buffer;          _rl_update_pos();
         rl_end = li->lastchar - li->buffer;  
   
         if (rl_attempted_completion_function) {          if (rl_attempted_completion_function) {
                 int end = li->cursor - li->buffer;                  int end = li->cursor - li->buffer;
Line 1740  rl_complete_internal(int what_to_do)
Line 1762  rl_complete_internal(int what_to_do)
                     (end - len), end);                      (end - len), end);
         } else          } else
                 matches = 0;                  matches = 0;
         if (!rl_attempted_completion_function || !matches)          if (!rl_attempted_completion_function ||
                (!rl_attempted_completion_over && !matches))
                 matches = completion_matches(temp, (CPFunction *)complet_func);                  matches = completion_matches(temp, (CPFunction *)complet_func);
   
           if (rl_attempted_completion_over)
                   rl_attempted_completion_over = 0;
   
         if (matches) {          if (matches) {
                 int i, retval = CC_REFRESH;                  int i, retval = CC_REFRESH;
                 int matches_num, maxlen, match_len, match_display=1;                  int matches_num, maxlen, match_len, match_display=1;
Line 1839  rl_complete_internal(int what_to_do)
Line 1865  rl_complete_internal(int what_to_do)
  * complete word at current point   * complete word at current point
  */   */
 int  int
   /*ARGSUSED*/
 rl_complete(int ignore, int invoking_key)  rl_complete(int ignore, int invoking_key)
 {  {
         if (h == NULL || e == NULL)          if (h == NULL || e == NULL)
                 rl_initialize();                  rl_initialize();
   
         if (rl_inhibit_completion) {          if (rl_inhibit_completion) {
                 rl_insert(ignore, invoking_key);                  char arr[2];
                   arr[0] = (char)invoking_key;
                   arr[1] = '\0';
                   el_insertstr(e, arr);
                 return (CC_REFRESH);                  return (CC_REFRESH);
         } else if (e->el_state.lastcmd == el_rl_complete_cmdnum)          } else if (e->el_state.lastcmd == el_rl_complete_cmdnum)
                 return rl_complete_internal('?');                  return _rl_complete_internal('?');
         else if (_rl_complete_show_all)          else if (_rl_complete_show_all)
                 return rl_complete_internal('!');                  return _rl_complete_internal('!');
         else          else
                 return (rl_complete_internal(TAB));                  return _rl_complete_internal(TAB);
 }  }
   
   
Line 1947  rl_bind_wrapper(EditLine *el, unsigned c
Line 1977  rl_bind_wrapper(EditLine *el, unsigned c
 {  {
         if (map[c] == NULL)          if (map[c] == NULL)
             return CC_ERROR;              return CC_ERROR;
   
           _rl_update_pos();
   
         (*map[c])(NULL, c);          (*map[c])(NULL, c);
   
         /* If rl_done was set by the above call, deal with it here */          /* If rl_done was set by the above call, deal with it here */
Line 1991  rl_callback_read_char()
Line 2024  rl_callback_read_char()
                 } else                  } else
                         wbuf = NULL;                          wbuf = NULL;
                 (*(void (*)(const char *))rl_linefunc)(wbuf);                  (*(void (*)(const char *))rl_linefunc)(wbuf);
                   el_set(e, EL_UNBUFFERED, 1);
         }          }
 }  }
   
Line 2066  rl_parse_and_bind(const char *line)
Line 2100  rl_parse_and_bind(const char *line)
         return (argc ? 1 : 0);          return (argc ? 1 : 0);
 }  }
   
   int
   rl_variable_bind(const char *var, const char *value)
   {
           /*
            * The proper return value is undocument, but this is what the
            * readline source seems to do.
            */
           return ((el_set(e, EL_BIND, "", var, value) == -1) ? 1 : 0);
   }
   
 void  void
 rl_stuff_char(int c)  rl_stuff_char(int c)
 {  {
Line 2117  _rl_event_read_char(EditLine *el, char *
Line 2161  _rl_event_read_char(EditLine *el, char *
                 el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);                  el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
         return(num_read);          return(num_read);
 }  }
   
   static void
   _rl_update_pos(void)
   {
           const LineInfo *li = el_line(e);
   
           rl_point = li->cursor - li->buffer;
           rl_end = li->lastchar - li->buffer;
   }

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.51

CVSweb <webmaster@jp.NetBSD.org>