source: clfs-sysroot/patches/readline-5.2-fixes-5.patch@ 0eb57e6

Last change on this file since 0eb57e6 was a50d3ff, checked in by Joe Ciccone <jciccone@…>, 16 years ago

Update Readline Patch.

  • Property mode set to 100644
File size: 21.3 KB
  • readline-5.2

    Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
    Date: 12-20-2008
    Initial Package Version: 5.2
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 5.2-013
    
    diff -Naur readline-5.2.orig/complete.c readline-5.2/complete.c
    old new  
    428428        return (1);
    429429      if (c == 'n' || c == 'N' || c == RUBOUT)
    430430        return (0);
    431       if (c == ABORT_CHAR)
     431      if (c == ABORT_CHAR || c < 0)
    432432        _rl_abort_internal ();
    433433      if (for_pager && (c == NEWLINE || c == RETURN))
    434434        return (2);
  • readline-5.2

    diff -Naur readline-5.2.orig/display.c readline-5.2/display.c
    old new  
    391391      t = ++p;
    392392      local_prompt = expand_prompt (p, &prompt_visible_length,
    393393                                       &prompt_last_invisible,
    394                                        (int *)NULL,
     394                                       &prompt_invis_chars_first_line,
    395395                                       &prompt_physical_chars);
    396396      c = *t; *t = '\0';
    397397      /* The portion of the prompt string up to and including the
    398398         final newline is now null-terminated. */
    399399      local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
    400400                                                   (int *)NULL,
    401                                                    &prompt_invis_chars_first_line,
     401                                                   (int *)NULL,
    402402                                                   (int *)NULL);
    403403      *t = c;
    404404      local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
     
    561561      wrap_offset = prompt_invis_chars_first_line = 0;
    562562    }
    563563
     564#if defined (HANDLE_MULTIBYTE)
     565#define CHECK_INV_LBREAKS() \
     566      do { \
     567        if (newlines >= (inv_lbsize - 2)) \
     568          { \
     569            inv_lbsize *= 2; \
     570            inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
     571            _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
     572          } \
     573      } while (0)
     574#else
    564575#define CHECK_INV_LBREAKS() \
    565576      do { \
    566577        if (newlines >= (inv_lbsize - 2)) \
     
    569580            inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
    570581          } \
    571582      } while (0)
     583#endif /* HANDLE_MULTIBYTE */
    572584
    573585#if defined (HANDLE_MULTIBYTE)   
    574586#define CHECK_LPOS() \
     
    898910             second and subsequent lines start at inv_lbreaks[N], offset by
    899911             OFFSET (which has already been calculated above).  */
    900912
     913#define INVIS_FIRST()   (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
     914#define WRAP_OFFSET(line, offset)  ((line == 0) \
     915                                        ? (offset ? INVIS_FIRST() : 0) \
     916                                        : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
    901917#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
    902918#define VIS_LLEN(l)     ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
    903919#define INV_LLEN(l)     (inv_lbreaks[l+1] - inv_lbreaks[l])
     
    932948                  _rl_last_c_pos != o_cpos &&
    933949                  _rl_last_c_pos > wrap_offset &&
    934950                  o_cpos < prompt_last_invisible)
    935                 _rl_last_c_pos -= wrap_offset;
     951                _rl_last_c_pos -= prompt_invis_chars_first_line;        /* XXX - was wrap_offset */
     952              else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
     953                        (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
     954                        cpos_adjusted == 0 &&
     955                        _rl_last_c_pos != o_cpos &&
     956                        _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
     957                _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
    936958                 
    937959              /* If this is the line with the prompt, we might need to
    938960                 compensate for invisible characters in the new line. Do
     
    10361058                tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
    10371059              else
    10381060                tx = nleft;
    1039               if (_rl_last_c_pos > tx)
     1061              if (tx >= 0 && _rl_last_c_pos > tx)
    10401062                {
    10411063                  _rl_backspace (_rl_last_c_pos - tx);  /* XXX */
    10421064                  _rl_last_c_pos = tx;
     
    11921214     int current_line, omax, nmax, inv_botlin;
    11931215{
    11941216  register char *ofd, *ols, *oe, *nfd, *nls, *ne;
    1195   int temp, lendiff, wsatend, od, nd;
     1217  int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
    11961218  int current_invis_chars;
    11971219  int col_lendiff, col_temp;
    11981220#if defined (HANDLE_MULTIBYTE)
     
    12081230  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    12091231    temp = _rl_last_c_pos;
    12101232  else
    1211     temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
     1233    temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
    12121234  if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
    12131235        && _rl_last_v_pos == current_line - 1)
    12141236    {
     
    14531475        _rl_last_c_pos = lendiff;
    14541476    }
    14551477
     1478  o_cpos = _rl_last_c_pos;
     1479
    14561480  /* When this function returns, _rl_last_c_pos is correct, and an absolute
    14571481     cursor postion in multibyte mode, but a buffer index when not in a
    14581482     multibyte locale. */
     
    14621486  /* We need to indicate that the cursor position is correct in the presence of
    14631487     invisible characters in the prompt string.  Let's see if setting this when
    14641488     we make sure we're at the end of the drawn prompt string works. */
    1465   if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
     1489  if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
     1490      (_rl_last_c_pos > 0 || o_cpos > 0) &&
     1491      _rl_last_c_pos == prompt_physical_chars)
    14661492    cpos_adjusted = 1;
    14671493#endif
    14681494#endif
     
    15061532    {
    15071533      /* Non-zero if we're increasing the number of lines. */
    15081534      int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
     1535      /* If col_lendiff is > 0, implying that the new string takes up more
     1536         screen real estate than the old, but lendiff is < 0, meaning that it
     1537         takes fewer bytes, we need to just output the characters starting
     1538         from the first difference.  These will overwrite what is on the
     1539         display, so there's no reason to do a smart update.  This can really
     1540         only happen in a multibyte environment. */
     1541      if (lendiff < 0)
     1542        {
     1543          _rl_output_some_chars (nfd, temp);
     1544          _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
     1545          /* If nfd begins before any invisible characters in the prompt,
     1546             adjust _rl_last_c_pos to account for wrap_offset and set
     1547             cpos_adjusted to let the caller know. */
     1548          if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
     1549            {
     1550              _rl_last_c_pos -= wrap_offset;
     1551              cpos_adjusted = 1;
     1552            }
     1553          return;
     1554        }
    15091555      /* Sometimes it is cheaper to print the characters rather than
    15101556         use the terminal's capabilities.  If we're growing the number
    15111557         of lines, make sure we actually cause the new line to wrap
    15121558         around on auto-wrapping terminals. */
    1513       if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
     1559      else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
    15141560        {
    15151561          /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
    15161562             _rl_horizontal_scroll_mode == 1, inserting the characters with
     
    15331579            }
    15341580          else
    15351581            {
    1536               /* We have horizontal scrolling and we are not inserting at
    1537                  the end.  We have invisible characters in this line.  This
    1538                  is a dumb update. */
    15391582              _rl_output_some_chars (nfd, temp);
    15401583              _rl_last_c_pos += col_temp;
     1584              /* If nfd begins before any invisible characters in the prompt,
     1585                 adjust _rl_last_c_pos to account for wrap_offset and set
     1586                 cpos_adjusted to let the caller know. */
     1587              if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
     1588                {
     1589                  _rl_last_c_pos -= wrap_offset;
     1590                  cpos_adjusted = 1;
     1591                }
    15411592              return;
    15421593            }
    15431594          /* Copy (new) chars to screen from first diff to last match. */
     
    15451596          if ((temp - lendiff) > 0)
    15461597            {
    15471598              _rl_output_some_chars (nfd + lendiff, temp - lendiff);
    1548 #if 1
    15491599             /* XXX -- this bears closer inspection.  Fixes a redisplay bug
    15501600                reported against bash-3.0-alpha by Andreas Schwab involving
    15511601                multibyte characters and prompt strings with invisible
    15521602                characters, but was previously disabled. */
    1553               _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
    1554 #else
    1555               _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
    1556 #endif
     1603              if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     1604                twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
     1605              else
     1606                twidth = temp - lendiff;
     1607              _rl_last_c_pos += twidth;
    15571608            }
    15581609        }
    15591610      else
     
    15861637          temp = nls - nfd;
    15871638          if (temp > 0)
    15881639            {
     1640              /* If nfd begins at the prompt, or before the invisible
     1641                 characters in the prompt, we need to adjust _rl_last_c_pos
     1642                 in a multibyte locale to account for the wrap offset and
     1643                 set cpos_adjusted accordingly. */
    15891644              _rl_output_some_chars (nfd, temp);
    1590               _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
     1645              if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     1646                {
     1647                  _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
     1648                  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
     1649                    {
     1650                      _rl_last_c_pos -= wrap_offset;
     1651                      cpos_adjusted = 1;
     1652                    }
     1653                }
     1654              else
     1655                _rl_last_c_pos += temp;
    15911656            }
    15921657        }
    15931658      /* Otherwise, print over the existing material. */
     
    15951660        {
    15961661          if (temp > 0)
    15971662            {
     1663              /* If nfd begins at the prompt, or before the invisible
     1664                 characters in the prompt, we need to adjust _rl_last_c_pos
     1665                 in a multibyte locale to account for the wrap offset and
     1666                 set cpos_adjusted accordingly. */
    15981667              _rl_output_some_chars (nfd, temp);
    15991668              _rl_last_c_pos += col_temp;               /* XXX */
     1669              if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     1670                {
     1671                  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
     1672                    {
     1673                      _rl_last_c_pos -= wrap_offset;
     1674                      cpos_adjusted = 1;
     1675                    }
     1676                }
    16001677            }
    16011678          lendiff = (oe - old) - (ne - new);
    16021679          if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     
    17211798  int woff;                     /* number of invisible chars on current line */
    17221799  int cpos, dpos;               /* current and desired cursor positions */
    17231800
    1724   woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
     1801  woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
    17251802  cpos = _rl_last_c_pos;
    17261803#if defined (HANDLE_MULTIBYTE)
    17271804  /* If we have multibyte characters, NEW is indexed by the buffer point in
     
    17321809  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    17331810    {
    17341811      dpos = _rl_col_width (data, 0, new);
    1735       if (dpos > prompt_last_invisible)         /* XXX - don't use woff here */
     1812      /* Use NEW when comparing against the last invisible character in the
     1813         prompt string, since they're both buffer indices and DPOS is a
     1814         desired display position. */
     1815      if ((new > prompt_last_invisible) ||              /* XXX - don't use woff here */
     1816          (prompt_physical_chars > _rl_screenwidth &&
     1817           _rl_last_v_pos == prompt_last_screen_line &&
     1818           wrap_offset != woff &&
     1819           new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
    17361820        {
    17371821          dpos -= woff;
    17381822          /* Since this will be assigned to _rl_last_c_pos at the end (more
     
    23802464
    23812465  if (end <= start)
    23822466    return 0;
     2467  if (MB_CUR_MAX == 1 || rl_byte_oriented)
     2468    return (end - start);
    23832469
    23842470  memset (&ps, 0, sizeof (mbstate_t));
    23852471
  • readline-5.2

    diff -Naur readline-5.2.orig/input.c readline-5.2/input.c
    old new  
    133133    return (0);
    134134
    135135  *key = ibuffer[pop_index++];
    136 
     136#if 0
    137137  if (pop_index >= ibuffer_len)
     138#else
     139  if (pop_index > ibuffer_len)
     140#endif
    138141    pop_index = 0;
    139142
    140143  return (1);
     
    151154    {
    152155      pop_index--;
    153156      if (pop_index < 0)
    154         pop_index = ibuffer_len - 1;
     157        pop_index = ibuffer_len;
    155158      ibuffer[pop_index] = key;
    156159      return (1);
    157160    }
     
    250253      while (chars_avail--)
    251254        {
    252255          k = (*rl_getc_function) (rl_instream);
    253           rl_stuff_char (k);
     256          if (rl_stuff_char (k) == 0)
     257            break;                      /* some problem; no more room */
    254258          if (k == NEWLINE || k == RETURN)
    255259            break;
    256260        }
     
    373377      RL_SETSTATE (RL_STATE_INPUTPENDING);
    374378    }
    375379  ibuffer[push_index++] = key;
     380#if 0
    376381  if (push_index >= ibuffer_len)
     382#else
     383  if (push_index > ibuffer_len)
     384#endif
    377385    push_index = 0;
    378386
    379387  return 1;
     
    513521     char *mbchar;
    514522     int size;
    515523{
    516   int mb_len = 0;
     524  int mb_len, c;
    517525  size_t mbchar_bytes_length;
    518526  wchar_t wc;
    519527  mbstate_t ps, ps_back;
    520528
    521529  memset(&ps, 0, sizeof (mbstate_t));
    522530  memset(&ps_back, 0, sizeof (mbstate_t));
    523  
     531
     532  mb_len = 0; 
    524533  while (mb_len < size)
    525534    {
    526535      RL_SETSTATE(RL_STATE_MOREINPUT);
    527       mbchar[mb_len++] = rl_read_key ();
     536      c = rl_read_key ();
    528537      RL_UNSETSTATE(RL_STATE_MOREINPUT);
    529538
     539      if (c < 0)
     540        break;
     541
     542      mbchar[mb_len++] = c;
     543
    530544      mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
    531545      if (mbchar_bytes_length == (size_t)(-1))
    532546        break;          /* invalid byte sequence for the current locale */
     
    564578
    565579  c = first;
    566580  memset (mb, 0, mlen);
    567   for (i = 0; i < mlen; i++)
     581  for (i = 0; c >= 0 && i < mlen; i++)
    568582    {
    569583      mb[i] = (char)c;
    570584      memset (&ps, 0, sizeof (mbstate_t));
  • readline-5.2

    diff -Naur readline-5.2.orig/isearch.c readline-5.2/isearch.c
    old new  
    327327  rl_command_func_t *f;
    328328
    329329  f = (rl_command_func_t *)NULL;
    330  
    331  /* Translate the keys we do something with to opcodes. */
     330
     331  if (c < 0)
     332    {
     333      cxt->sflags |= SF_FAILED;
     334      cxt->history_pos = cxt->last_found_line;
     335      return -1;
     336    }
     337
     338  /* Translate the keys we do something with to opcodes. */
    332339  if (c >= 0 && _rl_keymap[c].type == ISFUNC)
    333340    {
    334341      f = _rl_keymap[c].function;
  • readline-5.2

    diff -Naur readline-5.2.orig/misc.c readline-5.2/misc.c
    old new  
    146146          rl_restore_prompt ();
    147147          rl_clear_message ();
    148148          RL_UNSETSTATE(RL_STATE_NUMERICARG);
     149          if (key < 0)
     150            return -1;
    149151          return (_rl_dispatch (key, _rl_keymap));
    150152        }
    151153    }
  • readline-5.2

    diff -Naur readline-5.2.orig/readline.c readline-5.2/readline.c
    old new  
    645645  if ((cxt->flags & KSEQ_DISPATCHED) == 0)
    646646    {
    647647      nkey = _rl_subseq_getchar (cxt->okey);
     648      if (nkey < 0)
     649        {
     650          _rl_abort_internal ();
     651          return -1;
     652        }
    648653      r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
    649654      cxt->flags |= KSEQ_DISPATCHED;
    650655    }
  • support/shobj-conf

    diff -Naur readline-5.2.orig/support/shobj-conf readline-5.2/support/shobj-conf
    old new  
    1010# Chet Ramey
    1111# chet@po.cwru.edu
    1212
    13 # Copyright (C) 1996-2002 Free Software Foundation, Inc.
     13# Copyright (C) 1996-2007 Free Software Foundation, Inc.
    1414#
    1515# This program is free software; you can redistribute it and/or modify
    1616# it under the terms of the GNU General Public License as published by
     
    114114        SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
    115115        ;;
    116116
    117 freebsd2* | netbsd*)
     117freebsd2*)
    118118        SHOBJ_CFLAGS=-fpic
    119119        SHOBJ_LD=ld
    120120        SHOBJ_LDFLAGS='-x -Bshareable'
     
    125125
    126126# FreeBSD-3.x ELF
    127127freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*)
    128         SHOBJ_CFLAGS=-fpic
     128        SHOBJ_CFLAGS=-fPIC
    129129        SHOBJ_LD='${CC}'
    130130
    131131        if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
     
    142142        ;;
    143143
    144144# Darwin/MacOS X
    145 darwin8*)
     145darwin[89]*)
    146146        SHOBJ_STATUS=supported
    147147        SHLIB_STATUS=supported
    148148       
     
    153153        SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
    154154        SHLIB_LIBSUFF='dylib'
    155155
    156         SHOBJ_LDFLAGS='-undefined dynamic_lookup'
     156        SHOBJ_LDFLAGS='-dynamiclib -dynamic -undefined dynamic_lookup -arch_only `/usr/bin/arch`'
    157157        SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
    158158
    159159        SHLIB_LIBS='-lncurses'  # see if -lcurses works on MacOS X 10.1
     
    171171        SHLIB_LIBSUFF='dylib'
    172172
    173173        case "${host_os}" in
    174         darwin[78]*)    SHOBJ_LDFLAGS=''
     174        darwin[789]*)   SHOBJ_LDFLAGS=''
    175175                        SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
    176176                        ;;
    177177        *)              SHOBJ_LDFLAGS='-dynamic'
     
    182182        SHLIB_LIBS='-lncurses'  # see if -lcurses works on MacOS X 10.1
    183183        ;;
    184184
    185 openbsd*)
     185openbsd*|netbsd*)
    186186        SHOBJ_CFLAGS=-fPIC
    187187        SHOBJ_LD='${CC}'
    188188        SHOBJ_LDFLAGS='-shared'
     
    247247        SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
    248248        ;;
    249249
    250 aix4.[2-9]*-*gcc*)              # lightly tested by jik@cisco.com
     250aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*)             # lightly tested by jik@cisco.com
    251251        SHOBJ_CFLAGS=-fpic
    252252        SHOBJ_LD='ld'
    253253        SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
     
    258258        SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
    259259        ;;
    260260
    261 aix4.[2-9]*)
     261aix4.[2-9]*|aix[5-9].*)
    262262        SHOBJ_CFLAGS=-K
    263263        SHOBJ_LD='ld'
    264264        SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
     
    329329        SHOBJ_LD='${CC}'
    330330        # if you have problems linking here, moving the `-Wl,+h,$@' from
    331331        # SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work
    332         SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
     332        SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s'
    333333
    334334        SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)'
    335335        SHLIB_LIBSUFF='sl'
  • readline-5.2

    diff -Naur readline-5.2.orig/text.c readline-5.2/text.c
    old new  
    857857  c = rl_read_key ();
    858858  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    859859
     860  if (c < 0)
     861    return -1;
     862
    860863#if defined (HANDLE_SIGNALS)
    861864  if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
    862865    _rl_restore_tty_signals ();
     
    15201523
    15211524  mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
    15221525
     1526  if (mb_len <= 0)
     1527    return -1;
     1528
    15231529  if (count < 0)
    15241530    return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
    15251531  else
     
    15361542  c = rl_read_key ();
    15371543  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    15381544
     1545  if (c < 0)
     1546    return -1;
     1547
    15391548  if (count < 0)
    15401549    return (_rl_char_search_internal (-count, bdir, c));
    15411550  else
  • readline-5.2

    diff -Naur readline-5.2.orig/vi_mode.c readline-5.2/vi_mode.c
    old new  
    886886  RL_SETSTATE(RL_STATE_MOREINPUT);
    887887  c = rl_read_key ();
    888888  RL_UNSETSTATE(RL_STATE_MOREINPUT);
     889
     890  if (c < 0)
     891    {
     892      *nextkey = 0;
     893      return -1;
     894    }
     895
    889896  *nextkey = c;
    890897
    891898  if (!member (c, vi_motion))
     
    902909          RL_SETSTATE(RL_STATE_MOREINPUT);
    903910          c = rl_read_key ();   /* real command */
    904911          RL_UNSETSTATE(RL_STATE_MOREINPUT);
     912          if (c < 0)
     913            {
     914              *nextkey = 0;
     915              return -1;
     916            }
    905917          *nextkey = c;
    906918        }
    907919      else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
     
    12241236_rl_vi_callback_char_search (data)
    12251237     _rl_callback_generic_arg *data;
    12261238{
     1239  int c;
    12271240#if defined (HANDLE_MULTIBYTE)
    1228   _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
     1241  c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
    12291242#else
    12301243  RL_SETSTATE(RL_STATE_MOREINPUT);
    1231   _rl_vi_last_search_char = rl_read_key ();
     1244  c = rl_read_key ();
    12321245  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    12331246#endif
    12341247
     1248  if (c <= 0)
     1249    return -1;
     1250
     1251#if !defined (HANDLE_MULTIBYTE)
     1252  _rl_vi_last_search_char = c;
     1253#endif
     1254
    12351255  _rl_callback_func = 0;
    12361256  _rl_want_redisplay = 1;
    12371257
     
    12471267rl_vi_char_search (count, key)
    12481268     int count, key;
    12491269{
     1270  int c;
    12501271#if defined (HANDLE_MULTIBYTE)
    12511272  static char *target;
    12521273  static int tlen;
     
    12931314      else
    12941315        {
    12951316#if defined (HANDLE_MULTIBYTE)
    1296           _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
     1317          c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
     1318          if (c <= 0)
     1319            return -1;
     1320          _rl_vi_last_search_mblen = c;
    12971321#else
    12981322          RL_SETSTATE(RL_STATE_MOREINPUT);
    1299           _rl_vi_last_search_char = rl_read_key ();
     1323          c = rl_read_key ();
    13001324          RL_UNSETSTATE(RL_STATE_MOREINPUT);
     1325          if (c < 0)
     1326            return -1;
     1327          _rl_vi_last_search_char = c;
    13011328#endif
    13021329        }
    13031330    }
     
    14671494  c = rl_read_key ();
    14681495  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    14691496
     1497  if (c < 0)
     1498    return -1;
     1499
    14701500#if defined (HANDLE_MULTIBYTE)
    14711501  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    14721502    c = _rl_read_mbstring (c, mb, mlen);
     
    14851515
    14861516  _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
    14871517
     1518  if (c < 0)
     1519    return -1;
     1520
    14881521  _rl_callback_func = 0;
    14891522  _rl_want_redisplay = 1;
    14901523
     
    15161549  else
    15171550    _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
    15181551
     1552  if (c < 0)
     1553    return -1;
     1554
    15191555  return (_rl_vi_change_char (count, c, mb));
    15201556}
    15211557
     
    16501686  ch = rl_read_key ();
    16511687  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    16521688
    1653   if (ch < 'a' || ch > 'z')
     1689  if (ch < 0 || ch < 'a' || ch > 'z')   /* make test against 0 explicit */
    16541690    {
    16551691      rl_ding ();
    16561692      return -1;
     
    17021738      rl_point = rl_mark;
    17031739      return 0;
    17041740    }
    1705   else if (ch < 'a' || ch > 'z')
     1741  else if (ch < 0 || ch < 'a' || ch > 'z')      /* make test against 0 explicit */
    17061742    {
    17071743      rl_ding ();
    17081744      return -1;
Note: See TracBrowser for help on using the repository browser.