summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-07 01:00:33 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-13 13:08:52 -0700
commit123ff05c2e2bbdb9d7d6d958d9f096cf854b8360 (patch)
tree504d8a812f89cc4f7eb0e5ef9573cb92abafeadf
parent369c37a62cdd2841a3e8778674029841231f45ad (diff)
Delay generating unknown code string until we know we need it
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xwininfo.c12
1 files 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);
}