summaryrefslogtreecommitdiff
path: root/libbb/read_key.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-05-29 10:39:06 +0200
committerDenys Vlasenko2009-05-29 10:39:06 +0200
commit4b7db4f2ca232c630e334fa56b1eb89848d5fcc5 (patch)
tree55608587f33fc1d6f6a8e40dfdf7fea66c750d7a /libbb/read_key.c
parent171932d7ca62dbb0e0b84a0919e1f3a8a68f03f2 (diff)
downloadbusybox-4b7db4f2ca232c630e334fa56b1eb89848d5fcc5.zip
busybox-4b7db4f2ca232c630e334fa56b1eb89848d5fcc5.tar.gz
read_key: drop optimization where we read 3 bytes at once
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/read_key.c')
-rw-r--r--libbb/read_key.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libbb/read_key.c b/libbb/read_key.c
index 3771045..6f6c39e 100644
--- a/libbb/read_key.c
+++ b/libbb/read_key.c
@@ -69,11 +69,14 @@ int64_t FAST_FUNC read_key(int fd, char *buffer)
errno = 0;
n = (unsigned char) *buffer++;
if (n == 0) {
- /* If no data, block waiting for input. If we read more
- * than the minimal ESC sequence size, the "n=0" below
- * would instead have to figure out how much to keep,
- * resulting in larger code. */
- n = safe_read(fd, buffer, 3);
+ /* If no data, block waiting for input.
+ * It is tempting to read more than one byte here,
+ * but it breaks pasting. Example: at shell prompt,
+ * user presses "c","a","t" and then pastes "\nline\n".
+ * When we were reading 3 bytes here, we were eating
+ * "li" too, and cat was getting wrong input.
+ */
+ n = safe_read(fd, buffer, 1);
if (n <= 0)
return -1;
}