From: kramm Date: Tue, 13 Jan 2009 22:42:20 +0000 (+0000) Subject: added param to pool_dump, fixed bug in float comparison (NaN support) X-Git-Tag: release-0-9-0~289 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;ds=sidebyside;h=0d0db46ffab07e85ece7961eb9c22b64749d918b;p=swftools.git added param to pool_dump, fixed bug in float comparison (NaN support) --- diff --git a/lib/as3/pool.c b/lib/as3/pool.c index 2ed429e..a17797f 100644 --- a/lib/as3/pool.c +++ b/lib/as3/pool.c @@ -55,7 +55,10 @@ char float_equals(const void*_v1, const void*_v2) { const double*v2=_v2; if(!v1 || !v2) return v1==v2; - return *v1==*v2; + + if(*v1==*v2) return 1; + if(*v1!=*v1 && *v2!=*v2) return 1; //both values are NaN + return 0; } type_t float_type = { @@ -1121,43 +1124,43 @@ void pool_read(pool_t*pool, TAG*tag) } } -void pool_dump(pool_t*pool, FILE*fo) +void pool_dump(pool_t*pool, FILE*fo, char flags) { int t; fprintf(fo, "%d integers:\n", pool->x_ints->num); for(t=1;tx_ints->num;t++) { S32 val = *(int*)array_getkey(pool->x_ints, t); - fprintf(fo, "%d) %d\n", t, val); + if(flags&1) fprintf(fo, "%d) %d\n", t, val); } - fprintf(fo, "%d integers:\n", pool->x_uints->num); + fprintf(fo, "%d unsigned integers:\n", pool->x_uints->num); for(t=1;tx_uints->num;t++) { U32 val = *(unsigned int*)array_getkey(pool->x_uints, t); - fprintf(fo, "%d) %d\n", t, val); + if(flags&1) fprintf(fo, "%d) %d\n", t, val); } fprintf(fo, "%d floats:\n", pool->x_floats->num); for(t=1;tx_floats->num;t++) { double d = pool_lookup_float(pool, t); - fprintf(fo, "%d) %f\n", t, d); + if(flags&2) fprintf(fo, "%d) %f\n", t, d); } fprintf(fo, "%d strings:\n", pool->x_strings->num); for(t=1;tx_strings->num;t++) { string_t str = pool_lookup_string2(pool, t); - fprintf(fo, "%d) ", t); - fwrite(str.str, str.len, 1, fo); - fprintf(fo, "\n", t); + if(flags&1) fprintf(fo, "%d) ", t); + if(flags&1) fwrite(str.str, str.len, 1, fo); + if(flags&1) fprintf(fo, "\n", t); } fprintf(fo, "%d namespaces:\n", pool->x_namespaces->num); for(t=1;tx_namespaces->num;t++) { namespace_t*ns= (namespace_t*)array_getkey(pool->x_namespaces, t); char*s = namespace_tostring(ns); - fprintf(fo, "%d) %s\n", t, s); + if(flags&1) fprintf(fo, "%d) %s\n", t, s); free(s); } fprintf(fo, "%d namespace sets:\n", pool->x_namespace_sets->num); for(t=1;tx_namespace_sets->num;t++) { namespace_set_t*set = (namespace_set_t*)array_getkey(pool->x_namespace_sets, t); char*s = namespace_set_tostring(set); - fprintf(fo, "%d) %s\n", t, s); + if(flags&1) fprintf(fo, "%d) %s\n", t, s); free(s); } @@ -1165,7 +1168,7 @@ void pool_dump(pool_t*pool, FILE*fo) for(t=1;tx_multinames->num;t++) { multiname_t*m = (multiname_t*)array_getkey(pool->x_multinames, t); char*s = multiname_tostring(m); - fprintf(fo, "%d) %s\n", t, s); + if(flags&1) fprintf(fo, "%d) %s\n", t, s); free(s); } } diff --git a/lib/as3/pool.h b/lib/as3/pool.h index 3758c2c..c6b2238 100644 --- a/lib/as3/pool.h +++ b/lib/as3/pool.h @@ -204,6 +204,6 @@ pool_t*pool_new(); void pool_read(pool_t*pool, TAG*tag); void pool_write(pool_t*pool, TAG*tag); void pool_destroy(pool_t*pool); -void pool_dump(pool_t*pool, FILE*fo); +void pool_dump(pool_t*pool, FILE*fo, char flags); #endif