From 123ff05c2e2bbdb9d7d6d958d9f096cf854b8360 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 7 Jun 2010 01:00:33 -0700 Subject: Delay generating unknown code string until we know we need it Signed-off-by: Alan Coopersmith --- xwininfo.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xwininfo.c b/xwininfo.c index 7ca7cd9..6b2f728 100644 --- a/xwininfo.c +++ b/xwininfo.c @@ -431,11 +431,7 @@ static char _lookup_buffer[100]; static const char * LookupL (long code, const binding *table) { - const char *name; - - snprintf (_lookup_buffer, sizeof(_lookup_buffer), - "unknown (code = %ld. = 0x%lx)", code, code); - name = _lookup_buffer; + const char *name = NULL; while (table->name) { if (table->code == code) { @@ -445,6 +441,12 @@ LookupL (long code, const binding *table) table++; } + if (name == NULL) { + snprintf (_lookup_buffer, sizeof(_lookup_buffer), + "unknown (code = %ld. = 0x%lx)", code, code); + name = _lookup_buffer; + } + return (name); } -- cgit v1.2.3