From 3fb6f398e95a441d9e6b739073e0ad8a56cd8d7e Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Mon, 5 Sep 2011 13:58:15 +0100 Subject: Handle TERMKEY_RES_ERROR in (debugging mode) res2str() --- termkey.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/termkey.c b/termkey.c index 573bd44..1cd7562 100644 --- a/termkey.c +++ b/termkey.c @@ -153,6 +153,8 @@ static void print_key(TermKey *tk, TermKeyKey *key) static const char *res2str(TermKeyResult res) { + static char errorbuffer[256]; + switch(res) { case TERMKEY_RES_KEY: return "TERMKEY_RES_KEY"; @@ -162,6 +164,9 @@ static const char *res2str(TermKeyResult res) return "TERMKEY_RES_AGAIN"; case TERMKEY_RES_NONE: return "TERMKEY_RES_NONE"; + case TERMKEY_RES_ERROR: + snprintf(errorbuffer, sizeof errorbuffer, "TERMKEY_RES_ERROR(errno=%d)\n", errno); + return (const char*)errorbuffer; } return "unknown"; -- cgit v1.2.3-70-g09d2