=== modified file 'driver-ti.c' --- driver-ti.c 2011-09-23 22:40:54 +0000 +++ driver-ti.c 2011-08-25 21:49:17 +0000 @@ -157,14 +157,24 @@ return n; } -static int load_terminfo(TermKeyTI *ti, const char *term) +static void *new_driver(TermKey *tk, const char *term) { int err; /* Have to cast away the const. But it's OK - we know terminfo won't really * modify term */ if(setupterm((char*)term, 1, &err) != OK) - return 0; + return NULL; + + TermKeyTI *ti = malloc(sizeof *ti); + if(!ti) + return NULL; + + ti->tk = tk; + + ti->root = new_node_arr(0, 0xff); + if(!ti->root) + goto abort_free_ti; int i; for(i = 0; strfnames[i]; i++) { @@ -179,10 +189,10 @@ struct trie_node *node = NULL; - if(strcmp(name + 4, "mouse") == 0) { + if(strcmp(strfnames[i] + 4, "mouse") == 0) { node = malloc(sizeof(*node)); if(!node) - return 0; + goto abort_free_trie; node->type = TYPE_MOUSE; } @@ -192,7 +202,7 @@ int mask = 0; int set = 0; - if(!funcname2keysym(name + 4, &type, &sym, &mask, &set)) + if(!funcname2keysym(strfnames[i] + 4, &type, &sym, &mask, &set)) continue; if(sym == TERMKEY_SYM_NONE) @@ -204,10 +214,12 @@ if(node) if(!insert_seq(ti, value, node)) { free(node); - return 0; + goto abort_free_trie; } } + ti->root = compress_trie(ti->root); + /* Take copies of these terminfo strings, in case we build multiple termkey * instances for multiple different termtypes, and it's different by the * time we want to use it @@ -222,26 +234,6 @@ else ti->stop_string = NULL; - return 1; -} - -static void *new_driver(TermKey *tk, const char *term) -{ - TermKeyTI *ti = malloc(sizeof *ti); - if(!ti) - return NULL; - - ti->tk = tk; - - ti->root = new_node_arr(0, 0xff); - if(!ti->root) - goto abort_free_ti; - - if(!load_terminfo(ti, term)) - goto abort_free_trie; - - ti->root = compress_trie(ti->root); - return ti; abort_free_trie: