From 58f108eb339957f58d5a6034d82b09c4d50b53e3 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Thu, 11 Mar 2010 21:17:55 +0100
Subject: lineedit: fix another corner case with bad unicode input

function                                             old     new   delta
read_key                                             607     646     +39
readit                                                50      55      +5
getch_nowait                                         290     295      +5
hash_find                                            233     234      +1
xstrtoul_range_sfx                                   231     230      -1
passwd_main                                         1058    1056      -2
builtin_exit                                          45      43      -2
cmp_main                                             649     645      -4
lineedit_read_key                                    257     245     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/5 up/down: 50/-21)             Total: 29 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 include/libbb.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'include')

diff --git a/include/libbb.h b/include/libbb.h
index fccc816cb..044d09047 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1275,8 +1275,12 @@ enum {
  * Return of -1 means EOF or error (errno == 0 on EOF).
  * buffer[0] is used as a counter of buffered chars and must be 0
  * on first call.
+ * timeout:
+ * -2: do not poll for input;
+ * -1: poll(-1) (i.e. block);
+ * >=0: poll for TIMEOUT milliseconds, return -1/EAGAIN on timeout
  */
-int64_t read_key(int fd, char *buffer) FAST_FUNC;
+int64_t read_key(int fd, char *buffer, int timeout) FAST_FUNC;
 void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC;
 
 
-- 
cgit v1.2.3