fixed FreeTag bug
[swftools.git] / src / swfdump.c
index a74c453..0a2ed76 100644 (file)
@@ -167,6 +167,7 @@ void args_callback_usage(char *name)
     printf("-D , --full                    Show everything. Same as -atp\n");
     printf("-V , --version                 Print version info and exit\n");
     printf("-e , --html                    Print out html code for embedding the file\n");
+    printf("-E , --xhtml                   Print out xhtml code for embedding the file\n");
     printf("-a , --action                  Disassemble action tags\n");
     printf("-t , --text                    Show text fields (like swfstrings).\n");
     printf("-s , --shapes                  Show shape coordinates/styles\n");
@@ -275,8 +276,12 @@ void textcallback(void*self, int*glyphs, int*ypos, int nr, int fontid, int fonts
            if(glyphs[t] >= fonts[font]->numchars  /*glyph is in range*/
                    || !fonts[font]->glyph2ascii /* font has ascii<->glyph mapping */
              ) a = glyphs[t];
-           else
-               a = fonts[font]->glyph2ascii[glyphs[t]];
+           else {
+               if(fonts[font]->glyph2ascii[glyphs[t]])
+                   a = fonts[font]->glyph2ascii[glyphs[t]];
+               else
+                   a = glyphs[t];
+           }
        } else {
            a = glyphs[t];
        }
@@ -920,11 +925,6 @@ int main (int argc,char ** argv)
            printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, swf_TagGetName(tag));
        }
        
-       if(tag->id == ST_FREECHARACTER) {
-           U16 id = swf_GetU16(tag);
-           idtab[id] = 0;
-       }
-
         if(swf_isDefiningTag(tag)) {
             U16 id = swf_GetDefineID(tag);
             printf(" defines id %04d", id);
@@ -1171,6 +1171,13 @@ int main (int argc,char ** argv)
                printf("\n");
            }
        }
+       
+       if(tag->id == ST_FREECHARACTER) {
+           U16 id;
+           swf_SetTagPos(tag, 0);
+           id = swf_GetU16(tag);
+           idtab[id] = 0;
+       }
 
        if(tag->len && hex) {
            hexdumpTag(tag, prefix);