moved from ..
[swftools.git] / lib / pdf / xpdf-changes.patch
1 Index: FoFiType1C.cc
2 ===================================================================
3 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/FoFiType1C.cc,v
4 retrieving revision 1.3
5 retrieving revision 1.4
6 diff -u -r1.3 -r1.4
7 --- FoFiType1C.cc       3 Dec 2005 10:11:33 -0000       1.3
8 +++ FoFiType1C.cc       3 Dec 2005 10:30:41 -0000       1.4
9 @@ -231,8 +231,11 @@
10      (*outputFunc)(outputStream,
11                   "0 1 255 {1 index exch /.notdef put} for\n", 40);
12      enc = newEncoding ? newEncoding : encoding;
13 +    if(!enc) {
14 +       fprintf(stderr, "convertToType1: Warning: No Encoding\n");
15 +    }
16      for (i = 0; i < 256; ++i) {
17 -      if (enc[i]) {
18 +      if (enc && enc[i]) {
19         sprintf(buf, "dup %d /%s put\n", i, enc[i]);
20         (*outputFunc)(outputStream, buf, strlen(buf));
21        }
22 Index: Gfx.cc
23 ===================================================================
24 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Gfx.cc,v
25 retrieving revision 1.9
26 retrieving revision 1.10
27 diff -u -r1.9 -r1.10
28 --- Gfx.cc      3 Dec 2005 10:11:33 -0000       1.9
29 +++ Gfx.cc      3 Dec 2005 10:30:41 -0000       1.10
30 @@ -439,7 +439,9 @@
31    fontChanged = gFalse;
32    clip = clipNone;
33    ignoreUndef = 0;
34 -  out->startPage(pageNum, state);
35 +  if(cropBox) {
36 +      out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
37 +  }
38    out->setDefaultCTM(state->getCTM());
39    out->updateAll(state);
40    for (i = 0; i < 6; ++i) {
41 @@ -450,7 +450,9 @@
42    abortCheckCbkData = abortCheckCbkDataA;
43  
44    // set crop box
45 -  if (cropBox) {
46 +#ifdef XPDFEXE
47 +  if (cropBox) {
48      state->moveTo(cropBox->x1, cropBox->y1);
49      state->lineTo(cropBox->x2, cropBox->y1);
50      state->lineTo(cropBox->x2, cropBox->y2);
51 @@ -459,7 +459,7 @@
52      state->clip();
53      out->clip(state);
54      state->clearPath();
55 -  }
56 +  }
57 +#endif XPDFEXE
58  }
59  
60  Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
61 Index: GfxFont.h
62 ===================================================================
63 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxFont.h,v
64 retrieving revision 1.6
65 retrieving revision 1.7
66 diff -u -r1.6 -r1.7
67 --- GfxFont.h   3 Dec 2005 10:11:33 -0000       1.6
68 +++ GfxFont.h   3 Dec 2005 10:30:41 -0000       1.7
69 @@ -207,7 +207,7 @@
70    CharCodeToUnicode *getToUnicode();
71  
72    // Return the character name associated with <code>.
73 -  char *getCharName(int code) { return enc[code]; }
74 +  char *getCharName(int code) { return code>=256?0:enc[code]; }
75  
76    // Returns true if the PDF font specified an encoding.
77    GBool getHasEncoding() { return hasEncoding; }
78 Index: GfxState.cc
79 ===================================================================
80 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxState.cc,v
81 retrieving revision 1.10
82 retrieving revision 1.12
83 diff -u -r1.10 -r1.12
84 --- GfxState.cc 3 Dec 2005 10:11:33 -0000       1.10
85 +++ GfxState.cc 3 Dec 2005 12:41:32 -0000       1.12
86 @@ -21,6 +21,7 @@
87  #include "Array.h"
88  #include "Page.h"
89  #include "GfxState.h"
90 +#include "cmyk.h"
91  
92  //------------------------------------------------------------------------
93  
94 @@ -468,6 +469,18 @@
95                                 - 0.11 * color->c[2] + 0.5));
96  }
97  
98 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
99 +    unsigned char r,g,b;
100 +    float c = color->c[0];
101 +    float m = color->c[1];
102 +    float y = color->c[2];
103 +    float k = color->c[3];
104 +    convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
105 +    rgb->r = r/255.0;
106 +    rgb->g = g/255.0;
107 +    rgb->b = b/255.0;
108 +}*/
109 +
110  void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
111    double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
112  
113 @@ -3099,6 +3112,7 @@
114    GfxIndexedColorSpace *indexedCS;
115    GfxSeparationColorSpace *sepCS;
116    int maxPixel, indexHigh;
117 +  int maxPixelForAlloc;
118    Guchar *lookup2;
119    Function *sepFunc;
120    Object obj;
121 @@ -3111,6 +3125,7 @@
122    // bits per component and color space
123    bits = bitsA;
124    maxPixel = (1 << bits) - 1;
125 +  maxPixelForAlloc = (1 << (bits>8?bits:8));
126    colorSpace = colorSpaceA;
127  
128    // get decode map
129 @@ -3163,7 +3178,7 @@
130      lookup2 = indexedCS->getLookup();
131      colorSpace2->getDefaultRanges(x, y, indexHigh);
132      for (k = 0; k < nComps2; ++k) {
133 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
134 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
135                                            sizeof(GfxColorComp));
136        for (i = 0; i <= maxPixel; ++i) {
137         j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
138 @@ -3182,7 +3197,7 @@
139      nComps2 = colorSpace2->getNComps();
140      sepFunc = sepCS->getFunc();
141      for (k = 0; k < nComps2; ++k) {
142 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
143 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
144                                            sizeof(GfxColorComp));
145        for (i = 0; i <= maxPixel; ++i) {
146         x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
147 @@ -3192,7 +3207,7 @@
148      }
149    } else {
150      for (k = 0; k < nComps; ++k) {
151 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
152 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
153                                            sizeof(GfxColorComp));
154        for (i = 0; i <= maxPixel; ++i) {
155         lookup[k][i] = dblToCol(decodeLow[k] +
156 Index: GlobalParams.cc
157 ===================================================================
158 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.cc,v
159 retrieving revision 1.4
160 retrieving revision 1.7
161 diff -u -r1.4 -r1.7
162 --- GlobalParams.cc     3 Dec 2005 10:11:33 -0000       1.4
163 +++ GlobalParams.cc     18 Dec 2005 08:31:22 -0000      1.7
164 @@ -498,6 +498,29 @@
165    char buf[512];
166    FILE *f2;
167  
168 +  /* extract path */
169 +  if(fileName) {
170 +    char* cfgFileName = fileName->getCString();
171 +    char* pos1 = strrchr(cfgFileName, '/');
172 +    char* pos2 = strrchr(cfgFileName, '\\');
173 +    char* p = pos1>pos2?pos1:pos2;
174 +    int pos = p ? p-cfgFileName : -1;
175 +    GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
176 +    if(pos1>=0)
177 +       path->append('/');
178 +    else if(pos2>=0)
179 +       path->append('\\');
180 +    else
181 +#ifdef WIN32
182 +       path->append('\\');
183 +#else
184 +       path->append('/');
185 +#endif
186 +    this->path = path;
187 +  } else {
188 +    this->path = new GString();
189 +  }
190 +  
191    line = 1;
192    while (getLine(buf, sizeof(buf) - 1, f)) {
193  
194 @@ -659,6 +682,32 @@
195    }
196  }
197  
198 +static GString* qualify_filename(GString*path, GString*filename)
199 +{
200 +  GString*fullpath = 0;
201 +  char*prefix = "/usr/local/share/xpdf/";
202 +
203 +  if (filename->getChar(0) != '\\' && filename->getChar(0) != '/') {
204 +    /* relative path */
205 +    fullpath = path->copy();
206 +    fullpath->append(filename);
207 +  } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
208 +    /* xpdf default path */
209 +    char*s = strchr(filename->getCString()+strlen(prefix), '/');
210 +    if(s) {
211 +       fullpath = path->copy();
212 +       fullpath->append(s+1);
213 +    } else {
214 +       fullpath = filename->copy();
215 +    }
216 +  } else {
217 +    /* absolute path */
218 +    fullpath = filename->copy();
219 +  }
220 +  //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
221 +  return fullpath;
222 +}
223 +
224  void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
225                                          int line) {
226    GString *name;
227 @@ -673,7 +722,7 @@
228           fileName->getCString(), line);
229      return;
230    }
231 -  name = (GString *)tokens->get(1);
232 +  name = qualify_filename(this->path, (GString *)tokens->get(1));
233    if (!(f = fopen(name->getCString(), "r"))) {
234      error(-1, "Couldn't open 'nameToUnicode' file '%s'",
235           name->getCString());
236 @@ -705,10 +754,12 @@
237    }
238    collection = (GString *)tokens->get(1);
239    name = (GString *)tokens->get(2);
240 +
241    if ((old = (GString *)cidToUnicodes->remove(collection))) {
242      delete old;
243    }
244 -  cidToUnicodes->add(collection->copy(), name->copy());
245 +
246 +  cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
247  }
248  
249  void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
250 @@ -725,7 +776,8 @@
251    if ((old = (GString *)unicodeToUnicodes->remove(font))) {
252      delete old;
253    }
254 -  unicodeToUnicodes->add(font->copy(), file->copy());
255 +
256 +  unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
257  }
258  
259  void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
260 @@ -742,7 +794,8 @@
261    if ((old = (GString *)unicodeMaps->remove(encodingName))) {
262      delete old;
263    }
264 -  unicodeMaps->add(encodingName->copy(), name->copy());
265 +
266 +  unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
267  }
268  
269  void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
270 @@ -760,23 +813,30 @@
271      list = new GList();
272      cMapDirs->add(collection->copy(), list);
273    }
274 -  list->append(dir->copy());
275 +
276 +  list->append(qualify_filename(this->path, dir));
277  }
278  
279  void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
280                                      int line) {
281 +  GString *dir;
282 +
283    if (tokens->getLength() != 2) {
284      error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
285           fileName->getCString(), line);
286      return;
287    }
288 -  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
289 +
290 +  dir = (GString *)tokens->get(1);
291 +
292 +  toUnicodeDirs->append(qualify_filename(this->path, dir));
293  }
294  
295  void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
296                                     DisplayFontParamKind kind,
297                                     GString *fileName, int line) {
298    DisplayFontParam *param, *old;
299 +  GString *file;
300  
301    if (tokens->getLength() < 2) {
302      goto err1;
303 @@ -788,13 +848,15 @@
304      if (tokens->getLength() != 3) {
305        goto err2;
306      }
307 -    param->t1.fileName = ((GString *)tokens->get(2))->copy();
308 +    file = (GString *)tokens->get(2);
309 +    param->t1.fileName = qualify_filename(this->path, file);
310      break;
311    case displayFontTT:
312      if (tokens->getLength() != 3) {
313        goto err2;
314      }
315 -    param->tt.fileName = ((GString *)tokens->get(2))->copy();
316 +    file = (GString *)tokens->get(2);
317 +    param->tt.fileName = qualify_filename(this->path, file);
318      break;
319    }
320  
321 Index: GlobalParams.h
322 ===================================================================
323 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
324 retrieving revision 1.5
325 retrieving revision 1.6
326 diff -u -r1.5 -r1.6
327 --- GlobalParams.h      2006-10-10 19:54:29.000000000 +0200
328 +++ GlobalParams.h      2006-11-12 11:19:40.000000000 +0100
329 @@ -357,6 +357,10 @@
330    GBool loadPlugin(char *type, char *name);
331  #endif
332  
333 +  //----- config file base path
334 +
335 +  GString*path;
336 +
337    //----- static tables
338  
339    NameToCharCode *             // mapping from char name to
340 j@@ -318,1 +318,1 @@
341 -  void parseFile(GString *fileName, FILE *f);
342 +public: void parseFile(GString *fileName, FILE *f); private:
343 Index: Lexer.cc
344 ===================================================================
345 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
346 retrieving revision 1.4
347 retrieving revision 1.5
348 diff -u -r1.4 -r1.5
349 --- Lexer.cc    3 Dec 2005 10:11:33 -0000       1.4
350 +++ Lexer.cc    14 Mar 2006 12:43:23 -0000      1.5
351 @@ -74,6 +74,7 @@
352      curStr.streamReset();
353    }
354  }
355 +static int illegalChars = 0;
356  
357  Lexer::~Lexer() {
358    if (!curStr.isNone()) {
359 @@ -83,6 +84,9 @@
360    if (freeArray) {
361      delete streams;
362    }
363 +  if(illegalChars)
364 +      error(0, "Illegal characters in hex string (%d)", illegalChars);
365 +  illegalChars = 0;
366  }
367  
368  int Lexer::getChar() {
369 @@ -330,7 +334,8 @@
370         } else if (c2 >= 'a' && c2 <= 'f') {
371           c += c2 - 'a' + 10;
372         } else {
373 -         error(getPos(), "Illegal digit in hex char in name");
374 +         illegalChars++;
375 +         //error(getPos(), "Illegal digit in hex char in name");
376         }
377        }
378       notEscChar:
379 @@ -384,8 +389,10 @@
380             c2 += c - 'A' + 10;
381           else if (c >= 'a' && c <= 'f')
382             c2 += c - 'a' + 10;
383 -         else
384 -           error(getPos(), "Illegal character <%02x> in hex string", c);
385 +         else {
386 +           illegalChars++;
387 +           //error(getPos(), "Illegal character <%02x> in hex string", c);
388 +         }
389           if (++m == 2) {
390             if (n == tokBufSize) {
391               if (!s)
392 @@ -421,7 +428,8 @@
393        tokBuf[2] = '\0';
394        obj->initCmd(tokBuf);
395      } else {
396 -      error(getPos(), "Illegal character '>'");
397 +      illegalChars++;
398 +      //error(getPos(), "Illegal character '>'");
399        obj->initError();
400      }
401      break;
402 @@ -430,7 +438,8 @@
403    case ')':
404    case '{':
405    case '}':
406 -    error(getPos(), "Illegal character '%c'", c);
407 +    //error(getPos(), "Illegal character '%c'", c);
408 +    illegalChars++;
409      obj->initError();
410      break;
411  
412 @@ -459,7 +468,6 @@
413      }
414      break;
415    }
416 -
417    return obj;
418  }
419  
420 Index: Link.cc
421 ===================================================================
422 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
423 retrieving revision 1.5
424 retrieving revision 1.6
425 diff -u -r1.5 -r1.6
426 --- Link.cc     3 Dec 2005 10:11:33 -0000       1.5
427 +++ Link.cc     26 Mar 2006 08:26:59 -0000      1.6
428 @@ -430,10 +430,9 @@
429        delete dest;
430        dest = NULL;
431      }
432 -
433    // error
434    } else {
435 -    error(-1, "Illegal annotation destination");
436 +    error(-1, "Illegal annotation destination %d", destObj->getType());
437    }
438  }
439  
440 @@ -468,10 +467,9 @@
441        delete dest;
442        dest = NULL;
443      }
444 -
445    // error
446    } else {
447 -    error(-1, "Illegal annotation destination");
448 +    error(-1, "Illegal annotation destination %d", destObj->getType());
449    }
450  }
451  
452 Index: OutputDev.h
453 ===================================================================
454 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
455 retrieving revision 1.7
456 retrieving revision 1.9
457 diff -u -r1.7 -r1.9
458 --- OutputDev.h 3 Dec 2005 10:11:33 -0000       1.7
459 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000       1.9
460 @@ -74,7 +74,7 @@
461    virtual void setDefaultCTM(double *ctm);
462  
463    // Start a page.
464 -  virtual void startPage(int pageNum, GfxState *state) {}
465 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
466  
467    // End a page.
468    virtual void endPage() {}
469 Index: Page.cc
470 ===================================================================
471 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Page.cc,v
472 retrieving revision 1.5
473 retrieving revision 1.6
474 diff -u -r1.5 -r1.6
475 --- Page.cc     3 Dec 2005 10:11:33 -0000       1.5
476 +++ Page.cc     3 Dec 2005 10:30:41 -0000       1.6
477 @@ -66,6 +66,19 @@
478      cropBox = mediaBox;
479    }
480  
481 +  /* if the crop box is larger than the media box, cut it down to 
482 +     media box size */
483 +  if(haveCropBox &&
484 +     mediaBox.x1 <= cropBox.x2 &&
485 +     mediaBox.y1 <= cropBox.y2 &&
486 +     cropBox.x1 <= mediaBox.x2 &&
487 +     cropBox.y1 <= mediaBox.y2) {
488 +      if(mediaBox.x1 >= cropBox.x1) cropBox.x1 = mediaBox.x1;
489 +      if(mediaBox.y1 >= cropBox.y1) cropBox.y1 = mediaBox.y1;
490 +      if(mediaBox.x2 <= cropBox.x2) cropBox.x2 = mediaBox.x2;
491 +      if(mediaBox.y2 <= cropBox.y2) cropBox.y2 = mediaBox.y2;
492 +  }
493 +
494    // other boxes
495    bleedBox = cropBox;
496    readBox(dict, "BleedBox", &bleedBox);
497 Index: Stream.cc
498 ===================================================================
499 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
500 retrieving revision 1.7
501 retrieving revision 1.8
502 diff -u -r1.7 -r1.8
503 --- Stream.cc   3 Dec 2005 10:11:33 -0000       1.7
504 +++ Stream.cc   3 Dec 2005 10:30:41 -0000       1.8
505 @@ -17,6 +17,8 @@
506  #include <stddef.h>
507  #ifndef WIN32
508  #include <unistd.h>
509 +#else
510 +extern "C" int unlink(char *filename);
511  #endif
512  #include <string.h>
513  #include <ctype.h>
514 Index: config.h
515 ===================================================================
516 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/config.h,v
517 retrieving revision 1.5
518 retrieving revision 1.6
519 diff -u -r1.5 -r1.6
520 --- config.h    3 Dec 2005 10:11:33 -0000       1.5
521 +++ config.h    3 Dec 2005 10:30:41 -0000       1.6
522 @@ -53,18 +53,18 @@
523  
524  // user config file name, relative to the user's home directory
525  #if defined(VMS) || (defined(WIN32) && !defined(__CYGWIN32__))
526 -#define xpdfUserConfigFile "xpdfrc"
527 +#define xpdfUserConfigFile "pdf2swf.conf"
528  #else
529 -#define xpdfUserConfigFile ".xpdfrc"
530 +#define xpdfUserConfigFile ".pdf2swf.conf"
531  #endif
532  
533  // system config file name (set via the configure script)
534 -#ifdef SYSTEM_XPDFRC
535 -#define xpdfSysConfigFile SYSTEM_XPDFRC
536 +#ifndef WIN32
537 +#define xpdfSysConfigFile "/etc/pdf2swf.conf"
538  #else
539  // under Windows, we get the directory with the executable and then
540  // append this file name
541 -#define xpdfSysConfigFile "xpdfrc"
542 +#define xpdfSysConfigFile "pdf2swf.conf"
543  #endif
544  
545  //------------------------------------------------------------------------
546 Index: gfile.cc
547 ===================================================================
548 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
549 retrieving revision 1.12
550 retrieving revision 1.13
551 diff -u -r1.12 -r1.13
552 --- gfile.cc    3 Dec 2005 10:11:33 -0000       1.12
553 +++ gfile.cc    3 Dec 2005 10:30:41 -0000       1.13
554 @@ -437,6 +437,52 @@
555  #endif
556  }
557  
558 +static char* getTempDir()
559 +{
560 +#ifdef WIN32
561 +    char*dir = getenv("TMP");
562 +    if(!dir) dir = getenv("TEMP");
563 +    if(!dir) dir = getenv("tmp");
564 +    if(!dir) dir = getenv("temp");
565 +    if(!dir) dir = "C:\\";
566 +#else
567 +    char* dir = "/tmp/";
568 +#endif
569 +    return dir;
570 +}
571 +
572 +char* mktmpname(char*ptr) {
573 +    static char tmpbuf[128];
574 +    char*dir = getTempDir();
575 +    int l = strlen(dir);
576 +    char*sep = "";
577 +    if(!ptr)
578 +       ptr = tmpbuf;
579 +    if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
580 +#ifdef WIN32
581 +       sep = "\\";
582 +#else
583 +       sep = "/";
584 +#endif
585 +    }
586 +
587 + //   used to be mktemp. This does remove the warnings, but
588 + //   It's not exactly an improvement.
589 +#ifdef HAVE_LRAND48
590 +    sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
591 +#else
592 +#   ifdef HAVE_RAND
593 +       sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
594 +#   else
595 +       static int count = 1;
596 +       sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
597 +       count ++;
598 +#   endif
599 +#endif
600 +     return ptr;
601 +}
602 +
603 +
604  GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
605  #if defined(WIN32)
606    //---------- Win32 ----------
607 @@ -463,7 +509,7 @@
608    // with this file name after the tmpnam call and before the fopen
609    // call.  I will happily accept fixes to this function for non-Unix
610    // OSs.
611 -  if (!(s = tmpnam(NULL))) {
612 +  if (!(s = mktmpname(NULL))) {
613      return gFalse;
614    }
615    *name = new GString(s);
616 @@ -490,7 +536,7 @@
617      (*name)->append("/XXXXXX")->append(ext);
618      fd = mkstemps((*name)->getCString(), strlen(ext));
619  #else
620 -    if (!(s = tmpnam(NULL))) {
621 +    if (!(s = mktmpname(NULL))) {
622        return gFalse;
623      }
624      *name = new GString(s);
625 @@ -507,7 +553,7 @@
626      (*name)->append("/XXXXXX");
627      fd = mkstemp((*name)->getCString());
628  #else // HAVE_MKSTEMP
629 -    if (!(s = tmpnam(NULL))) {
630 +    if (!(s = mktmpname(NULL))) {
631        return gFalse;
632      }
633      *name = new GString(s);
634 Index: gfile.h
635 ===================================================================
636 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
637 retrieving revision 1.9
638 retrieving revision 1.10
639 diff -u -r1.9 -r1.10
640 --- gfile.h     3 Dec 2005 10:11:33 -0000       1.9
641 +++ gfile.h     3 Dec 2005 10:30:41 -0000       1.10
642 @@ -58,6 +58,9 @@
643  // Get current directory.
644  extern GString *getCurrentDir();
645  
646 +/* create a temporary filename */
647 +char* mktmpname(char*ptr);
648 +
649  // Append a file name to a path string.  <path> may be an empty
650  // string, denoting the current directory).  Returns <path>.
651  extern GString *appendToPath(GString *path, char *fileName);
652 --- pdf/xpdf-3.01.16/GlobalParams.h     2006-11-12 11:20:54.000000000 +0100
653 +++ j   2006-11-12 11:19:40.000000000 +0100
654 @@ -315,7 +315,7 @@
655  private:
656  
657    void createDefaultKeyBindings();
658 -  void parseFile(GString *fileName, FILE *f);
659 +public: void parseFile(GString *fileName, FILE *f); private:
660    void parseNameToUnicode(GList *tokens, GString *fileName, int line);
661    void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
662    void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
663 --- SplashOutputDev.h.orig      2006-11-12 12:07:22.000000000 +0100
664 +++ SplashOutputDev.h   2006-11-12 12:08:48.000000000 +0100
665 @@ -70,7 +70,7 @@
666    //----- initialization and control
667  
668    // Start a page.
669 -  virtual void startPage(int pageNum, GfxState *state);
670 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
671  
672    // End a page.
673    virtual void endPage();
674 --- SplashOutputDev.cc.orig     2006-11-12 12:07:06.000000000 +0100
675 +++ SplashOutputDev.cc  2006-11-12 12:09:36.000000000 +0100
676 @@ -696,7 +696,7 @@
677    nT3Fonts = 0;
678  }
679  
680 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
681 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
682    int w, h;
683    double *ctm;
684    SplashCoord mat[6];
685 --- TextOutputDev.h.orig        2006-11-12 12:23:01.000000000 +0100
686 +++ TextOutputDev.h     2006-11-12 12:25:31.000000000 +0100
687 @@ -578,7 +578,7 @@
688    //----- initialization and control
689  
690    // Start a page.
691 -  virtual void startPage(int pageNum, GfxState *state);
692 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
693  
694    // End a page.
695    virtual void endPage();
696 --- TextOutputDev.cc.orig       2006-11-12 12:22:53.000000000 +0100
697 +++ TextOutputDev.cc    2006-11-12 12:25:03.000000000 +0100
698 @@ -3805,7 +3805,7 @@
699    }
700  }
701  
702 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
703 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
704    text->startPage(state);
705  }
706  
707 --- CoreOutputDev.cc.orig       2006-11-12 12:21:59.000000000 +0100
708 +++ CoreOutputDev.cc    2006-11-12 12:23:29.000000000 +0100
709 @@ -57,5 +57,5 @@
710  
711  void CoreOutputDev::clear() {
712    startDoc(NULL);
713 -  startPage(0, NULL);
714 +  startPage(0, NULL, 0,0,0,0);
715  }