small fixes
authorMatthias Kramm <kramm@quiss.org>
Sun, 29 Mar 2009 18:57:12 +0000 (20:57 +0200)
committerMatthias Kramm <kramm@quiss.org>
Sun, 29 Mar 2009 18:57:12 +0000 (20:57 +0200)
13 files changed:
configure
configure.in
lib/as3/abc.c
lib/as3/test
lib/modules/swfshape.c
lib/pdf/BitmapOutputDev.cc
lib/pdf/GFXOutputDev.cc
lib/q.c
lib/q.h
lib/rfxswf.c
release.in
setup.py
src/swfbytes.c

index 61c9bb1..94db70c 100755 (executable)
--- a/configure
+++ b/configure
@@ -10002,6 +10002,7 @@ fi
 done
 
     else
+        USES_EXTERNAL_LIBART=1
        CPPFLAGS="$CPPFLAGS $LIBART_CFLAGS"
         cat >>confdefs.h <<\_ACEOF
 #define INTERNAL_LIBART 0
@@ -10555,6 +10556,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
     else
+        USES_EXTERNAL_POPPLER=1
        CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
         cat >>confdefs.h <<\_ACEOF
 #define HAVE_POPPLER 1
@@ -10927,8 +10929,8 @@ else
     if test "x$PYTHON_LIB" '!=' "x" -o "x$PYTHON_INCLUDES" '!=' "x";then
         echo "Set both PYTHON_LIB and PYTHON_INCLUDES, or none at all"
     fi
-    # iterate through version 2.2 to 2.5
-    for v in 2 3 4 5; do
+    # iterate through version 2.2 to 2.6
+    for v in 2 3 4 5 6; do
         # Linux
         if test -f "/usr/include/python2.$v/Python.h";then
             PY_VERSION=2.$v
 
 
 
+if test "$USES_EXTERNAL_POPPLER";then
+    echo "*"
+    echo "*"
+    echo "* uses external poppler library"
+    echo "*"
+    echo "*"
+fi
+if test "$USES_EXTERNAL_LIBART";then
+    echo "*"
+    echo "*"
+    echo "* uses external libart library"
+    echo "*"
+    echo "*"
+fi
 
 if test -f "release.in"; then release_in="./release"; fi
 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
index d6f66d8..010aaa0 100644 (file)
@@ -540,7 +540,6 @@ AH_BOTTOM([
 #endif // __config_h__
 ])
 
-
 if test -f "release.in"; then release_in="./release"; fi
 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
 FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile} lib/art/Makefile lib/readers/Makefile"
index 2962331..207c277 100644 (file)
@@ -949,6 +949,10 @@ static pool_t*writeABC(TAG*abctag, void*code, pool_t*pool)
                 NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
                 // don't bother to set m->index
                 body->method = m; m->body = body;
+               if(c->superclass && c->superclass->name && !strcmp(c->superclass->name,"Object")) {
+                   __ getlocal_0(body);
+                   __ constructsuper(body, 0);
+               }
                 __ returnvoid(body);
                 c->constructor = m;
             } else {
index 8f96670..e30b451 100755 (executable)
@@ -28,6 +28,11 @@ import marshal
 import select
 from optparse import OptionParser
 
+CMD_ARGS=[]
+#CMD = "./parser"
+CMD="as3compile"
+CMD_ARGS=["-o","abc.swf"]
+
 def check(s):
     row = None
     ok = 0
@@ -101,7 +106,7 @@ class Cache:
         try:
             self.milestone = marshal.load(open(self.filename_milestone, "rb"))
         except IOError:
-            self.milstone = {}
+            self.milestone = {}
 
     def parse_args(self):
         parser = OptionParser()
@@ -171,7 +176,7 @@ class TestBase:
     def compile(self):
         try: os.unlink("abc.swf");
         except: pass
-        ret,output = runcmd("./parser",[self.file],wait=cache.runtime)
+        ret,output = runcmd(CMD,CMD_ARGS+[self.file],wait=cache.runtime)
         self.compile_error = 0
         self.compile_output = output
         self.exit_status = 0
index b715248..bcca89f 100644 (file)
@@ -349,7 +349,12 @@ int swf_ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y)
   
   b = swf_CountBits(x,0);
   b = swf_CountBits(y,b);
-  
+
+  if(b>31) {
+      fprintf(stderr, "Warning: bad moveTo (%f,%f)\n", x/20.0, y/20.0);
+      b=31;
+  }
+    
   swf_SetBits(t,b,5);
   swf_SetBits(t,x,b);
   swf_SetBits(t,y,b);
index ac5744b..5831a59 100644 (file)
@@ -1412,7 +1412,9 @@ void BitmapOutputDev::drawChar(GfxState *state, double x, double y,
    
        /* calculate the bbox of this character */
        int x1 = (int)x, x2 = (int)x+1, y1 = (int)y, y2 = (int)y+1;
-       SplashPath*path = clip0dev->getCurrentFont()->getGlyphPath(code);
+        SplashFont*font = clip0dev->getCurrentFont();
+       SplashPath*path = font?font->getGlyphPath(code):NULL;
+
         if(!path) {
             if(code)
                 msg("<error> couldn't create outline for char %d", code);
index 73c94e2..9c8b9c7 100644 (file)
@@ -1328,7 +1328,6 @@ void GFXOutputDev::beginString(GfxState *state, GString *s)
     if(current_text_stroke) {
        msg("<error> Error: Incompatible change of text rendering to %d while inside cliptext", render);
     }
-
     msg("<trace> beginString(%s) render=%d", makeStringPrintable(s->getCString()), render);
 }
 
@@ -1377,11 +1376,12 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y,
     }
 
     Unicode u = uLen?(_u[0]):0;
-    msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",x,y,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont);
 
     gfxmatrix_t m = this->current_font_matrix;
     this->transformXY(state, x-originX, y-originY, &m.tx, &m.ty);
     //m.tx += originX; m.ty += originY;
+    
+    msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",m.tx,m.ty,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont);
 
     if(render == RENDER_FILL || render == RENDER_INVISIBLE) {
        device->drawchar(device, current_gfxfont, glyphid, &col, &m);
diff --git a/lib/q.c b/lib/q.c
index 519da40..0a9cb9f 100644 (file)
--- a/lib/q.c
+++ b/lib/q.c
@@ -287,7 +287,7 @@ trie_t*trie_new()
 static char _trie_put(trielayer_t**t, unsigned const char*id, void*data)
 {
     if(!*t) {
-        (*t) = rfx_calloc(sizeof(trie_t));
+        (*t) = rfx_calloc(sizeof(trielayer_t));
         (*t)->rest = (unsigned char*)strdup(id);
         (*t)->data = data;
         return 0;
@@ -333,11 +333,11 @@ void trie_put(trie_t*t, unsigned const char*id, void*data)
     } else {
         char contains = trie_contains(t, id);
         void*olddata = contains?trie_lookup(t, id):0;
-        trie_rollback_removes(t, id, data);
         _trie_put(&t->start, id, data);
         if(contains) {
             trie_rollback_adds(t, id, olddata);
         }
+        trie_rollback_removes(t, id, data);
     }
 }
 char trie_remove(trie_t*t, unsigned const char*id)
@@ -348,7 +348,7 @@ char trie_remove(trie_t*t, unsigned const char*id)
         void*olddata = trie_lookup(t, id);
         char exists = _trie_remove(t->start, id);
         if(exists) {
-            trie_rollback_removes(t, id, olddata);
+            trie_rollback_adds(t, id, olddata);
         }
         return exists;
     }
@@ -381,34 +381,58 @@ void* trie_lookup(trie_t*trie, unsigned const char*id)
 typedef struct _triememory {
     const unsigned char*key;
     void*data;
+    char del; // 0/1
     struct _triememory*next;
 } triememory_t;
 
 typedef struct _trierollback {
-    triememory_t*add;
-    triememory_t*remove;
+    triememory_t*ops;
     struct _trierollback*prev;
 } trierollback_t;
 
-static void trie_rollback_removes(trie_t*t, unsigned const char*id, void*data)
+static void trie_rollback_adds(trie_t*t, unsigned const char*id, void*data)
 {
     trierollback_t*rollback = (trierollback_t*)t->rollback;
     triememory_t*m = (triememory_t*)rfx_calloc(sizeof(triememory_t));
     m->key = id;
     m->data = data;
-    m->next = rollback->add;
-    rollback->add = m;
+    m->del = 0;
+    m->next = rollback->ops;
+    rollback->ops = m;
 }
-static void trie_rollback_adds(trie_t*t, unsigned const char*id, void*data)
+static void trie_rollback_removes(trie_t*t, unsigned const char*id, void*data)
 {
     trierollback_t*rollback = (trierollback_t*)t->rollback;
     triememory_t*m = (triememory_t*)rfx_calloc(sizeof(triememory_t));
     m->key = id;
     m->data = data;
-    m->next = rollback->remove;
-    rollback->remove = m;
+    m->del = 1;
+    m->next = rollback->ops;
+    rollback->ops = m;
 }
 
+void _trie_dump(trielayer_t*t, char*buffer, int pos)
+{
+    int i;
+    for(i=0;i<256;i++) {
+        if(t->row[i]) {
+            buffer[pos]=i;
+            _trie_dump(t->row[i], buffer, pos+1);
+        }
+    }
+    if(t->rest) {
+        buffer[pos]=0;
+        printf("%s%s %08x\n", buffer, t->rest, t->data);
+    }
+}
+
+void trie_dump(trie_t*t) 
+{
+    char buffer[256];
+    _trie_dump(t->start, buffer, 0);
+}
+
+
 void trie_remember(trie_t*t)
 {
     trierollback_t*old = (trierollback_t*)t->rollback;
@@ -425,20 +449,20 @@ void trie_rollback(trie_t*t)
     }
     t->rollback = ((trierollback_t*)t->rollback)->prev;
 
-    triememory_t*remove = rollback->remove;
-    while(remove) {
-        triememory_t*next = remove->next;
-        if(!trie_remove(t, remove->key)) {
-            fprintf(stderr, "Internal error: can't delete key %s in trie during rollback\n", remove->key);
+    triememory_t*op = rollback->ops;
+    while(op) {
+        triememory_t*next = op->next;
+        if(op->del) {
+            if(!_trie_remove(t->start, op->key)) {
+                fprintf(stderr, "Internal error: can't delete key %s in trie during rollback\n", op->key);
+            }
+        } else {
+            if(_trie_put(&t->start, op->key, op->data)) {
+                fprintf(stderr, "Internal error: overwrote key %s in trie during rollback\n", op->key);
+            }
         }
-        free(remove);
-        remove = next;
-    }
-    triememory_t*add = rollback->add;
-    while(add) {
-        triememory_t*next = add->next;
-        trie_put(t, add->key, add->data);
-        add = next;
+        free(op);
+        op = next;
     }
 }
 
diff --git a/lib/q.h b/lib/q.h
index 3d09c25..997b470 100644 (file)
--- a/lib/q.h
+++ b/lib/q.h
@@ -223,6 +223,7 @@ void*trie_lookup(trie_t*t, unsigned const char*id);
 int trie_contains(trie_t*t, unsigned const char*id);
 void trie_remember(trie_t*t);
 void trie_rollback(trie_t*t);
+void trie_dump(trie_t*t);
 
 array_t* array_new();
 array_t* array_new2(type_t*type);
@@ -257,7 +258,7 @@ void list_concat_(void*l1, void*l2);
 #define list_prepend(list, e) {sizeof((list)->next);list_prepend_(&(list),(e));}
 #define list_free(list) {sizeof((list)->next);list_free_(&(list));}
 #define list_deep_free(list) {sizeof((list)->next);list_deep_free_(&(list));}
-#define list_clone(list) (sizeof((list)->next),list_clone_(&(list)))
+#define list_clone(list) (sizeof((list)->next),(list?list_clone_(&(list)):0))
 #define list_length(list) (sizeof((list)->next),list_length_(list))
 
 #ifdef __cplusplus
index 93f5db5..b063cc0 100644 (file)
@@ -204,17 +204,22 @@ U32 swf_GetBits(TAG * t,int nbits)
   if (!t->readBit) t->readBit = 0x80;
   while (nbits)
   { res<<=1;
+#ifdef DEBUG_RFXSWF
+    if (t->pos>=t->len) 
+    { fprintf(stderr,"GetBits() out of bounds: TagID = %i, pos=%d, len=%d\n",t->id, t->pos, t->len);
+      int i,m=t->len>10?10:t->len;
+      for(i=-1;i<m;i++) {
+        fprintf(stderr, "(%d)%02x ", i, t->data[i]);
+      } 
+      fprintf(stderr, "\n");
+      return res;
+    }
+#endif
     if (t->data[t->pos]&t->readBit) res|=1;
     t->readBit>>=1;
     nbits--;
     if (!t->readBit)
     { if (nbits) t->readBit = 0x80;
-      #ifdef DEBUG_RFXSWF
-      if (t->pos>=t->len) 
-      { fprintf(stderr,"GetBits() out of bounds: TagID = %i\n",t->id);
-        return res;
-      }
-      #endif
       t->pos++;
     }
   }
@@ -368,7 +373,12 @@ int swf_GetS30(TAG*tag)
     while(1) {
        U8 b = swf_GetU8(tag);
         nr++;
-       s|=(b&127)<<shift;
+       nt i,m=t->len>10?10:t->len;
+                for(i=0;i<m;i++) {
+                            fprintf(stderr, "%02x ", t->data[i]);
+                                    } 
+                        fprintf(stderr, "\n");
+                        s|=(b&127)<<shift;
        shift+=7;
        if(!(b&128) || shift>=32) {
             if(b&64) {
index bc046fe..1f2a9e9 100644 (file)
@@ -58,7 +58,6 @@ ${name}/avi2swf/v2swf.h \
 ${name}/avi2swf/avi2swf.1"
 
 MAKEFILES="${name}/src/Makefile.in \
-${name}/pdf2swf/fonts/Makefile.in \
 ${name}/lib/readers/Makefile.in \
 ${name}/lib/art/Makefile.in \
 ${name}/lib/Makefile.in \
@@ -166,6 +165,8 @@ ${name}/lib/as3/tokenizer.h \
 ${name}/lib/as3/tokenizer.yy.c \
 ${name}/lib/as3/parser.tab.c \
 ${name}/lib/as3/parser.tab.h \
+${name}/lib/as3/scripts.c \
+${name}/lib/as3/scripts.h \
 ${name}/lib/action/action.h \
 ${name}/lib/action/actioncompiler.c \
 ${name}/lib/action/actioncompiler.h \
index 62c201d..094768f 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -121,6 +121,10 @@ class ConfigScript:
     def system_has_property(self,name):
         if name.startswith("STD"):
             return 1
+        elif name.startswith("INTERNAL"):
+            return 1
+        elif "POPPLER" in name:
+            return None
         elif name.startswith("HAVE_") and name.endswith("_H"):
             header = name[5:].lower()
             c = header.rfind("_")
index 53f1ccc..e0862ab 100644 (file)
 static char * filename = 0;
 static int verbose;
 
-struct options_t options[] =
-{
- {"v","verbose"},
- {"V","version"},
- {0,0}
+static struct options_t options[] = {
+{"h", "help"},
+{"v", "verbose"},
+{"V", "version"},
+{0,0}
 };
 
 int args_callback_option(char*name,char*val)
@@ -55,12 +55,16 @@ int args_callback_longoption(char*name,char*val)
 {
     return args_long2shortoption(options, name, val);
 }
-void args_callback_usage(char*name)
-{    
-    printf("Usage: %s [-at] file.swf\n", name);
-    printf("\t-h , --help\t\t Print help and exit\n");
-    printf("\t-v , --verbose\t\t Be more verbose\n");
-    printf("\t-V , --version\t\t Print program version and exit\n");
+void args_callback_usage(char *name)
+{
+    printf("\n");
+    printf("Usage: %s [-v] file.swf > file.hexdump\n", name);
+    printf("OR:    %s file.hexdump\n", name);
+    printf("\n");
+    printf("-h , --help                    Print help and exit\n");
+    printf("-v , --verbose                 Be more verbose\n");
+    printf("-V , --version                 Print program version and exit\n");
+    printf("\n");
 }
 int args_callback_command(char*name,char*val)
 {