Diff for /embedaddon/readline/callback.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2014/07/30 08:16:45 version 1.1.1.2, 2021/03/17 01:01:01
Line 1 Line 1
 /* callback.c -- functions to use readline as an X `callback' mechanism. */  /* callback.c -- functions to use readline as an X `callback' mechanism. */
   
/* Copyright (C) 1987-2009 Free Software Foundation, Inc./* Copyright (C) 1987-2017 Free Software Foundation, Inc.
   
    This file is part of the GNU Readline Library (Readline), a library     This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.     for reading lines of text with interactive input and history editing.
Line 50 Line 50
 _rl_callback_func_t *_rl_callback_func = 0;  _rl_callback_func_t *_rl_callback_func = 0;
 _rl_callback_generic_arg *_rl_callback_data = 0;  _rl_callback_generic_arg *_rl_callback_data = 0;
   
   /* Applications can set this to non-zero to have readline's signal handlers
      installed during the entire duration of reading a complete line, as in
      readline-6.2.  This should be used with care, because it can result in
      readline receiving signals and not handling them until it's called again
      via rl_callback_read_char, thereby stealing them from the application.
      By default, signal handlers are only active while readline is active. */   
   int rl_persistent_signal_handlers = 0;
   
 /* **************************************************************** */  /* **************************************************************** */
 /*                                                                  */  /*                                                                  */
/*                      Callback Readline Functions              *//*                      Callback Readline Functions                 */
 /*                                                                  */  /*                                                                  */
 /* **************************************************************** */  /* **************************************************************** */
   
Line 72  static int in_handler;  /* terminal_prepped and signal Line 80  static int in_handler;  /* terminal_prepped and signal
   
 /* Make sure the terminal is set up, initialize readline, and prompt. */  /* Make sure the terminal is set up, initialize readline, and prompt. */
 static void  static void
_rl_callback_newline ()_rl_callback_newline (void)
 {  {
   rl_initialize ();    rl_initialize ();
   
Line 82  _rl_callback_newline () Line 90  _rl_callback_newline ()
   
       if (rl_prep_term_function)        if (rl_prep_term_function)
         (*rl_prep_term_function) (_rl_meta_flag);          (*rl_prep_term_function) (_rl_meta_flag);
   
   #if defined (HANDLE_SIGNALS)
         if (rl_persistent_signal_handlers)
           rl_set_signals ();
   #endif
     }      }
   
   readline_internal_setup ();    readline_internal_setup ();
Line 90  _rl_callback_newline () Line 103  _rl_callback_newline ()
   
 /* Install a readline handler, set up the terminal, and issue the prompt. */  /* Install a readline handler, set up the terminal, and issue the prompt. */
 void  void
rl_callback_handler_install (prompt, linefunc)rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *linefunc)
     const char *prompt; 
     rl_vcpfunc_t *linefunc; 
 {  {
   rl_set_prompt (prompt);    rl_set_prompt (prompt);
   RL_SETSTATE (RL_STATE_CALLBACK);    RL_SETSTATE (RL_STATE_CALLBACK);
Line 103  rl_callback_handler_install (prompt, linefunc) Line 114  rl_callback_handler_install (prompt, linefunc)
 #if defined (HANDLE_SIGNALS)  #if defined (HANDLE_SIGNALS)
 #define CALLBACK_READ_RETURN() \  #define CALLBACK_READ_RETURN() \
   do { \    do { \
    rl_clear_signals (); \    if (rl_persistent_signal_handlers == 0) \
       rl_clear_signals (); \
     return; \      return; \
   } while (0)    } while (0)
 #else  #else
Line 112  rl_callback_handler_install (prompt, linefunc) Line 124  rl_callback_handler_install (prompt, linefunc)
   
 /* Read one character, and dispatch to the handler if it ends the line. */  /* Read one character, and dispatch to the handler if it ends the line. */
 void  void
rl_callback_read_char ()rl_callback_read_char (void)
 {  {
   char *line;    char *line;
   int eof, jcode;    int eof, jcode;
Line 140  rl_callback_read_char () Line 152  rl_callback_read_char ()
   
 #if defined (HANDLE_SIGNALS)  #if defined (HANDLE_SIGNALS)
   /* Install signal handlers only when readline has control. */    /* Install signal handlers only when readline has control. */
  rl_set_signals ();  if (rl_persistent_signal_handlers == 0)
     rl_set_signals ();
 #endif  #endif
   
   do    do
Line 161  rl_callback_read_char () Line 174  rl_callback_read_char ()
           CALLBACK_READ_RETURN ();            CALLBACK_READ_RETURN ();
         }          }
 #if defined (VI_MODE)  #if defined (VI_MODE)
         /* States that can occur while in state VIMOTION have to be checked
            before RL_STATE_VIMOTION */
         else if (RL_ISSTATE (RL_STATE_CHARSEARCH))
           {
             int k;
   
             k = _rl_callback_data->i2;
   
             eof = (*_rl_callback_func) (_rl_callback_data);
             /* If the function `deregisters' itself, make sure the data is
                cleaned up. */
             if (_rl_callback_func == 0)   /* XXX - just sanity check */
               {
                 if (_rl_callback_data)
                   {
                     _rl_callback_data_dispose (_rl_callback_data);
                     _rl_callback_data = 0;
                   }
               }
   
             /* Messy case where vi motion command can be char search */
             if (RL_ISSTATE (RL_STATE_VIMOTION))
               {
                 _rl_vi_domove_motion_cleanup (k, _rl_vimvcxt);
                 _rl_internal_char_cleanup ();
                 CALLBACK_READ_RETURN ();        
               }
   
             _rl_internal_char_cleanup ();
           }
       else if (RL_ISSTATE (RL_STATE_VIMOTION))        else if (RL_ISSTATE (RL_STATE_VIMOTION))
         {          {
           eof = _rl_vi_domove_callback (_rl_vimvcxt);            eof = _rl_vi_domove_callback (_rl_vimvcxt);
Line 254  rl_callback_read_char () Line 297  rl_callback_read_char ()
   
 /* Remove the handler, and make sure the terminal is in its normal state. */  /* Remove the handler, and make sure the terminal is in its normal state. */
 void  void
rl_callback_handler_remove ()rl_callback_handler_remove (void)
 {  {
   rl_linefunc = NULL;    rl_linefunc = NULL;
   RL_UNSETSTATE (RL_STATE_CALLBACK);    RL_UNSETSTATE (RL_STATE_CALLBACK);
Line 271  rl_callback_handler_remove () Line 314  rl_callback_handler_remove ()
 }  }
   
 _rl_callback_generic_arg *  _rl_callback_generic_arg *
_rl_callback_data_alloc (count)_rl_callback_data_alloc (int count)
     int count; 
 {  {
   _rl_callback_generic_arg *arg;    _rl_callback_generic_arg *arg;
   
Line 284  _rl_callback_data_alloc (count) Line 326  _rl_callback_data_alloc (count)
   return arg;    return arg;
 }  }
   
void _rl_callback_data_dispose (arg)void
     _rl_callback_generic_arg *arg;_rl_callback_data_dispose (_rl_callback_generic_arg *arg)
 {  {
   xfree (arg);    xfree (arg);
 }  }
   
   /* Make sure that this agrees with cases in rl_callback_read_char */
   void
   rl_callback_sigcleanup (void)
   {
     if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
       return;
   
     if (RL_ISSTATE (RL_STATE_ISEARCH))
       _rl_isearch_cleanup (_rl_iscxt, 0);
     else if (RL_ISSTATE (RL_STATE_NSEARCH))
       _rl_nsearch_cleanup (_rl_nscxt, 0);
     else if (RL_ISSTATE (RL_STATE_VIMOTION))
       RL_UNSETSTATE (RL_STATE_VIMOTION);
     else if (RL_ISSTATE (RL_STATE_NUMERICARG))
       {
         _rl_argcxt = 0;
         RL_UNSETSTATE (RL_STATE_NUMERICARG);
       }
     else if (RL_ISSTATE (RL_STATE_MULTIKEY))
       RL_UNSETSTATE (RL_STATE_MULTIKEY);
     if (RL_ISSTATE (RL_STATE_CHARSEARCH))
       RL_UNSETSTATE (RL_STATE_CHARSEARCH);
   
     _rl_callback_func = 0;
   }
 #endif  #endif

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>