[BACK]Return to cu.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cu

Diff for /src/usr.bin/cu/cu.c between version 1.26 and 1.27

version 1.26, 2017/12/10 01:03:46 version 1.27, 2019/03/22 07:03:23
Line 41 
Line 41 
 struct termios           saved_tio;  struct termios           saved_tio;
 struct bufferevent      *input_ev;  struct bufferevent      *input_ev;
 struct bufferevent      *output_ev;  struct bufferevent      *output_ev;
   int                      escape_char = '~';
 int                      is_direct = -1;  int                      is_direct = -1;
 int                      restricted = 0;  int                      restricted = 0;
 const char              *line_path = NULL;  const char              *line_path = NULL;
Line 53 
Line 54 
 enum {  enum {
         STATE_NONE,          STATE_NONE,
         STATE_NEWLINE,          STATE_NEWLINE,
         STATE_TILDE          STATE_ESCAPE
 } last_state = STATE_NEWLINE;  } last_state = STATE_NEWLINE;
   
 __dead void     usage(void);  __dead void     usage(void);
Line 67 
Line 68 
 __dead void  __dead void
 usage(void)  usage(void)
 {  {
         fprintf(stderr, "usage: %s [-dr] [-l line] [-s speed | -speed]\n",          fprintf(stderr, "usage: %s [-dr] [-E escape_char] [-l line] "
             __progname);              "[-s speed | -speed]\n", __progname);
         fprintf(stderr, "       %s [host]\n", __progname);          fprintf(stderr, "       %s [host]\n", __progname);
         exit(1);          exit(1);
 }  }
Line 94 
Line 95 
         for (i = 1; i < argc; i++) {          for (i = 1; i < argc; i++) {
                 if (strcmp("--", argv[i]) == 0)                  if (strcmp("--", argv[i]) == 0)
                         break;                          break;
                 if (argv[i][0] != '-' || !isdigit((unsigned char)argv[i][1]))                  if (argv[i][0] != '-' || !isdigit((u_char)argv[i][1]))
                         continue;                          continue;
   
                 if (asprintf(&argv[i], "-s%s", &argv[i][1]) == -1)                  if (asprintf(&argv[i], "-s%s", &argv[i][1]) == -1)
                         errx(1, "speed asprintf");                          errx(1, "speed asprintf");
         }          }
   
         while ((opt = getopt(argc, argv, "drl:s:")) != -1) {          while ((opt = getopt(argc, argv, "drE:l:s:")) != -1) {
                 switch (opt) {                  switch (opt) {
                 case 'd':                  case 'd':
                         is_direct = 1;                          is_direct = 1;
Line 111 
Line 112 
                                 err(1, "pledge");                                  err(1, "pledge");
                         restricted = 1;                          restricted = 1;
                         break;                          break;
                   case 'E':
                           if (optarg[0] == '^' && optarg[2] == '\0' &&
                               (u_char)optarg[1] >= 64 && (u_char)optarg[1] < 128)
                                   escape_char = (u_char)optarg[1] & 31;
                           else if (strlen(optarg) == 1)
                                   escape_char = (u_char)optarg[0];
                           else
                                   errx(1, "invalid escape character: %s", optarg);
                           break;
                 case 'l':                  case 'l':
                         line_path = optarg;                          line_path = optarg;
                         break;                          break;
Line 308 
Line 318 
                                 last_state = STATE_NEWLINE;                                  last_state = STATE_NEWLINE;
                         break;                          break;
                 case STATE_NEWLINE:                  case STATE_NEWLINE:
                         if (state_change && *ptr == '~') {                          if (state_change && (u_char)*ptr == escape_char) {
                                 last_state = STATE_TILDE;                                  last_state = STATE_ESCAPE;
                                 continue;                                  continue;
                         }                          }
                         if (*ptr != '\r')                          if (*ptr != '\r')
                                 last_state = STATE_NONE;                                  last_state = STATE_NONE;
                         break;                          break;
                 case STATE_TILDE:                  case STATE_ESCAPE:
                         do_command(*ptr);                          do_command(*ptr);
                         last_state = STATE_NEWLINE;                          last_state = STATE_NEWLINE;
                         continue;                          continue;

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27