diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/read_key.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libbb/read_key.c b/libbb/read_key.c index 598bd94f5..614e2f9e0 100644 --- a/libbb/read_key.c +++ b/libbb/read_key.c | |||
@@ -33,14 +33,16 @@ int FAST_FUNC read_key(int fd, smalluint *nbuffered, char *buffer) | |||
33 | '[','B' |0x80,KEYCODE_DOWN , | 33 | '[','B' |0x80,KEYCODE_DOWN , |
34 | '[','C' |0x80,KEYCODE_RIGHT , | 34 | '[','C' |0x80,KEYCODE_RIGHT , |
35 | '[','D' |0x80,KEYCODE_LEFT , | 35 | '[','D' |0x80,KEYCODE_LEFT , |
36 | '[','H' |0x80,KEYCODE_HOME , | 36 | '[','H' |0x80,KEYCODE_HOME , /* xterm */ |
37 | '[','F' |0x80,KEYCODE_END , | 37 | '[','F' |0x80,KEYCODE_END , /* xterm */ |
38 | '[','1','~' |0x80,KEYCODE_HOME , | 38 | '[','1','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */ |
39 | '[','2','~' |0x80,KEYCODE_INSERT , | 39 | '[','2','~' |0x80,KEYCODE_INSERT , |
40 | '[','3','~' |0x80,KEYCODE_DELETE , | 40 | '[','3','~' |0x80,KEYCODE_DELETE , |
41 | '[','4','~' |0x80,KEYCODE_END , | 41 | '[','4','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */ |
42 | '[','5','~' |0x80,KEYCODE_PAGEUP , | 42 | '[','5','~' |0x80,KEYCODE_PAGEUP , |
43 | '[','6','~' |0x80,KEYCODE_PAGEDOWN, | 43 | '[','6','~' |0x80,KEYCODE_PAGEDOWN, |
44 | '[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */ | ||
45 | '[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */ | ||
44 | #if 0 | 46 | #if 0 |
45 | '[','1','1','~'|0x80,KEYCODE_FUN1 , | 47 | '[','1','1','~'|0x80,KEYCODE_FUN1 , |
46 | '[','1','2','~'|0x80,KEYCODE_FUN2 , | 48 | '[','1','2','~'|0x80,KEYCODE_FUN2 , |
@@ -58,7 +60,9 @@ int FAST_FUNC read_key(int fd, smalluint *nbuffered, char *buffer) | |||
58 | 0 | 60 | 0 |
59 | }; | 61 | }; |
60 | 62 | ||
61 | n = *nbuffered; | 63 | n = 0; |
64 | if (nbuffered) | ||
65 | n = *nbuffered; | ||
62 | if (n == 0) { | 66 | if (n == 0) { |
63 | /* If no data, block waiting for input. If we read more | 67 | /* If no data, block waiting for input. If we read more |
64 | * than the minimal ESC sequence size, the "n=0" below | 68 | * than the minimal ESC sequence size, the "n=0" below |
@@ -141,6 +145,7 @@ int FAST_FUNC read_key(int fd, smalluint *nbuffered, char *buffer) | |||
141 | * by now. */ | 145 | * by now. */ |
142 | 146 | ||
143 | ret: | 147 | ret: |
144 | *nbuffered = n; | 148 | if (nbuffered) |
149 | *nbuffered = n; | ||
145 | return c; | 150 | return c; |
146 | } | 151 | } |