summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-07 06:45:33 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-07 06:45:33 -0800
commit65217f8589c16280d77b4790b55280d688eb31e6 (patch)
treea7125baa82b6b2a485254f18dc16d45d65ffefdd
parent6f402def6d87ebc5b043919e29df1b6e11dd8f0f (diff)
downloadreadline-65217f8589c16280d77b4790b55280d688eb31e6.tar.gz
readline-65217f8589c16280d77b4790b55280d688eb31e6.tar.bz2
readline-65217f8589c16280d77b4790b55280d688eb31e6.zip
applied patch readline52-005
-rw-r--r--complete.c2
-rw-r--r--input.c14
-rw-r--r--isearch.c11
-rw-r--r--misc.c2
-rw-r--r--readline.c5
-rw-r--r--text.c9
-rw-r--r--vi_mode.c48
7 files changed, 78 insertions, 13 deletions
diff --git a/complete.c b/complete.c
index 73f834a..5ff198d 100644
--- a/complete.c
+++ b/complete.c
@@ -428,7 +428,7 @@ get_y_or_n (for_pager)
return (1);
if (c == 'n' || c == 'N' || c == RUBOUT)
return (0);
- if (c == ABORT_CHAR)
+ if (c == ABORT_CHAR || c < 0)
_rl_abort_internal ();
if (for_pager && (c == NEWLINE || c == RETURN))
return (2);
diff --git a/input.c b/input.c
index da5d771..9660ff1 100644
--- a/input.c
+++ b/input.c
@@ -513,20 +513,26 @@ _rl_read_mbchar (mbchar, size)
char *mbchar;
int size;
{
- int mb_len = 0;
+ int mb_len, c;
size_t mbchar_bytes_length;
wchar_t wc;
mbstate_t ps, ps_back;
memset(&ps, 0, sizeof (mbstate_t));
memset(&ps_back, 0, sizeof (mbstate_t));
-
+
+ mb_len = 0;
while (mb_len < size)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
- mbchar[mb_len++] = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ break;
+
+ mbchar[mb_len++] = c;
+
mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
if (mbchar_bytes_length == (size_t)(-1))
break; /* invalid byte sequence for the current locale */
@@ -564,7 +570,7 @@ _rl_read_mbstring (first, mb, mlen)
c = first;
memset (mb, 0, mlen);
- for (i = 0; i < mlen; i++)
+ for (i = 0; c >= 0 && i < mlen; i++)
{
mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
diff --git a/isearch.c b/isearch.c
index 9f67bfc..2ed459f 100644
--- a/isearch.c
+++ b/isearch.c
@@ -327,8 +327,15 @@ _rl_isearch_dispatch (cxt, c)
rl_command_func_t *f;
f = (rl_command_func_t *)NULL;
-
- /* Translate the keys we do something with to opcodes. */
+
+ if (c < 0)
+ {
+ cxt->sflags |= SF_FAILED;
+ cxt->history_pos = cxt->last_found_line;
+ return -1;
+ }
+
+ /* Translate the keys we do something with to opcodes. */
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
{
f = _rl_keymap[c].function;
diff --git a/misc.c b/misc.c
index 94ecb25..e9c72c5 100644
--- a/misc.c
+++ b/misc.c
@@ -146,6 +146,8 @@ _rl_arg_dispatch (cxt, c)
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
+ if (key < 0)
+ return -1;
return (_rl_dispatch (key, _rl_keymap));
}
}
diff --git a/readline.c b/readline.c
index c2b7400..bd4d263 100644
--- a/readline.c
+++ b/readline.c
@@ -645,6 +645,11 @@ _rl_dispatch_callback (cxt)
if ((cxt->flags & KSEQ_DISPATCHED) == 0)
{
nkey = _rl_subseq_getchar (cxt->okey);
+ if (nkey < 0)
+ {
+ _rl_abort_internal ();
+ return -1;
+ }
r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
cxt->flags |= KSEQ_DISPATCHED;
}
diff --git a/text.c b/text.c
index 399a48c..cb2f5ad 100644
--- a/text.c
+++ b/text.c
@@ -857,6 +857,9 @@ _rl_insert_next (count)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
#if defined (HANDLE_SIGNALS)
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
_rl_restore_tty_signals ();
@@ -1520,6 +1523,9 @@ _rl_char_search (count, fdir, bdir)
mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
+ if (mb_len <= 0)
+ return -1;
+
if (count < 0)
return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
else
@@ -1536,6 +1542,9 @@ _rl_char_search (count, fdir, bdir)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
if (count < 0)
return (_rl_char_search_internal (-count, bdir, c));
else
diff --git a/vi_mode.c b/vi_mode.c
index d0b7e33..b0da0ab 100644
--- a/vi_mode.c
+++ b/vi_mode.c
@@ -886,6 +886,13 @@ rl_vi_domove (key, nextkey)
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+ if (c < 0)
+ {
+ *nextkey = 0;
+ return -1;
+ }
+
*nextkey = c;
if (!member (c, vi_motion))
@@ -902,6 +909,11 @@ rl_vi_domove (key, nextkey)
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key (); /* real command */
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ {
+ *nextkey = 0;
+ return -1;
+ }
*nextkey = c;
}
else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
@@ -1224,14 +1236,22 @@ static int
_rl_vi_callback_char_search (data)
_rl_callback_generic_arg *data;
{
+ int c;
#if defined (HANDLE_MULTIBYTE)
- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
- _rl_vi_last_search_char = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#endif
+ if (c <= 0)
+ return -1;
+
+#if !defined (HANDLE_MULTIBYTE)
+ _rl_vi_last_search_char = c;
+#endif
+
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1247,6 +1267,7 @@ int
rl_vi_char_search (count, key)
int count, key;
{
+ int c;
#if defined (HANDLE_MULTIBYTE)
static char *target;
static int tlen;
@@ -1293,11 +1314,17 @@ rl_vi_char_search (count, key)
else
{
#if defined (HANDLE_MULTIBYTE)
- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ if (c <= 0)
+ return -1;
+ _rl_vi_last_search_mblen = c;
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
- _rl_vi_last_search_char = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+ _rl_vi_last_search_char = c;
#endif
}
}
@@ -1467,6 +1494,9 @@ _rl_vi_callback_getchar (mb, mlen)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, mlen);
@@ -1485,6 +1515,9 @@ _rl_vi_callback_change_char (data)
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1516,6 +1549,9 @@ rl_vi_change_char (count, key)
else
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
return (_rl_vi_change_char (count, c, mb));
}
@@ -1650,7 +1686,7 @@ _rl_vi_set_mark ()
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
- if (ch < 'a' || ch > 'z')
+ if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
return -1;
@@ -1702,7 +1738,7 @@ _rl_vi_goto_mark ()
rl_point = rl_mark;
return 0;
}
- else if (ch < 'a' || ch > 'z')
+ else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
return -1;