aboutsummaryrefslogtreecommitdiff
path: root/libbb/read_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/read_key.c')
-rw-r--r--libbb/read_key.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libbb/read_key.c b/libbb/read_key.c
index a2253ce3e..98b3131de 100644
--- a/libbb/read_key.c
+++ b/libbb/read_key.c
@@ -246,3 +246,12 @@ int64_t FAST_FUNC read_key(int fd, char *buffer)
buffer[-1] = 0;
goto start_over;
}
+
+void FAST_FUNC read_key_ungets(char *buffer, const char *str, unsigned len)
+{
+ unsigned cur_len = (unsigned char)buffer[0];
+ if (len > KEYCODE_BUFFER_SIZE-1 - cur_len)
+ len = KEYCODE_BUFFER_SIZE-1 - cur_len;
+ memcpy(buffer + 1 + cur_len, str, len);
+ buffer[0] += cur_len + len;
+}