source: scripts/patches/readline-5.0-fixes-1.patch@ f2d3163

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since f2d3163 was 7f65c0e, checked in by Jim Gifford <clfs@…>, 19 years ago

r625@server (orig r623): jim | 2005-10-31 12:43:24 -0800
Final Move

  • Property mode set to 100644
File size: 6.8 KB
  • readline-5.0

    Submitted By: Jim Gifford (patches at jg555 dot com)
    Date: 2004-09-29
    Initial Package Version: 5.0
    Origin: Various
    Upstream Status: Already Applied
    Description: This patch contains various fixes recommended
    	     by the author Chet. The original patches are
    	     avaiable at ftp://ftp.cwru.edu/pub/bash/readline-5.0-patches
    
     
    diff -Naur readline-5.0.orig/display.c readline-5.0/display.c
    old new  
    201201     int *lp, *lip, *niflp, *vlp;
    202202{
    203203  char *r, *ret, *p;
    204   int l, rl, last, ignoring, ninvis, invfl, ind, pind, physchars;
     204  int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
    205205
    206206  /* Short-circuit if we can. */
    207207  if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
     
    222222  r = ret = (char *)xmalloc (l + 1);
    223223
    224224  invfl = 0;    /* invisible chars in first line of prompt */
     225  invflset = 0; /* we only want to set invfl once */
    225226
    226227  for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
    227228    {
     
    249250              while (l--)
    250251                *r++ = *p++;
    251252              if (!ignoring)
    252                 rl += ind - pind;
     253                {
     254                  rl += ind - pind;
     255                  physchars += _rl_col_width (pmt, pind, ind);
     256                }
    253257              else
    254258                ninvis += ind - pind;
    255259              p--;                      /* compensate for later increment */
     
    259263            {
    260264              *r++ = *p;
    261265              if (!ignoring)
    262                 rl++;                   /* visible length byte counter */
     266                {
     267                  rl++;                 /* visible length byte counter */
     268                  physchars++;
     269                }
    263270              else
    264271                ninvis++;               /* invisible chars byte counter */
    265272            }
    266273
    267           if (rl >= _rl_screenwidth)
    268             invfl = ninvis;
    269 
    270           if (ignoring == 0)
    271             physchars++;
     274          if (invflset == 0 && rl >= _rl_screenwidth)
     275            {
     276              invfl = ninvis;
     277              invflset = 1;
     278            }
    272279        }
    273280    }
    274281
     
    351358      local_prompt = expand_prompt (p, &prompt_visible_length,
    352359                                       &prompt_last_invisible,
    353360                                       (int *)NULL,
    354                                        (int *)NULL);
     361                                       &prompt_physical_chars);
    355362      c = *t; *t = '\0';
    356363      /* The portion of the prompt string up to and including the
    357364         final newline is now null-terminated. */
    358365      local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
    359366                                                   (int *)NULL,
    360367                                                   &prompt_invis_chars_first_line,
    361                                                    &prompt_physical_chars);
     368                                                   (int *)NULL);
    362369      *t = c;
    363370      return (prompt_prefix_length);
    364371    }
     
    417424  register int in, out, c, linenum, cursor_linenum;
    418425  register char *line;
    419426  int c_pos, inv_botlin, lb_botlin, lb_linenum;
    420   int newlines, lpos, temp, modmark;
     427  int newlines, lpos, temp, modmark, n0, num;
    421428  char *prompt_this_line;
    422429#if defined (HANDLE_MULTIBYTE)
    423430  wchar_t wc;
     
    573580
    574581#if defined (HANDLE_MULTIBYTE)
    575582  memset (_rl_wrapped_line, 0, vis_lbsize);
     583  num = 0;
    576584#endif
    577585
    578586  /* prompt_invis_chars_first_line is the number of invisible characters in
     
    591599         probably too much work for the benefit gained.  How many people have
    592600         prompts that exceed two physical lines?
    593601         Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
     602#if defined (HANDLE_MULTIBYTE)
     603      n0 = num;
     604      temp = local_prompt ? strlen (local_prompt) : 0;
     605      while (num < temp)
     606        {
     607          if (_rl_col_width  (local_prompt, n0, num) > _rl_screenwidth)
     608            {
     609              num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
     610              break;
     611            }
     612          num++;
     613        }
     614      temp = num +
     615#else
    594616      temp = ((newlines + 1) * _rl_screenwidth) +
     617#endif /* !HANDLE_MULTIBYTE */
    595618             ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
    596619                                                            : ((newlines == 1) ? wrap_offset : 0))
    597620                                         : ((newlines == 0) ? wrap_offset :0));
    598621             
    599622      inv_lbreaks[++newlines] = temp;
     623#if defined (HANDLE_MULTIBYTE)
     624      lpos -= _rl_col_width (local_prompt, n0, num);
     625#else
    600626      lpos -= _rl_screenwidth;
     627#endif
    601628    }
    602629
    603630  prompt_last_screen_line = newlines;
  • readline-5.0

    diff -Naur readline-5.0.orig/mbutil.c readline-5.0/mbutil.c
    old new  
    126126  if (find_non_zero)
    127127    {
    128128      tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
    129       while (wcwidth (wc) == 0)
     129      while (tmp > 0 && wcwidth (wc) == 0)
    130130        {
    131131          point += tmp;
    132132          tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
    133           if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
     133          if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
    134134            break;
    135135        }
    136136    }
  • readline-5.0

    diff -Naur readline-5.0.orig/misc.c readline-5.0/misc.c
    old new  
    276276      _rl_saved_line_for_history->line = savestring (rl_line_buffer);
    277277      _rl_saved_line_for_history->data = (char *)rl_undo_list;
    278278    }
    279   else if (STREQ (rl_line_buffer, _rl_saved_line_for_history->line) == 0)
    280     {
    281       free (_rl_saved_line_for_history->line);
    282       _rl_saved_line_for_history->line = savestring (rl_line_buffer);
    283       _rl_saved_line_for_history->data = (char *)rl_undo_list;  /* XXX possible memleak */
    284     }
    285279
    286280  return 0;
    287281}
  • readline-5.0

    diff -Naur readline-5.0.orig/vi_mode.c readline-5.0/vi_mode.c
    old new  
    272272  switch (key)
    273273    {
    274274    case '?':
     275      _rl_free_saved_history_line ();
    275276      rl_noninc_forward_search (count, key);
    276277      break;
    277278
    278279    case '/':
     280      _rl_free_saved_history_line ();
    279281      rl_noninc_reverse_search (count, key);
    280282      break;
    281283
     
    690692{
    691693  wchar_t wc;
    692694  char mb[MB_LEN_MAX+1];
    693   int mblen;
     695  int mblen, p;
    694696  mbstate_t ps;
    695697
    696698  memset (&ps, 0, sizeof (mbstate_t));
     
    713715      /* Vi is kind of strange here. */
    714716      if (wc)
    715717        {
     718          p = rl_point;
    716719          mblen = wcrtomb (mb, wc, &ps);
    717720          if (mblen >= 0)
    718721            mb[mblen] = '\0';
    719722          rl_begin_undo_group ();
    720           rl_delete (1, 0);
     723          rl_vi_delete (1, 0);
     724          if (rl_point < p)     /* Did we retreat at EOL? */
     725            rl_point++; /* XXX - should we advance more than 1 for mbchar? */
    721726          rl_insert_text (mb);
    722727          rl_end_undo_group ();
    723728          rl_vi_check ();
     
    13101315      rl_vi_delete (1, c);
    13111316#if defined (HANDLE_MULTIBYTE)
    13121317      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    1313         while (_rl_insert_char (1, c))
    1314           {
    1315             RL_SETSTATE (RL_STATE_MOREINPUT);
    1316             c = rl_read_key ();
    1317             RL_UNSETSTATE (RL_STATE_MOREINPUT);
    1318           }
     1318        {
     1319          if (rl_point < p)             /* Did we retreat at EOL? */
     1320            rl_point++;
     1321          while (_rl_insert_char (1, c))
     1322            {
     1323              RL_SETSTATE (RL_STATE_MOREINPUT);
     1324              c = rl_read_key ();
     1325              RL_UNSETSTATE (RL_STATE_MOREINPUT);
     1326            }
     1327        }
    13191328      else
    13201329#endif
    13211330        {
Note: See TracBrowser for help on using the repository browser.