From 136cfab4c5f22061327135e43239dde36c47c08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 4 Aug 2008 15:38:50 +0000 Subject: fixed bug where equality of A_FLOAT atoms was not detected correctly svn path=/trunk/externals/zexy/; revision=10232 --- src/listfind.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/listfind.c b/src/listfind.c index e362bc1..426312c 100644 --- a/src/listfind.c +++ b/src/listfind.c @@ -81,24 +81,53 @@ static int atom_equals(t_atom*a1, t_atom*a2) { static int list_equals(int count, t_atom*a1, t_atom*a2) { int i=0; + DEBUGFUN(post("list(%d) equals?", count)); + DEBUGFUN(postatom(count, a1)); + DEBUGFUN(endpost()); + DEBUGFUN(postatom(count, a2)); + DEBUGFUN(endpost()); + DEBUGFUN(endpost()); + for(i=0; ia_type!=a2->a_type) + if(a1->a_type!=a2->a_type) { + DEBUGFUN(post("atomtypes do not match!")); return 0; - if(a1->a_w.w_symbol!=a2->a_w.w_symbol) /* is it that simple? */ + } + if(A_FLOAT==a1->a_type) { + if(atom_getfloat(a1)!=atom_getfloat(a2)) { + return 0; + } + } else + if(a1->a_w.w_symbol!=a2->a_w.w_symbol) { /* is it that simple? */ + DEBUGFUN(post("atom values do not match: %x != %x", + a1->a_w.w_symbol, + a2->a_w.w_symbol + )); return 0; + } } + DEBUGFUN(post("lists match")); return 1; } static int listfind_find(int argc, t_atom*argv, int matchc, t_atom*matchv) { int i=0; - if(matchc>argc) + DEBUGFUN(post("match: %d vs %d elements", argc, matchc)); + + if(matchc>argc) { + DEBUGFUN(post("list find -1")); + return -1; - if(matchc==0) + } + if(matchc==0) { + DEBUGFUN(post("list find 0")); + return 0; + } for(i=0; i<=(argc-matchc); i++, argv++) { + DEBUGFUN(post("checking at %d", i)); if(list_equals(matchc, argv, matchv)) return i; } -- cgit v1.2.1