added parsing for flash 8 fill styles
[swftools.git] / pdf2swf / xpdf / Lexer.cc
index d037469..ee9dc59 100644 (file)
@@ -2,15 +2,16 @@
 //
 // Lexer.cc
 //
-// Copyright 1996-2002 Glyph & Cog, LLC
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
 #pragma implementation
 #endif
 
-#include <aconf.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
@@ -73,6 +74,7 @@ Lexer::Lexer(XRef *xref, Object *obj) {
     curStr.streamReset();
   }
 }
+static int illegalChars = 0;
 
 Lexer::~Lexer() {
   if (!curStr.isNone()) {
@@ -82,6 +84,9 @@ Lexer::~Lexer() {
   if (freeArray) {
     delete streams;
   }
+  if(illegalChars)
+      error(0, "Illegal characters in hex string (%d)", illegalChars);
+  illegalChars = 0;
 }
 
 int Lexer::getChar() {
@@ -170,6 +175,13 @@ Object *Lexer::getObj(Object *obj) {
     scale = 0.1;
     while (1) {
       c = lookChar();
+      if (c == '-') {
+       // ignore minus signs in the middle of numbers to match
+       // Adobe's behavior
+       error(getPos(), "Badly formatted number");
+       getChar();
+       continue;
+      }
       if (!isdigit(c)) {
        break;
       }
@@ -322,7 +334,8 @@ Object *Lexer::getObj(Object *obj) {
        } else if (c2 >= 'a' && c2 <= 'f') {
          c += c2 - 'a' + 10;
        } else {
-         error(getPos(), "Illegal digit in hex char in name");
+         illegalChars++;
+         //error(getPos(), "Illegal digit in hex char in name");
        }
       }
      notEscChar:
@@ -376,8 +389,10 @@ Object *Lexer::getObj(Object *obj) {
            c2 += c - 'A' + 10;
          else if (c >= 'a' && c <= 'f')
            c2 += c - 'a' + 10;
-         else
-           error(getPos(), "Illegal character <%02x> in hex string", c);
+         else {
+           illegalChars++;
+           //error(getPos(), "Illegal character <%02x> in hex string", c);
+         }
          if (++m == 2) {
            if (n == tokBufSize) {
              if (!s)
@@ -413,7 +428,8 @@ Object *Lexer::getObj(Object *obj) {
       tokBuf[2] = '\0';
       obj->initCmd(tokBuf);
     } else {
-      error(getPos(), "Illegal character '>'");
+      illegalChars++;
+      //error(getPos(), "Illegal character '>'");
       obj->initError();
     }
     break;
@@ -422,7 +438,8 @@ Object *Lexer::getObj(Object *obj) {
   case ')':
   case '{':
   case '}':
-    error(getPos(), "Illegal character '%c'", c);
+    //error(getPos(), "Illegal character '%c'", c);
+    illegalChars++;
     obj->initError();
     break;
 
@@ -451,7 +468,6 @@ Object *Lexer::getObj(Object *obj) {
     }
     break;
   }
-
   return obj;
 }
 
@@ -471,3 +487,7 @@ void Lexer::skipToNextLine() {
     }
   }
 }
+
+GBool Lexer::isSpace(int c) {
+  return c >= 0 && c <= 0xff && specialChars[c] == 1;
+}