diff options
author | David Walter Seikel | 2014-04-15 18:41:35 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-04-15 18:41:35 +1000 |
commit | 526f00d1a0823537518ffd21a9d46f503ad8493a (patch) | |
tree | cab92a806a09236dfb00ce33a4600911b8fbb0a6 | |
parent | Better comments about CSI. (diff) | |
download | boxes-526f00d1a0823537518ffd21a9d46f503ad8493a.zip boxes-526f00d1a0823537518ffd21a9d46f503ad8493a.tar.gz boxes-526f00d1a0823537518ffd21a9d46f503ad8493a.tar.bz2 boxes-526f00d1a0823537518ffd21a9d46f503ad8493a.tar.xz |
Fix up a couple of bugs in the buffer full case.
Diffstat (limited to '')
-rw-r--r-- | handlekeys.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/handlekeys.c b/handlekeys.c index e605966..44c0748 100644 --- a/handlekeys.c +++ b/handlekeys.c | |||
@@ -253,6 +253,8 @@ void handle_keys(long extra, int (*handle_event)(long extra, struct keyevent *ev | |||
253 | else | 253 | else |
254 | { | 254 | { |
255 | buffIndex += j; | 255 | buffIndex += j; |
256 | buffer[buffIndex] = 0; | ||
257 | |||
256 | // Send raw keystrokes, mostly for things like showkey. | 258 | // Send raw keystrokes, mostly for things like showkey. |
257 | event.type = HK_RAW; | 259 | event.type = HK_RAW; |
258 | event.sequence = buffer; | 260 | event.sequence = buffer; |
@@ -261,13 +263,13 @@ void handle_keys(long extra, int (*handle_event)(long extra, struct keyevent *ev | |||
261 | 263 | ||
262 | if (sizeof(buffer) < (buffIndex + 1)) // Ran out of buffer. | 264 | if (sizeof(buffer) < (buffIndex + 1)) // Ran out of buffer. |
263 | { | 265 | { |
266 | buffer[buffIndex] = 0; | ||
264 | fprintf(stderr, "Full buffer - %s -> %s\n", buffer, sequence); | 267 | fprintf(stderr, "Full buffer - %s -> %s\n", buffer, sequence); |
265 | for (j = 0; buffer[j + 1]; j++) | 268 | for (j = 0; buffer[j]; j++) |
266 | fprintf(stderr, "(%x) %c, ", (int) buffer[j], buffer[j]); | 269 | fprintf(stderr, "(%x) %c, ", (int) buffer[j], buffer[j]); |
267 | fflush(stderr); | 270 | fflush(stderr); |
268 | buffIndex = 0; | 271 | buffer[0] = buffIndex = 0; |
269 | } | 272 | } |
270 | buffer[buffIndex] = 0; | ||
271 | } | 273 | } |
272 | } | 274 | } |
273 | 275 | ||