850e72a43a66f410e97d2b3dae17ec06fa786498
[swftools.git] / lib / pdf / xpdf-changes.patch
1 --- xpdf/Catalog.cc.orig        2010-05-18 11:22:18.000000000 -0700
2 +++ xpdf/Catalog.cc     2010-05-18 11:22:18.000000000 -0700
3 @@ -193,7 +193,7 @@
4    if (!kids.isArray()) {
5      error(-1, "Kids object (page %d) is wrong type (%s)",
6           start+1, kids.getTypeName());
7 -    goto err1;
8 +    return start;
9    }
10    for (i = 0; i < kids.arrayGetLength(); ++i) {
11      kids.arrayGetNF(i, &kidRef);
12 --- xpdf/CharCodeToUnicode.cc.orig      2010-05-18 11:22:18.000000000 -0700
13 +++ xpdf/CharCodeToUnicode.cc   2010-05-18 11:22:18.000000000 -0700
14 @@ -208,13 +208,13 @@
15                                    int nBits) {
16    PSTokenizer *pst;
17    char tok1[256], tok2[256], tok3[256];
18 -  int nDigits, n1, n2, n3;
19 +  int maxCode, n1, n2, n3;
20    CharCode i;
21    CharCode code1, code2;
22    GString *name;
23    FILE *f;
24  
25 -  nDigits = nBits / 4;
26 +  maxCode = (nBits == 8) ? 0xff : (nBits == 16) ? 0xffff : 0xffffffff;
27    pst = new PSTokenizer(getCharFunc, data);
28    pst->getToken(tok1, sizeof(tok1), &n1);
29    while (pst->getToken(tok2, sizeof(tok2), &n2)) {
30 @@ -241,9 +241,9 @@
31           error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
32           break;
33         }
34 -       if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
35 +       if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
36               tok2[0] == '<' && tok2[n2 - 1] == '>')) {
37 -         error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
38 +         error(-1, "Illegal entry in bfchar block in ToUnicode CMap.");
39           continue;
40         }
41         tok1[n1 - 1] = tok2[n2 - 1] = '\0';
42 @@ -251,6 +251,9 @@
43           error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
44           continue;
45         }
46 +        if (code1 > maxCode) {
47 +          error(-1, "Invalid entry in bfchar block in ToUnicode CMap");
48 +        }
49         addMapping(code1, tok2 + 1, n2 - 2, 0);
50        }
51        pst->getToken(tok1, sizeof(tok1), &n1);
52 @@ -266,8 +269,8 @@
53           error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
54           break;
55         }
56 -       if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
57 -             n2 == 2 + nDigits && tok2[0] == '<' && tok2[n2 - 1] == '>')) {
58 +       if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
59 +             tok2[0] == '<' && tok2[n2 - 1] == '>')) {
60           error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
61           continue;
62         }
63 @@ -277,6 +280,10 @@
64           error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
65           continue;
66         }
67 +        if (code1 > maxCode || code2 > maxCode) {
68 +           error(-1, "Invalid entry in bfrange block in ToUnicode CMap");
69 +       }
70 +
71         if (!strcmp(tok3, "[")) {
72           i = 0;
73           while (pst->getToken(tok1, sizeof(tok1), &n1) &&
74 --- xpdf/CoreOutputDev.cc.orig  2010-05-18 11:22:18.000000000 -0700
75 +++ xpdf/CoreOutputDev.cc       2010-05-18 11:22:18.000000000 -0700
76 @@ -57,5 +57,5 @@
77  
78  void CoreOutputDev::clear() {
79    startDoc(NULL);
80 -  startPage(0, NULL);
81 +  startPage(0, NULL, 0,0,0,0);
82  }
83 --- xpdf/Decrypt.cc.orig        2010-05-18 11:22:18.000000000 -0700
84 +++ xpdf/Decrypt.cc     2010-05-18 11:22:18.000000000 -0700
85 @@ -596,6 +596,7 @@
86    s->bufIdx = 0;
87    if (last) {
88      n = s->buf[15];
89 +    if(!n || n>16) n=16;
90      for (i = 15; i >= n; --i) {
91        s->buf[i] = s->buf[i-n];
92      }
93 --- xpdf/Gfx.cc.orig    2010-05-18 11:22:18.000000000 -0700
94 +++ xpdf/Gfx.cc 2010-05-18 11:22:18.000000000 -0700
95 @@ -454,7 +454,11 @@
96    fontChanged = gFalse;
97    clip = clipNone;
98    ignoreUndef = 0;
99 -  out->startPage(pageNum, state);
100 +  if(cropBox) {
101 +      out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
102 +  } else {
103 +      out->startPage(pageNum, state, 0,0,0,0);
104 +  }
105    out->setDefaultCTM(state->getCTM());
106    out->updateAll(state);
107    for (i = 0; i < 6; ++i) {
108 @@ -465,6 +469,7 @@
109    abortCheckCbkData = abortCheckCbkDataA;
110  
111    // set crop box
112 +#ifdef XPDFEXE
113    if (cropBox) {
114      state->moveTo(cropBox->x1, cropBox->y1);
115      state->lineTo(cropBox->x2, cropBox->y1);
116 @@ -475,6 +480,7 @@
117      out->clip(state);
118      state->clearPath();
119    }
120 +#endif
121  }
122  
123  Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
124 @@ -3182,8 +3188,11 @@
125                             u, (int)(sizeof(u) / sizeof(Unicode)), &uLen,
126                             &dx, &dy, &originX, &originY);
127        dx = dx * state->getFontSize() + state->getCharSpace();
128 -      if (n == 1 && *p == ' ') {
129 -       dx += state->getWordSpace();
130 +      if (n == 1 && (*p == ' ' || *p == 0)) {
131 +        double w=state->getWordSpace();
132 +        if (w==0 && dx==0)
133 +          w=state->getFontSize()/3; // workaround for zero word space
134 +        dx += w;
135        }
136        dx *= state->getHorizScaling();
137        dy *= state->getFontSize();
138 @@ -3476,11 +3485,13 @@
139        }
140      }
141      if (!obj1.isNull()) {
142 -      colorSpace = GfxColorSpace::parse(&obj1);
143 +      colorSpace = GfxColorSpace::parse(&obj1, csMode);
144      } else if (csMode == streamCSDeviceGray) {
145        colorSpace = new GfxDeviceGrayColorSpace();
146      } else if (csMode == streamCSDeviceRGB) {
147        colorSpace = new GfxDeviceRGBColorSpace();
148 +    } else if (csMode == streamCSDeviceRGBX) {
149 +      colorSpace = new GfxDeviceRGBXColorSpace();
150      } else if (csMode == streamCSDeviceCMYK) {
151        colorSpace = new GfxDeviceCMYKColorSpace();
152      } else {
153 @@ -3824,6 +3835,7 @@
154      out->beginTransparencyGroup(state, bbox, blendingColorSpace,
155                                 isolated, knockout, softMask);
156    }
157 +  GfxState*old_state = state;
158  
159    // set new base matrix
160    for (i = 0; i < 6; ++i) {
161 @@ -3835,6 +3847,9 @@
162    display(str, gFalse);
163  
164    if (softMask || transpGroup) {
165 +    // restore graphics state
166 +    while(state != old_state)
167 +       restoreState();
168      out->endTransparencyGroup(state);
169    }
170  
171 --- xpdf/GfxFont.cc.orig        2010-05-18 11:22:18.000000000 -0700
172 +++ xpdf/GfxFont.cc     2010-05-18 11:22:18.000000000 -0700
173 @@ -919,6 +919,10 @@
174    return 1;
175  }
176  
177 +CharCodeToUnicode* Gfx8BitFont::getCTU() {
178 +    return ctu;
179 +}
180 +
181  CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
182    ctu->incRefCnt();
183    return ctu;
184 @@ -1411,6 +1415,10 @@
185    }
186  }
187  
188 +CharCodeToUnicode* GfxCIDFont::getCTU() {
189 +    return ctu;
190 +}
191 +
192  int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
193                             Unicode *u, int uSize, int *uLen,
194                             double *dx, double *dy, double *ox, double *oy) {
195 --- xpdf/GfxFont.h.orig 2010-05-18 11:22:18.000000000 -0700
196 +++ xpdf/GfxFont.h      2010-05-18 11:22:18.000000000 -0700
197 @@ -164,6 +164,7 @@
198    virtual int getNextChar(char *s, int len, CharCode *code,
199                           Unicode *u, int uSize, int *uLen,
200                           double *dx, double *dy, double *ox, double *oy) = 0;
201 +  virtual CharCodeToUnicode* getCTU() = 0;
202  
203  protected:
204  
205 @@ -204,6 +205,7 @@
206    virtual int getNextChar(char *s, int len, CharCode *code,
207                           Unicode *u, int uSize, int *uLen,
208                           double *dx, double *dy, double *ox, double *oy);
209 +  virtual CharCodeToUnicode* getCTU();
210  
211    // Return the encoding.
212    char **getEncoding() { return enc; }
213 @@ -212,7 +214,7 @@
214    CharCodeToUnicode *getToUnicode();
215  
216    // Return the character name associated with <code>.
217 -  char *getCharName(int code) { return enc[code]; }
218 +  char *getCharName(int code) { return code>=256?0:enc[code]; }
219  
220    // Returns true if the PDF font specified an encoding.
221    GBool getHasEncoding() { return hasEncoding; }
222 @@ -266,6 +268,7 @@
223    virtual int getNextChar(char *s, int len, CharCode *code,
224                           Unicode *u, int uSize, int *uLen,
225                           double *dx, double *dy, double *ox, double *oy);
226 +  virtual CharCodeToUnicode* getCTU();
227  
228    // Return the writing mode (0=horizontal, 1=vertical).
229    virtual int getWMode();
230 --- xpdf/GfxState.cc.orig       2010-05-18 11:22:18.000000000 -0700
231 +++ xpdf/GfxState.cc    2010-05-18 11:22:18.000000000 -0700
232 @@ -21,6 +21,7 @@
233  #include "Array.h"
234  #include "Page.h"
235  #include "GfxState.h"
236 +#include "cmyk.h"
237  
238  //------------------------------------------------------------------------
239  
240 @@ -92,7 +93,7 @@
241  GfxColorSpace::~GfxColorSpace() {
242  }
243  
244 -GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
245 +GfxColorSpace *GfxColorSpace::parse(Object *csObj, StreamColorSpaceMode csMode) {
246    GfxColorSpace *cs;
247    Object obj1;
248  
249 @@ -101,7 +102,10 @@
250      if (csObj->isName("DeviceGray") || csObj->isName("G")) {
251        cs = new GfxDeviceGrayColorSpace();
252      } else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) {
253 -      cs = new GfxDeviceRGBColorSpace();
254 +      if(csMode == streamCSDeviceRGBX)
255 +       cs = new GfxDeviceRGBXColorSpace();
256 +      else
257 +       cs = new GfxDeviceRGBColorSpace();
258      } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) {
259        cs = new GfxDeviceCMYKColorSpace();
260      } else if (csObj->isName("Pattern")) {
261 @@ -114,7 +118,10 @@
262      if (obj1.isName("DeviceGray") || obj1.isName("G")) {
263        cs = new GfxDeviceGrayColorSpace();
264      } else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) {
265 -      cs = new GfxDeviceRGBColorSpace();
266 +      if(csMode == streamCSDeviceRGBX)
267 +        cs = new GfxDeviceRGBColorSpace();
268 +      else
269 +       cs = new GfxDeviceRGBColorSpace();
270      } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) {
271        cs = new GfxDeviceCMYKColorSpace();
272      } else if (obj1.isName("CalGray")) {
273 @@ -333,6 +340,17 @@
274  }
275  
276  //------------------------------------------------------------------------
277 +// GfxDeviceRGBXColorSpace
278 +//------------------------------------------------------------------------
279 +
280 +GfxDeviceRGBXColorSpace::GfxDeviceRGBXColorSpace() {
281 +}
282 +
283 +GfxColorSpace *GfxDeviceRGBXColorSpace::copy() {
284 +  return new GfxDeviceRGBXColorSpace();
285 +}
286 +
287 +//------------------------------------------------------------------------
288  // GfxCalRGBColorSpace
289  //------------------------------------------------------------------------
290  
291 @@ -490,6 +508,18 @@
292                                 - 0.11 * color->c[2] + 0.5));
293  }
294  
295 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
296 +    unsigned char r,g,b;
297 +    float c = color->c[0];
298 +    float m = color->c[1];
299 +    float y = color->c[2];
300 +    float k = color->c[3];
301 +    convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
302 +    rgb->r = r/255.0;
303 +    rgb->g = g/255.0;
304 +    rgb->b = b/255.0;
305 +}*/
306 +
307  void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
308    double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
309  
310 @@ -3187,6 +3217,7 @@
311    GfxIndexedColorSpace *indexedCS;
312    GfxSeparationColorSpace *sepCS;
313    int maxPixel, indexHigh;
314 +  int maxPixelForAlloc;
315    Guchar *lookup2;
316    Function *sepFunc;
317    Object obj;
318 @@ -3199,6 +3230,7 @@
319    // bits per component and color space
320    bits = bitsA;
321    maxPixel = (1 << bits) - 1;
322 +  maxPixelForAlloc = (1 << (bits>8?bits:8));
323    colorSpace = colorSpaceA;
324  
325    // initialize
326 @@ -3253,7 +3285,7 @@
327      lookup2 = indexedCS->getLookup();
328      colorSpace2->getDefaultRanges(x, y, indexHigh);
329      for (k = 0; k < nComps2; ++k) {
330 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
331 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
332                                            sizeof(GfxColorComp));
333        for (i = 0; i <= maxPixel; ++i) {
334         j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
335 @@ -3272,7 +3304,7 @@
336      nComps2 = colorSpace2->getNComps();
337      sepFunc = sepCS->getFunc();
338      for (k = 0; k < nComps2; ++k) {
339 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
340 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
341                                            sizeof(GfxColorComp));
342        for (i = 0; i <= maxPixel; ++i) {
343         x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
344 @@ -3282,7 +3314,7 @@
345      }
346    } else {
347      for (k = 0; k < nComps; ++k) {
348 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
349 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
350                                            sizeof(GfxColorComp));
351        for (i = 0; i <= maxPixel; ++i) {
352         lookup[k][i] = dblToCol(decodeLow[k] +
353 @@ -3754,7 +3786,10 @@
354  }
355  
356  void GfxState::setPath(GfxPath *pathA) {
357 +  if(pathA) {
358 +      if(path)
359    delete path;
360 +  }
361    path = pathA;
362  }
363  
364 --- xpdf/GfxState.h.orig        2010-05-18 11:22:18.000000000 -0700
365 +++ xpdf/GfxState.h     2010-05-18 11:22:18.000000000 -0700
366 @@ -138,7 +138,7 @@
367    virtual GfxColorSpaceMode getMode() = 0;
368  
369    // Construct a color space.  Returns NULL if unsuccessful.
370 -  static GfxColorSpace *parse(Object *csObj);
371 +  static GfxColorSpace *parse(Object *csObj, StreamColorSpaceMode csMode = streamCSNone);
372  
373    // Convert to gray, RGB, or CMYK.
374    virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
375 @@ -252,6 +252,19 @@
376  };
377  
378  //------------------------------------------------------------------------
379 +// GfxDeviceRGBXColorSpace
380 +//------------------------------------------------------------------------
381 +
382 +class GfxDeviceRGBXColorSpace: public GfxDeviceRGBColorSpace {
383 +public:
384 +
385 +  GfxDeviceRGBXColorSpace();
386 +  virtual GfxColorSpace *copy();
387 +  virtual int getNComps() { return 4; }
388 +private:
389 +};
390 +
391 +//------------------------------------------------------------------------
392  // GfxCalRGBColorSpace
393  //------------------------------------------------------------------------
394  
395 --- xpdf/GlobalParams.cc.orig   2010-05-18 11:22:18.000000000 -0700
396 +++ xpdf/GlobalParams.cc        2010-05-18 11:22:18.000000000 -0700
397 @@ -914,6 +914,29 @@
398    int line;
399    char buf[512];
400  
401 +  /* extract path */
402 +  if(fileName) {
403 +    char* cfgFileName = fileName->getCString();
404 +    char* pos1 = strrchr(cfgFileName, '/');
405 +    char* pos2 = strrchr(cfgFileName, '\\');
406 +    char* p = pos1>pos2?pos1:pos2;
407 +    int pos = p ? p-cfgFileName : -1;
408 +    GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
409 +    if(pos1>=0)
410 +       path->append('/');
411 +    else if(pos2>=0)
412 +       path->append('\\');
413 +    else
414 +#ifdef WIN32
415 +       path->append('\\');
416 +#else
417 +       path->append('/');
418 +#endif
419 +    this->path = path;
420 +  } else {
421 +    this->path = new GString();
422 +  }
423 +  
424    line = 1;
425    while (getLine(buf, sizeof(buf) - 1, f)) {
426      parseLine(buf, fileName, line);
427 @@ -1114,6 +1137,42 @@
428    deleteGList(tokens, GString);
429  }
430  
431 +static char is_absolute(char*filename)
432 +{
433 +    int l = strlen(filename);
434 +    if(filename[0] == '/' || filename[0] == '\\') 
435 +       return 1;
436 +    if(l>2 && filename[1]==':' && (filename[2]=='\\' || filename[2]=='/'))
437 +       return 1;
438 +    return 0;
439 +}
440 +
441 +static GString* qualify_filename(GString*path, GString*filename)
442 +{
443 +  GString*fullpath = 0;
444 +  char*prefix = "/usr/local/share/xpdf/";
445 +
446 +  if (!is_absolute(filename->getCString())) {
447 +    /* relative path */
448 +    fullpath = path->copy();
449 +    fullpath->append(filename);
450 +  } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
451 +    /* xpdf default path */
452 +    char*s = strchr(filename->getCString()+strlen(prefix), '/');
453 +    if(s) {
454 +       fullpath = path->copy();
455 +       fullpath->append(s+1);
456 +    } else {
457 +       fullpath = filename->copy();
458 +    }
459 +  } else {
460 +    /* absolute path */
461 +    fullpath = filename->copy();
462 +  }
463 +  //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
464 +  return fullpath;
465 +}
466 +
467  void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
468                                          int line) {
469    GString *name;
470 @@ -1128,10 +1187,10 @@
471           fileName->getCString(), line);
472      return;
473    }
474 -  name = (GString *)tokens->get(1);
475 +  name = qualify_filename(this->path, (GString *)tokens->get(1));
476    if (!(f = fopen(name->getCString(), "r"))) {
477 -    error(-1, "Couldn't open 'nameToUnicode' file '%s'",
478 -         name->getCString());
479 +    error(-1, "Couldn't open 'nameToUnicode' file '%s' using path '%s'",
480 +         name->getCString(), path->getCString());
481      return;
482    }
483    line2 = 1;
484 @@ -1160,10 +1219,12 @@
485    }
486    collection = (GString *)tokens->get(1);
487    name = (GString *)tokens->get(2);
488 +
489    if ((old = (GString *)cidToUnicodes->remove(collection))) {
490      delete old;
491    }
492 -  cidToUnicodes->add(collection->copy(), name->copy());
493 +
494 +  cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
495  }
496  
497  void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
498 @@ -1180,7 +1241,8 @@
499    if ((old = (GString *)unicodeToUnicodes->remove(font))) {
500      delete old;
501    }
502 -  unicodeToUnicodes->add(font->copy(), file->copy());
503 +
504 +  unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
505  }
506  
507  void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
508 @@ -1197,7 +1259,8 @@
509    if ((old = (GString *)unicodeMaps->remove(encodingName))) {
510      delete old;
511    }
512 -  unicodeMaps->add(encodingName->copy(), name->copy());
513 +
514 +  unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
515  }
516  
517  void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
518 @@ -1215,23 +1278,30 @@
519      list = new GList();
520      cMapDirs->add(collection->copy(), list);
521    }
522 -  list->append(dir->copy());
523 +
524 +  list->append(qualify_filename(this->path, dir));
525  }
526  
527  void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
528                                      int line) {
529 +  GString *dir;
530 +
531    if (tokens->getLength() != 2) {
532      error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
533           fileName->getCString(), line);
534      return;
535    }
536 -  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
537 +
538 +  dir = (GString *)tokens->get(1);
539 +
540 +  toUnicodeDirs->append(qualify_filename(this->path, dir));
541  }
542  
543  void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
544                                     DisplayFontParamKind kind,
545                                     GString *fileName, int line) {
546    DisplayFontParam *param, *old;
547 +  GString *file;
548  
549    if (tokens->getLength() < 2) {
550      goto err1;
551 @@ -1243,13 +1313,15 @@
552      if (tokens->getLength() != 3) {
553        goto err2;
554      }
555 -    param->t1.fileName = ((GString *)tokens->get(2))->copy();
556 +    file = (GString *)tokens->get(2);
557 +    param->t1.fileName = qualify_filename(this->path, file);
558      break;
559    case displayFontTT:
560      if (tokens->getLength() != 3) {
561        goto err2;
562      }
563 -    param->tt.fileName = ((GString *)tokens->get(2))->copy();
564 +    file = (GString *)tokens->get(2);
565 +    param->tt.fileName = qualify_filename(this->path, file);
566      break;
567    }
568  
569 --- xpdf/GlobalParams.h.orig    2010-05-18 11:22:18.000000000 -0700
570 +++ xpdf/GlobalParams.h 2010-05-18 11:22:18.000000000 -0700
571 @@ -196,7 +196,7 @@
572    // file.
573    GlobalParams(char *cfgFileName);
574  
575 -  ~GlobalParams();
576 +  virtual ~GlobalParams();
577  
578    void setBaseDir(char *dir);
579    void setupBaseFonts(char *dir);
580 @@ -213,8 +213,8 @@
581    FILE *getUnicodeMapFile(GString *encodingName);
582    FILE *findCMapFile(GString *collection, GString *cMapName);
583    FILE *findToUnicodeFile(GString *name);
584 -  DisplayFontParam *getDisplayFont(GString *fontName);
585 -  DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
586 +  virtual DisplayFontParam *getDisplayFont(GString *fontName);
587 +  virtual DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
588    GString *getPSFile();
589    int getPSPaperWidth();
590    int getPSPaperHeight();
591 @@ -316,7 +316,7 @@
592  private:
593  
594    void createDefaultKeyBindings();
595 -  void parseFile(GString *fileName, FILE *f);
596 +public: void parseFile(GString *fileName, FILE *f); private:
597    void parseNameToUnicode(GList *tokens, GString *fileName, int line);
598    void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
599    void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
600 @@ -358,6 +358,10 @@
601    GBool loadPlugin(char *type, char *name);
602  #endif
603  
604 +  //----- config file base path
605 +
606 +  GString*path;
607 +
608    //----- static tables
609  
610    NameToCharCode *             // mapping from char name to
611 --- xpdf/JBIG2Stream.cc.orig    2010-05-18 11:22:18.000000000 -0700
612 +++ xpdf/JBIG2Stream.cc 2010-05-18 11:22:18.000000000 -0700
613 @@ -1514,11 +1514,14 @@
614    }
615  
616    // compute symbol code length
617 -  symCodeLen = 1;
618 -  i = (numInputSyms + numNewSyms) >> 1;
619 -  while (i) {
620 -    ++symCodeLen;
621 -    i >>= 1;
622 +  symCodeLen = 0;
623 +  i = 1;
624 +  while (i < numInputSyms + numNewSyms) {
625 +   ++symCodeLen;
626 +   i <<= 1;
627 +  }
628 +  if (huff && symCodeLen == 0) {
629 +   symCodeLen = 1;
630    }
631  
632    // get the input symbol bitmaps
633 @@ -1921,6 +1924,9 @@
634      ++symCodeLen;
635      i <<= 1;
636    }
637 +  if (huff && symCodeLen == 0) {
638 +    symCodeLen = 1;
639 +  }
640  
641    // get the symbol bitmaps
642    syms = (JBIG2Bitmap **)gmallocn(numSyms, sizeof(JBIG2Bitmap *));
643 --- xpdf/JPXStream.cc.orig      2010-05-18 11:22:18.000000000 -0700
644 +++ xpdf/JPXStream.cc   2010-05-18 11:22:18.000000000 -0700
645 @@ -450,6 +450,7 @@
646    GBool haveBPC, haveCSMode;
647  
648    csPrec = 0; // make gcc happy
649 +  Guint num_components = 0;
650    haveBPC = haveCSMode = gFalse;
651    str->reset();
652    if (str->lookChar() == 0xff) {
653 @@ -463,7 +464,7 @@
654         cover(1);
655         if (readULong(&dummy) &&
656             readULong(&dummy) &&
657 -           readUWord(&dummy) &&
658 +           readUWord(&num_components) &&
659             readUByte(&bpc1) &&
660             readUByte(&dummy) &&
661             readUByte(&dummy) &&
662 @@ -519,6 +520,9 @@
663        }
664      }
665    }
666 +  if(*csMode == streamCSDeviceRGB && num_components == 4) {
667 +    *csMode = streamCSDeviceRGBX;
668 +  }
669    str->close();
670  }
671  
672 --- xpdf/Lexer.cc.orig  2010-05-18 11:22:18.000000000 -0700
673 +++ xpdf/Lexer.cc       2010-05-18 11:22:18.000000000 -0700
674 @@ -74,6 +74,7 @@
675      curStr.streamReset();
676    }
677  }
678 +static int illegalChars = 0;
679  
680  Lexer::~Lexer() {
681    if (!curStr.isNone()) {
682 @@ -83,6 +84,9 @@
683    if (freeArray) {
684      delete streams;
685    }
686 +  if(illegalChars)
687 +      error(0, "Illegal characters in hex string (%d)", illegalChars);
688 +  illegalChars = 0;
689  }
690  
691  int Lexer::getChar() {
692 @@ -330,7 +334,8 @@
693         } else if (c2 >= 'a' && c2 <= 'f') {
694           c += c2 - 'a' + 10;
695         } else {
696 -         error(getPos(), "Illegal digit in hex char in name");
697 +         illegalChars++;
698 +         //error(getPos(), "Illegal digit in hex char in name");
699         }
700        }
701       notEscChar:
702 @@ -384,8 +389,10 @@
703             c2 += c - 'A' + 10;
704           else if (c >= 'a' && c <= 'f')
705             c2 += c - 'a' + 10;
706 -         else
707 -           error(getPos(), "Illegal character <%02x> in hex string", c);
708 +         else {
709 +           illegalChars++;
710 +           //error(getPos(), "Illegal character <%02x> in hex string", c);
711 +         }
712           if (++m == 2) {
713             if (n == tokBufSize) {
714               if (!s)
715 @@ -421,7 +428,8 @@
716        tokBuf[2] = '\0';
717        obj->initCmd(tokBuf);
718      } else {
719 -      error(getPos(), "Illegal character '>'");
720 +      illegalChars++;
721 +      //error(getPos(), "Illegal character '>'");
722        obj->initError();
723      }
724      break;
725 @@ -430,7 +438,8 @@
726    case ')':
727    case '{':
728    case '}':
729 -    error(getPos(), "Illegal character '%c'", c);
730 +    //error(getPos(), "Illegal character '%c'", c);
731 +    illegalChars++;
732      obj->initError();
733      break;
734  
735 @@ -459,7 +468,6 @@
736      }
737      break;
738    }
739 -
740    return obj;
741  }
742  
743 --- xpdf/Link.cc.orig   2010-05-18 11:22:18.000000000 -0700
744 +++ xpdf/Link.cc        2010-05-18 11:22:18.000000000 -0700
745 @@ -430,10 +430,9 @@
746        delete dest;
747        dest = NULL;
748      }
749 -
750    // error
751    } else {
752 -    error(-1, "Illegal annotation destination");
753 +    error(-1, "Illegal annotation destination %d", destObj->getType());
754    }
755  }
756  
757 @@ -468,10 +467,9 @@
758        delete dest;
759        dest = NULL;
760      }
761 -
762    // error
763    } else {
764 -    error(-1, "Illegal annotation destination");
765 +    error(-1, "Illegal annotation destination %d", destObj->getType());
766    }
767  }
768  
769 --- xpdf/OutputDev.h.orig       2010-05-18 11:22:18.000000000 -0700
770 +++ xpdf/OutputDev.h    2010-05-18 11:22:18.000000000 -0700
771 @@ -17,6 +17,7 @@
772  
773  #include "gtypes.h"
774  #include "CharTypes.h"
775 +#include "Object.h"
776  
777  class GString;
778  class GfxState;
779 @@ -94,7 +95,7 @@
780      { return gTrue; }
781  
782    // Start a page.
783 -  virtual void startPage(int pageNum, GfxState *state) {}
784 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
785  
786    // End a page.
787    virtual void endPage() {}
788 --- xpdf/SplashFTFont.cc.orig   2010-05-18 11:22:18.000000000 -0700
789 +++ xpdf/SplashFTFont.cc        2010-05-18 11:22:18.000000000 -0700
790 @@ -46,6 +46,7 @@
791    int x, y;
792  
793    face = fontFileA->face;
794 +  
795    if (FT_New_Size(face, &sizeObj)) {
796      return;
797    }
798 @@ -54,6 +55,10 @@
799    if (FT_Set_Pixel_Sizes(face, 0, (int)size)) {
800      return;
801    }
802
803 +  this->ascender = face->ascender;
804 +  this->descender = face->descender;
805 +
806    // if the textMat values are too small, FreeType's fixed point
807    // arithmetic doesn't work so well
808    textScale = splashSqrt(textMat[2]*textMat[2] + textMat[3]*textMat[3]) / size;
809 @@ -228,6 +233,12 @@
810    GBool needClose;
811  };
812  
813 +int SplashFTFont::getNumChars()
814 +{
815 +  SplashFTFontFile* ff = (SplashFTFontFile *)fontFile;
816 +  return ff->face->num_glyphs;
817 +}
818 +
819  SplashPath *SplashFTFont::getGlyphPath(int c) {
820    static FT_Outline_Funcs outlineFuncs = {
821  #if FREETYPE_MINOR <= 1
822 @@ -249,6 +260,8 @@
823    FT_UInt gid;
824    FT_Glyph glyph;
825  
826 +  this->last_advance = -1;
827 +
828    ff = (SplashFTFontFile *)fontFile;
829    ff->face->size = sizeObj;
830    FT_Set_Transform(ff->face, &textMatrix, NULL);
831 @@ -262,17 +275,24 @@
832      // skip the TrueType notdef glyph
833      return NULL;
834    }
835 -  if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) {
836 +  int error = 0;
837 +  if ((error=FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP|FT_LOAD_NO_HINTING))) {
838 +      fprintf(stderr, "Truetype wasn't able to load glyph %d, error %d\n", gid, error);
839      return NULL;
840    }
841    if (FT_Get_Glyph(slot, &glyph)) {
842      return NULL;
843    }
844 +  this->last_advance = glyph->advance.x/65536.0;
845 +
846    path.path = new SplashPath();
847    path.textScale = textScale;
848    path.needClose = gFalse;
849 -  FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
850 +  error = FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
851                        &outlineFuncs, &path);
852 +  if(error) {
853 +      fprintf(stderr, "Truetype wasn't able to read glyph %d, error %d\n", gid, error);
854 +  }
855    if (path.needClose) {
856      path.path->close();
857    }
858 --- xpdf/SplashFTFont.h.orig    2010-05-18 11:22:18.000000000 -0700
859 +++ xpdf/SplashFTFont.h 2010-05-18 11:22:18.000000000 -0700
860 @@ -42,6 +42,9 @@
861    virtual GBool makeGlyph(int c, int xFrac, int yFrac,
862                           SplashGlyphBitmap *bitmap);
863  
864 +  // return the number of characters in this font
865 +  virtual int getNumChars();
866 +
867    // Return the path for a glyph.
868    virtual SplashPath *getGlyphPath(int c);
869  
870 --- xpdf/SplashFTFontEngine.cc.orig     2010-05-18 11:22:18.000000000 -0700
871 +++ xpdf/SplashFTFontEngine.cc  2010-05-18 11:22:18.000000000 -0700
872 @@ -13,9 +13,7 @@
873  #endif
874  
875  #include <stdio.h>
876 -#ifndef WIN32
877  #  include <unistd.h>
878 -#endif
879  #include "gmem.h"
880  #include "GString.h"
881  #include "gfile.h"
882 --- xpdf/SplashFont.cc.orig     2010-05-18 11:22:18.000000000 -0700
883 +++ xpdf/SplashFont.cc  2010-05-18 11:22:18.000000000 -0700
884 @@ -48,6 +48,10 @@
885    cacheTags = NULL;
886  
887    xMin = yMin = xMax = yMax = 0;
888 +
889 +  last_advance = -1;
890 +  ascender = -1;
891 +  descender = -1;
892  }
893  
894  void SplashFont::initCache() {
895 --- xpdf/SplashFont.h.orig      2010-05-18 11:22:18.000000000 -0700
896 +++ xpdf/SplashFont.h   2010-05-18 11:22:18.000000000 -0700
897 @@ -73,6 +73,9 @@
898    virtual GBool makeGlyph(int c, int xFrac, int yFrac,
899                           SplashGlyphBitmap *bitmap) = 0;
900  
901 +  // return the number of characters in this font
902 +  virtual int getNumChars() = 0;
903 +
904    // Return the path for a glyph.
905    virtual SplashPath *getGlyphPath(int c) = 0;
906  
907 @@ -83,6 +86,9 @@
908    void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
909      { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
910  
911 +  double ascender;
912 +  double descender;
913 +  double last_advance; //set after getGlyphPath()
914  protected:
915  
916    SplashFontFile *fontFile;
917 --- xpdf/SplashFontFile.cc.orig 2010-05-18 11:22:18.000000000 -0700
918 +++ xpdf/SplashFontFile.cc      2010-05-18 11:22:18.000000000 -0700
919 @@ -11,9 +11,7 @@
920  #endif
921  
922  #include <stdio.h>
923 -#ifndef WIN32
924 -#  include <unistd.h>
925 -#endif
926 +#include <unistd.h>
927  #include "GString.h"
928  #include "SplashFontFile.h"
929  #include "SplashFontFileID.h"
930 --- xpdf/SplashOutputDev.cc.orig        2010-05-18 11:22:18.000000000 -0700
931 +++ xpdf/SplashOutputDev.cc     2010-05-18 11:22:18.000000000 -0700
932 @@ -13,6 +13,7 @@
933  #endif
934  
935  #include <string.h>
936 +#include <unistd.h>
937  #include <math.h>
938  #include "gfile.h"
939  #include "GlobalParams.h"
940 @@ -702,7 +703,7 @@
941    nT3Fonts = 0;
942  }
943  
944 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
945 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
946    int w, h;
947    double *ctm;
948    SplashCoord mat[6];
949 @@ -2646,9 +2647,9 @@
950  
951    softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
952                               1, splashModeMono8, gFalse);
953 -  memset(softMask->getDataPtr(), 0,
954 -        softMask->getRowSize() * softMask->getHeight());
955 +  memset(softMask->getDataPtr(), 0x00, softMask->getRowSize()*softMask->getHeight());
956    p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;
957 +  if (tx<softMask->getWidth() && ty<softMask->getHeight())
958    for (y = 0; y < tBitmap->getHeight(); ++y) {
959      for (x = 0; x < tBitmap->getWidth(); ++x) {
960        tBitmap->getPixel(x, y, color);
961 --- xpdf/SplashOutputDev.h.orig 2010-05-18 11:22:18.000000000 -0700
962 +++ xpdf/SplashOutputDev.h      2010-05-18 11:22:18.000000000 -0700
963 @@ -70,7 +70,7 @@
964    //----- initialization and control
965  
966    // Start a page.
967 -  virtual void startPage(int pageNum, GfxState *state);
968 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
969  
970    // End a page.
971    virtual void endPage();
972 @@ -196,6 +196,9 @@
973    virtual void setVectorAntialias(GBool vaa);
974  #endif
975  
976 +  void doUpdateFont(GfxState *state);
977 +  
978 +  SplashPath *convertPath(GfxState *state, GfxPath *path);
979  private:
980  
981    void setupScreenParams(double hDPI, double vDPI);
982 @@ -204,8 +207,6 @@
983  #else
984    SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
985  #endif
986 -  SplashPath *convertPath(GfxState *state, GfxPath *path);
987 -  void doUpdateFont(GfxState *state);
988    void drawType3Glyph(T3FontCache *t3Font,
989                       T3FontCacheTag *tag, Guchar *data);
990    static GBool imageMaskSrc(void *data, SplashColorPtr line);
991 --- xpdf/SplashScreen.cc.orig   2010-05-18 11:22:18.000000000 -0700
992 +++ xpdf/SplashScreen.cc        2010-05-18 11:22:18.000000000 -0700
993 @@ -363,6 +363,8 @@
994  int SplashScreen::test(int x, int y, Guchar value) {
995    int xx, yy;
996  
997 +  return 1;
998 +
999    if (value < minVal) {
1000      return 0;
1001    }
1002 --- xpdf/SplashXPathScanner.cc.orig     2010-05-18 11:22:18.000000000 -0700
1003 +++ xpdf/SplashXPathScanner.cc  2010-05-18 11:22:18.000000000 -0700
1004 @@ -394,10 +394,10 @@
1005           *p++ &= mask;
1006           xx = (xx & ~7) + 8;
1007         }
1008 -       for (; xx + 7 <= xx0; xx += 8) {
1009 +       for (; xx + 7 < xx0; xx += 8) {
1010           *p++ = 0x00;
1011         }
1012 -       if (xx <= xx0) {
1013 +       if (xx < xx0) {
1014           *p &= 0xff >> (xx0 & 7);
1015         }
1016        }
1017 @@ -417,10 +417,10 @@
1018         *p++ &= mask;
1019         xx = (xx & ~7) + 8;
1020        }
1021 -      for (; xx + 7 <= xx0; xx += 8) {
1022 +      for (; xx + 7 < xx0; xx += 8) {
1023         *p++ = 0x00;
1024        }
1025 -      if (xx <= xx0) {
1026 +      if (xx < xx0) {
1027         *p &= 0xff >> (xx0 & 7);
1028        }
1029      }
1030 --- xpdf/Stream.cc.orig 2010-05-18 11:22:18.000000000 -0700
1031 +++ xpdf/Stream.cc      2010-05-18 11:22:18.000000000 -0700
1032 @@ -18,6 +18,8 @@
1033  #include <limits.h>
1034  #ifndef WIN32
1035  #include <unistd.h>
1036 +#else
1037 +extern "C" int unlink(char *filename);
1038  #endif
1039  #include <string.h>
1040  #include <ctype.h>
1041 --- xpdf/Stream.h.orig  2010-05-18 11:22:18.000000000 -0700
1042 +++ xpdf/Stream.h       2010-05-18 11:22:18.000000000 -0700
1043 @@ -41,7 +41,8 @@
1044    streamCSNone,
1045    streamCSDeviceGray,
1046    streamCSDeviceRGB,
1047 -  streamCSDeviceCMYK
1048 +  streamCSDeviceCMYK,
1049 +  streamCSDeviceRGBX
1050  };
1051  
1052  //------------------------------------------------------------------------
1053 --- xpdf/TextOutputDev.cc.orig  2010-05-18 11:22:18.000000000 -0700
1054 +++ xpdf/TextOutputDev.cc       2010-05-18 11:22:18.000000000 -0700
1055 @@ -3877,7 +3877,7 @@
1056    }
1057  }
1058  
1059 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
1060 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
1061    text->startPage(state);
1062  }
1063  
1064 --- xpdf/TextOutputDev.h.orig   2010-05-18 11:22:18.000000000 -0700
1065 +++ xpdf/TextOutputDev.h        2010-05-18 11:22:18.000000000 -0700
1066 @@ -170,6 +170,7 @@
1067    friend class TextFlow;
1068    friend class TextWordList;
1069    friend class TextPage;
1070 +  friend class XMLOutputDev;
1071  };
1072  
1073  //------------------------------------------------------------------------
1074 @@ -578,7 +579,7 @@
1075    //----- initialization and control
1076  
1077    // Start a page.
1078 -  virtual void startPage(int pageNum, GfxState *state);
1079 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
1080  
1081    // End a page.
1082    virtual void endPage();
1083 --- xpdf/gfile.cc.orig  2010-05-18 11:22:18.000000000 -0700
1084 +++ xpdf/gfile.cc       2010-05-18 11:22:18.000000000 -0700
1085 @@ -439,6 +439,52 @@
1086  #endif
1087  }
1088  
1089 +static char* getTempDir()
1090 +{
1091 +#ifdef WIN32
1092 +    char*dir = getenv("TMP");
1093 +    if(!dir) dir = getenv("TEMP");
1094 +    if(!dir) dir = getenv("tmp");
1095 +    if(!dir) dir = getenv("temp");
1096 +    if(!dir) dir = "C:\\";
1097 +#else
1098 +    char* dir = "/tmp/";
1099 +#endif
1100 +    return dir;
1101 +}
1102 +
1103 +char* mktmpname(char*ptr) {
1104 +    static char tmpbuf[128];
1105 +    char*dir = getTempDir();
1106 +    int l = strlen(dir);
1107 +    char*sep = "";
1108 +    if(!ptr)
1109 +       ptr = tmpbuf;
1110 +    if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
1111 +#ifdef WIN32
1112 +       sep = "\\";
1113 +#else
1114 +       sep = "/";
1115 +#endif
1116 +    }
1117 +
1118 + //   used to be mktemp. This does remove the warnings, but
1119 + //   It's not exactly an improvement.
1120 +#ifdef HAVE_LRAND48
1121 +    sprintf(ptr, "%s%s%08x%08x",dir,sep,(unsigned int)lrand48(),(unsigned int)lrand48());
1122 +#else
1123 +#   ifdef HAVE_RAND
1124 +       sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
1125 +#   else
1126 +       static int count = 1;
1127 +       sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
1128 +       count ++;
1129 +#   endif
1130 +#endif
1131 +     return ptr;
1132 +}
1133 +
1134 +
1135  GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
1136  #if defined(WIN32)
1137    //---------- Win32 ----------
1138 @@ -460,7 +506,7 @@
1139    s->append("x");
1140    t = (int)time(NULL);
1141    for (i = 0; i < 1000; ++i) {
1142 -    sprintf(buf, "%d", t + i);
1143 +    sprintf(buf, "%08x-%08x", t + i, GetCurrentThreadId());
1144      s2 = s->copy()->append(buf);
1145      if (ext) {
1146        s2->append(ext);
1147 @@ -468,8 +514,7 @@
1148      if (!(f2 = fopen(s2->getCString(), "r"))) {
1149        if (!(f2 = fopen(s2->getCString(), mode))) {
1150         delete s2;
1151 -       delete s;
1152 -       return gFalse;
1153 +        continue;
1154        }
1155        *name = s2;
1156        *f = f2;
1157 @@ -479,6 +524,7 @@
1158      fclose(f2);
1159      delete s2;
1160    }
1161 +  fprintf(stderr, "Couldn't create temporary file\n");
1162    delete s;
1163    return gFalse;
1164  #elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS)
1165 @@ -489,7 +535,7 @@
1166    // with this file name after the tmpnam call and before the fopen
1167    // call.  I will happily accept fixes to this function for non-Unix
1168    // OSs.
1169 -  if (!(s = tmpnam(NULL))) {
1170 +  if (!(s = mktmpname(NULL))) {
1171      return gFalse;
1172    }
1173    *name = new GString(s);
1174 @@ -516,7 +562,7 @@
1175      (*name)->append("/XXXXXX")->append(ext);
1176      fd = mkstemps((*name)->getCString(), strlen(ext));
1177  #else
1178 -    if (!(s = tmpnam(NULL))) {
1179 +    if (!(s = mktmpname(NULL))) {
1180        return gFalse;
1181      }
1182      *name = new GString(s);
1183 @@ -533,7 +579,7 @@
1184      (*name)->append("/XXXXXX");
1185      fd = mkstemp((*name)->getCString());
1186  #else // HAVE_MKSTEMP
1187 -    if (!(s = tmpnam(NULL))) {
1188 +    if (!(s = mktmpname(NULL))) {
1189        return gFalse;
1190      }
1191      *name = new GString(s);
1192 --- xpdf/gfile.h.orig   2010-05-18 11:22:18.000000000 -0700
1193 +++ xpdf/gfile.h        2010-05-18 11:22:18.000000000 -0700
1194 @@ -58,6 +58,9 @@
1195  // Get current directory.
1196  extern GString *getCurrentDir();
1197  
1198 +/* create a temporary filename */
1199 +char* mktmpname(char*ptr);
1200 +
1201  // Append a file name to a path string.  <path> may be an empty
1202  // string, denoting the current directory).  Returns <path>.
1203  extern GString *appendToPath(GString *path, char *fileName);