=== modified file 't/13cmpkey.c' --- t/13cmpkey.c 2011-09-06 21:49:05 +0000 +++ t/13cmpkey.c 2011-04-07 22:31:43 +0000 @@ -6,7 +6,7 @@ TermKey *tk; TermKeyKey key1, key2; - plan_tests(12); + plan_tests(10); tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); @@ -44,18 +44,6 @@ ok(termkey_keycmp(tk, &key1, &key2) < 0, "cmpkey orders KEYSYM after UNICODE"); ok(termkey_keycmp(tk, &key2, &key1) > 0, "cmpkey orders UNICODE before KEYSYM"); - key1.type = TERMKEY_TYPE_KEYSYM; - key1.code.sym = TERMKEY_SYM_SPACE; - key1.modifiers = 0; - key2.type = TERMKEY_TYPE_UNICODE; - key2.code.codepoint = ' '; - key2.modifiers = 0; - - is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical"); - - termkey_set_canonflags(tk, termkey_get_canonflags(tk) | TERMKEY_CANON_SPACESYMBOL); - is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical under SPACESYMBOL"); - termkey_destroy(tk); return exit_status(); === modified file 'termkey.c' --- termkey.c 2011-09-06 21:49:05 +0000 +++ termkey.c 2011-09-05 13:14:09 +0000 @@ -1244,34 +1244,28 @@ return (char *)str; } -int termkey_keycmp(TermKey *tk, const TermKeyKey *key1p, const TermKeyKey *key2p) +int termkey_keycmp(TermKey *tk, const TermKeyKey *key1, const TermKeyKey *key2) { - /* Copy the key structs since we'll be modifying them */ - TermKeyKey key1 = *key1p, key2 = *key2p; - - termkey_canonicalise(tk, &key1); - termkey_canonicalise(tk, &key2); - - if(key1.type != key2.type) - return key1.type - key2.type; - - switch(key1.type) { + if(key1->type != key2->type) + return key1->type - key2->type; + + switch(key1->type) { case TERMKEY_TYPE_UNICODE: - if(key1.code.codepoint != key2.code.codepoint) - return key1.code.codepoint - key2.code.codepoint; + if(key1->code.codepoint != key2->code.codepoint) + return key1->code.codepoint - key2->code.codepoint; case TERMKEY_TYPE_KEYSYM: - if(key1.code.sym != key2.code.sym) - return key1.code.sym - key2.code.sym; + if(key1->code.sym != key2->code.sym) + return key1->code.sym - key2->code.sym; case TERMKEY_TYPE_FUNCTION: - if(key1.code.number != key2.code.number) - return key1.code.number - key2.code.number; + if(key1->code.number != key2->code.number) + return key1->code.number - key2->code.number; case TERMKEY_TYPE_MOUSE: { - int cmp = strncmp(key1.code.mouse, key2.code.mouse, 4); + int cmp = strncmp(key1->code.mouse, key2->code.mouse, 4); if(cmp != 0) return cmp; } } - return key1.modifiers - key2.modifiers; + return key1->modifiers - key2->modifiers; } === modified file 'termkey_keycmp.3' --- termkey_keycmp.3 2011-09-06 21:49:05 +0000 +++ termkey_keycmp.3 2011-04-04 18:06:34 +0000 @@ -11,7 +11,7 @@ .sp Link with \fI-ltermkey\fP. .SH DESCRIPTION -\fBtermkey_keycmp\fP() compares two key structures and applies a total ordering, returning a value that is positive, zero, or negative, to indicate if the given structures are increasing, identical, or decreasing. Before comparison, copies of both referenced structures are taken, and canonicalised according to the rules for \fBtermkey_canonicalise\fP(3). +\fBtermkey_keycmp\fP() compares two key structures and applies a total ordering, returning a value that is positive, zero, or negative, to indicate if the given structures are increasing, identical, or decreasing. .PP Two structures of differing type are ordered \fBTERMKEY_TYPE_UNICODE\fP, \fBTERMKEY_TYPE_KEYSYM\fP, \fBTERMKEY_TYPE_FUNCTION\fP, \fBTERMKEY_TYPE_MOUSE\fP. Unicode structures are ordered by codepoint, keysym structures are ordered by keysym number, function structures are ordered by function key number, and mouse structures are ordered opaquely by an unspecified but consistent ordering. Within these values, keys different in modifier bits are ordered by the modifiers. .SH "RETURN VALUE" @@ -21,5 +21,4 @@ .SH "SEE ALSO" .BR termkey_new (3), .BR termkey_getkey (3), -.BR termkey_strpkey (3), -.BR termkey_canonicalise (3) +.BR termkey_strpkey (3)