[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.141 and 1.148

version 1.141, 2017/04/21 05:38:03 version 1.148, 2018/12/02 16:58:13
Line 80  int rl_end = 0;
Line 80  int rl_end = 0;
 char *rl_line_buffer = NULL;  char *rl_line_buffer = NULL;
 rl_vcpfunc_t *rl_linefunc = NULL;  rl_vcpfunc_t *rl_linefunc = NULL;
 int rl_done = 0;  int rl_done = 0;
 VFunction *rl_event_hook = NULL;  rl_hook_func_t *rl_event_hook = NULL;
 KEYMAP_ENTRY_ARRAY emacs_standard_keymap,  KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
     emacs_meta_keymap,      emacs_meta_keymap,
     emacs_ctlx_keymap;      emacs_ctlx_keymap;
Line 122  int readline_echoing_p = 1;
Line 122  int readline_echoing_p = 1;
 int _rl_print_completions_horizontally = 0;  int _rl_print_completions_horizontally = 0;
 VFunction *rl_redisplay_function = NULL;  VFunction *rl_redisplay_function = NULL;
 Function *rl_startup_hook = NULL;  Function *rl_startup_hook = NULL;
   int rl_did_startup_hook = 0;
 VFunction *rl_completion_display_matches_hook = NULL;  VFunction *rl_completion_display_matches_hook = NULL;
 VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;  VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;
 VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;  VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;
Line 289  rl_initialize(void)
Line 290  rl_initialize(void)
         if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0)          if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0)
                 editmode = 0;                  editmode = 0;
   
         e = el_init(rl_readline_name, rl_instream, rl_outstream, stderr);          e = el_init_internal(rl_readline_name, rl_instream, rl_outstream,
               stderr, fileno(rl_instream), fileno(rl_outstream), fileno(stderr),
               NO_RESET);
   
         if (!editmode)          if (!editmode)
                 el_set(e, EL_EDITMODE, 0);                  el_set(e, EL_EDITMODE, 0);
Line 385  rl_initialize(void)
Line 388  rl_initialize(void)
         _resize_fun(e, &rl_line_buffer);          _resize_fun(e, &rl_line_buffer);
         _rl_update_pos();          _rl_update_pos();
   
         if (rl_startup_hook)          tty_end(e, TCSADRAIN);
                 (*rl_startup_hook)(NULL, 0);  
   
         return 0;          return 0;
 }  }
Line 408  readline(const char *p)
Line 410  readline(const char *p)
   
         if (e == NULL || h == NULL)          if (e == NULL || h == NULL)
                 rl_initialize();                  rl_initialize();
           if (rl_did_startup_hook == 0 && rl_startup_hook) {
                   rl_did_startup_hook = 1;
                   (*rl_startup_hook)(NULL, 0);
           }
           tty_init(e);
   
   
         rl_done = 0;          rl_done = 0;
   
         (void)setjmp(topbuf);          (void)setjmp(topbuf);
           buf = NULL;
   
         /* update prompt accordingly to what has been passed */          /* update prompt accordingly to what has been passed */
         if (rl_set_prompt(prompt) == -1)          if (rl_set_prompt(prompt) == -1)
                 return NULL;                  goto out;
   
         if (rl_pre_input_hook)          if (rl_pre_input_hook)
                 (*rl_pre_input_hook)(NULL, 0);                  (*rl_pre_input_hook)(NULL, 0);
   
         if (rl_event_hook && !(e->el_flags&NO_TTY)) {          if (rl_event_hook && !(e->el_flags & NO_TTY)) {
                 el_set(e, EL_GETCFN, _rl_event_read_char);                  el_set(e, EL_GETCFN, _rl_event_read_char);
                 used_event_hook = 1;                  used_event_hook = 1;
         }          }
Line 440  readline(const char *p)
Line 449  readline(const char *p)
   
                 buf = strdup(ret);                  buf = strdup(ret);
                 if (buf == NULL)                  if (buf == NULL)
                         return NULL;                          goto out;
                 lastidx = count - 1;                  lastidx = count - 1;
                 if (buf[lastidx] == '\n')                  if (buf[lastidx] == '\n')
                         buf[lastidx] = '\0';                          buf[lastidx] = '\0';
Line 450  readline(const char *p)
Line 459  readline(const char *p)
         history(h, &ev, H_GETSIZE);          history(h, &ev, H_GETSIZE);
         history_length = ev.num;          history_length = ev.num;
   
   out:
           tty_end(e, TCSADRAIN);
         return buf;          return buf;
 }  }
   
Line 1344  read_history(const char *filename)
Line 1355  read_history(const char *filename)
                 rl_initialize();                  rl_initialize();
         if (filename == NULL && (filename = _default_history_file()) == NULL)          if (filename == NULL && (filename = _default_history_file()) == NULL)
                 return errno;                  return errno;
         return history(h, &ev, H_LOAD, filename) == -1 ?          errno = 0;
             (errno ? errno : EINVAL) : 0;          if (history(h, &ev, H_LOAD, filename) == -1)
               return errno ? errno : EINVAL;
           if (history(h, &ev, H_GETSIZE) == 0)
                   history_length = ev.num;
           if (history_length < 0)
                   return EINVAL;
           return 0;
 }  }
   
   
Line 1365  write_history(const char *filename)
Line 1382  write_history(const char *filename)
             (errno ? errno : EINVAL) : 0;              (errno ? errno : EINVAL) : 0;
 }  }
   
   int
   append_history(int n, const char *filename)
   {
           HistEvent ev;
           FILE *fp;
   
           if (h == NULL || e == NULL)
                   rl_initialize();
           if (filename == NULL && (filename = _default_history_file()) == NULL)
                   return errno;
   
           if ((fp = fopen(filename, "a")) == NULL)
                   return errno;
   
           if (history(h, &ev, H_NSAVE_FP, (size_t)n,  fp) == -1) {
                   int serrno = errno ? errno : EINVAL;
                   fclose(fp);
                   return serrno;
           }
           fclose(fp);
           return 0;
   }
   
 /*  /*
  * returns history ``num''th event   * returns history ``num''th event
Line 2035  rl_callback_read_char(void)
Line 2074  rl_callback_read_char(void)
         if (done && rl_linefunc != NULL) {          if (done && rl_linefunc != NULL) {
                 el_set(e, EL_UNBUFFERED, 0);                  el_set(e, EL_UNBUFFERED, 0);
                 if (done == 2) {                  if (done == 2) {
                     if ((wbuf = strdup(buf)) != NULL)                          if ((wbuf = strdup(buf)) != NULL)
                         wbuf[count] = '\0';                                  wbuf[count] = '\0';
                 } else                  } else
                         wbuf = NULL;                          wbuf = NULL;
                 (*(void (*)(const char *))rl_linefunc)(wbuf);                  (*(void (*)(const char *))rl_linefunc)(wbuf);
Line 2058  rl_callback_handler_install(const char *
Line 2097  rl_callback_handler_install(const char *
 void  void
 rl_callback_handler_remove(void)  rl_callback_handler_remove(void)
 {  {
         el_set(e, EL_UNBUFFERED, 0);  
         rl_linefunc = NULL;          rl_linefunc = NULL;
           el_end(e);
           e = NULL;
 }  }
   
 void  void
Line 2369  rl_set_keyboard_input_timeout(int u __at
Line 2409  rl_set_keyboard_input_timeout(int u __at
 {  {
         return 0;          return 0;
 }  }
   
   void
   rl_resize_terminal(void)
   {
           el_resize(e);
   }
   
   void
   rl_reset_after_signal(void)
   {
           if (rl_prep_term_function)
                   (*rl_prep_term_function)();
   }
   
   void
   rl_echo_signal_char(int sig)
   {
           int c = tty_get_signal_character(e, sig);
           if (c == -1)
                   return;
           re_putc(e, c, 0);
   }

Legend:
Removed from v.1.141  
changed lines
  Added in v.1.148

CVSweb <webmaster@jp.NetBSD.org>