X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fas3%2Fpool.c;h=3889ee641c45e72e46a9662178178528139c0ea3;hp=2402328df8535ba010a37ff9627faa1ba41b6b7c;hb=2391d7ae5d8a145a250a8b80ab8c93ba74eba030;hpb=f094f8e205d63e14b8d765b587cfd9f32022a67b diff --git a/lib/as3/pool.c b/lib/as3/pool.c index 2402328..3889ee6 100644 --- a/lib/as3/pool.c +++ b/lib/as3/pool.c @@ -136,7 +136,7 @@ char*escape_string(const char*str) if(!str) return strdup("NULL"); int len=0; - unsigned const char*s=str; + unsigned const char*s=(unsigned const char*)str; while(*s) { if(*s<10) { len+=2; // \d @@ -151,7 +151,7 @@ char*escape_string(const char*str) } char*newstr = malloc(len+1); char*dest = newstr; - s=str; + s=(unsigned const char*)str; while(*s) { if(*s<9) { dest+=sprintf(dest, "\\%d", *s); @@ -185,9 +185,9 @@ char* namespace_tostring(namespace_t*ns) char*s = escape_string(ns->name); char*string = (char*)malloc(strlen(access)+strlen(s)+7); if(!s) - sprintf(string, "[%s]NULL", access, s); + sprintf(string, "[%s]NULL", access); else if(!*s) - sprintf(string, "[%s]\"\"", access, s); + sprintf(string, "[%s]\"\"", access); else sprintf(string, "[%s]%s", access, s); free(s); @@ -487,6 +487,7 @@ char* access2str(int type) else if(type==0x19) return "explicit"; else if(type==0x1A) return "staticprotected"; else if(type==0x05) return "private"; + else if(type==0x00) return "any"; else { fprintf(stderr, "Undefined access type %02x\n", type); return "undefined"; @@ -902,7 +903,7 @@ int pool_register_namespace(pool_t*pool, namespace_t*ns) { if(!ns) return 0; int pos = array_append_or_increase(pool->x_namespaces, ns); - assert(pos!=0); + assert(pos!=0 || ns->access==ZERONAMESPACE); return pos; } int pool_register_namespace_set(pool_t*pool, namespace_set_t*set) @@ -952,7 +953,7 @@ int pool_find_float(pool_t*pool, double x) { int i = array_find(pool->x_ints, &x); if(i<=0) { - fprintf(stderr, "Couldn't find int \"%d\" in constant pool\n", x); + fprintf(stderr, "Couldn't find int \"%f\" in constant pool\n", x); return 0; } return i; @@ -962,9 +963,9 @@ int pool_find_namespace(pool_t*pool, namespace_t*ns) if(!ns) return 0; int i = array_find(pool->x_namespaces, ns); - if(i<=0) { + if(i<0) { char*s = namespace_tostring(ns); - fprintf(stderr, "Couldn't find namespace \"%s\" %08x in constant pool\n", s, ns); + fprintf(stderr, "Couldn't find namespace \"%s\" %08x in constant pool\n", s, (int)ns); free(s); return 0; } @@ -990,7 +991,7 @@ int pool_find_string(pool_t*pool, const char*str) string_t s = string_new2(str); int i = array_find(pool->x_strings, &s); if(i<=0) { - fprintf(stderr, "Couldn't find string \"%s\" in constant pool\n", s); + fprintf(stderr, "Couldn't find string \"%s\" in constant pool\n", str); return 0; } return i; @@ -1048,6 +1049,7 @@ multiname_t*pool_lookup_multiname(pool_t*pool, int i) return (multiname_t*)array_getkey(pool->x_multinames, i); } +static namespace_t zeronamespace={ZERONAMESPACE,"*"}; pool_t*pool_new() { NEW(pool_t, p); @@ -1066,7 +1068,7 @@ pool_t*pool_new() array_append(p->x_uints, 0, 0); array_append(p->x_floats, 0, 0); array_append(p->x_strings, 0, 0); - array_append(p->x_namespaces, 0, 0); + array_append(p->x_namespaces, &zeronamespace, 0); array_append(p->x_namespace_sets, 0, 0); array_append(p->x_multinames, 0, 0); return p; @@ -1117,7 +1119,7 @@ void pool_read(pool_t*pool, TAG*tag) DEBUG printf("%d strings\n", num_strings); for(t=1;tdata[tag->pos], len); + string_t s = string_new((char*)&tag->data[tag->pos], len); swf_GetBlock(tag, 0, len); array_append(pool->x_strings, &s, 0); DEBUG printf("%d) \"%s\"\n", t, ((string_t*)array_getkey(pool->x_strings, t))->str); @@ -1230,7 +1232,7 @@ void pool_dump(pool_t*pool, FILE*fo, char flags) int freq = (int)(ptroff_t)array_getvalue(pool->x_strings, t); if(flags&1) fprintf(fo, "%5d %d) ", freq, t); if(flags&1) fwrite(str.str, str.len, 1, fo); - if(flags&1) fprintf(fo, "\n", t); + if(flags&1) fprintf(fo, "\n"); } fprintf(fo, "%d namespaces\n", pool->x_namespaces->num); for(t=1;tx_namespaces->num;t++) {