X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=pdf2swf%2Fxpdf%2FFoFiType1.cc;h=a8a69fd0904aaf1100db882a5c52dcc3c32020e0;hb=85c46a8011c7fd5e4bda282266006c972ea7606b;hp=fe54a632406ca409b133c71026cd6f56d553ba8f;hpb=b0d012f83219d898e9cd92281d9996bc9ff13b5f;p=swftools.git diff --git a/pdf2swf/xpdf/FoFiType1.cc b/pdf2swf/xpdf/FoFiType1.cc index fe54a63..a8a69fd 100644 --- a/pdf2swf/xpdf/FoFiType1.cc +++ b/pdf2swf/xpdf/FoFiType1.cc @@ -108,6 +108,9 @@ void FoFiType1::writeEncoded(char **newEncoding, for (line = getNextLine(line); line && strncmp(line, "readonly def", 12); line = getNextLine(line)) ; + if (line) { + line = getNextLine(line); + } } if (line) { (*outputFunc)(outputStream, line, ((char *)file + len) - line); @@ -156,13 +159,13 @@ void FoFiType1::parse() { encoding = fofiType1StandardEncoding; } else if (!encoding && !strncmp(line, "/Encoding 256 array", 19)) { - encoding = (char **)gmalloc(256 * sizeof(char *)); + encoding = (char **)gmallocn(256, sizeof(char *)); for (j = 0; j < 256; ++j) { encoding[j] = NULL; } - line = getNextLine(line); - for (j = 0; j < 300 && line; ++j) { - line1 = getNextLine(line); + for (j = 0, line = getNextLine(line); + j < 300 && line && (line1 = getNextLine(line)); + ++j, line = line1) { if ((n = line1 - line) > 255) { n = 255; } @@ -187,20 +190,22 @@ void FoFiType1::parse() { } } } else { - if (strtok(buf, " \t") && - (p = strtok(NULL, " \t\n\r")) && !strcmp(p, "def")) { - break; + p = strtok(buf, " \t\n\r"); + if (p) + { + if (!strcmp(p, "def")) break; + if (!strcmp(p, "readonly")) break; + // the spec does not says this but i'm mantaining old xpdf behaviour that accepts "foo def" as end of the encoding array + p = strtok(buf, " \t\n\r"); + if (p && !strcmp(p, "def")) break; } } - line = line1; } //~ check for getinterval/putinterval junk } else { line = getNextLine(line); } - - ++i; } parsed = gTrue;