[PD-cvs] SF.net SVN: pure-data:[10232] trunk/externals/zexy/src/listfind.c
zmoelnig at users.sourceforge.net
zmoelnig at users.sourceforge.net
Mon Aug 4 17:38:54 CEST 2008
Revision: 10232
http://pure-data.svn.sourceforge.net/pure-data/?rev=10232&view=rev
Author: zmoelnig
Date: 2008-08-04 15:38:50 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
fixed bug where equality of A_FLOAT atoms was not detected correctly
Modified Paths:
--------------
trunk/externals/zexy/src/listfind.c
Modified: trunk/externals/zexy/src/listfind.c
===================================================================
--- trunk/externals/zexy/src/listfind.c 2008-08-04 08:40:15 UTC (rev 10231)
+++ trunk/externals/zexy/src/listfind.c 2008-08-04 15:38:50 UTC (rev 10232)
@@ -81,24 +81,53 @@
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; i<count; i++, a1++, a2++) {
- if(a1->a_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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Pd-cvs
mailing list