Diff for /embedaddon/readline/examples/rl-callbacktest.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2014/07/30 08:16:46 version 1.1.1.2, 2021/03/17 01:01:01
Line 2 Line 2
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  #include <unistd.h>
 #include <string.h>  #include <string.h>
   #include <locale.h>
   
 /* Used for select(2) */  /* Used for select(2) */
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/select.h>  #include <sys/select.h>
   
   #include <signal.h>
   
   #include <errno.h>
 #include <stdio.h>  #include <stdio.h>
   
 /* Standard readline include files. */  /* Standard readline include files. */
Line 18 Line 22
 #  include <readline/history.h>  #  include <readline/history.h>
 #endif  #endif
   
   extern int errno;
   
 static void cb_linehandler (char *);  static void cb_linehandler (char *);
   static void signandler (int);
   
int running;int running, sigwinch_received;
 const char *prompt = "rltest$ ";  const char *prompt = "rltest$ ";
   
   /* Handle SIGWINCH and window size changes when readline is not active and
      reading a character. */
   static void
   sighandler (int sig)
   {
     sigwinch_received = 1;
   }
   
 /* Callback function called for each line when accept-line executed, EOF  /* Callback function called for each line when accept-line executed, EOF
    seen, or EOF character read.  This sets a flag and returns; it could     seen, or EOF character read.  This sets a flag and returns; it could
    also call exit(3). */     also call exit(3). */
Line 57  main (int c, char **v) Line 72  main (int c, char **v)
   fd_set fds;    fd_set fds;
   int r;    int r;
   
   
     setlocale (LC_ALL, "");
   
     /* Handle SIGWINCH */
     signal (SIGWINCH, sighandler);
     
   /* Install the line handler. */    /* Install the line handler. */
   rl_callback_handler_install (prompt, cb_linehandler);    rl_callback_handler_install (prompt, cb_linehandler);
   
Line 71  main (int c, char **v) Line 92  main (int c, char **v)
       FD_SET (fileno (rl_instream), &fds);            FD_SET (fileno (rl_instream), &fds);    
   
       r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);        r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
      if (r < 0)      if (r < 0 && errno != EINTR)
         {          {
           perror ("rltest: select");            perror ("rltest: select");
           rl_callback_handler_remove ();            rl_callback_handler_remove ();
           break;            break;
         }          }
         if (sigwinch_received)
           {
             rl_resize_terminal ();
             sigwinch_received = 0;
           }
         if (r < 0)
           continue;
   
       if (FD_ISSET (fileno (rl_instream), &fds))        if (FD_ISSET (fileno (rl_instream), &fds))
         rl_callback_read_char ();          rl_callback_read_char ();

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


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