[poppler] Use mkstemp if available

Kristian Høgsberg krh at bitplanet.net
Mon Apr 4 14:21:38 PDT 2005


Albert Astals Cid wrote:
> Patch i got for kpdf from Takashi Iwai <tiwai AT suse DOT de> adapted to 
> poppler

This patch isn't correct, though, mkstemp() requires the last six chars 
of the template string to be XXXXXX (gotta love that API).  The patch 
tries to use mkstemp() in a place where the temp file is created with a 
specific extension.

> It uses mkstemp if it is available, the problem is why poppler lost the 
> configure checks xpdf has for HAVE_MKSTEMP and HAVE_MKSTEMPS?

Hmmm, I think I dropped those on the floor when I ported over bits of 
the xpdf configure script.  I've added back checks for mkstemp() and 
mkstemps() for now, but I'd rather see a patch that eliminates the need 
for these temp files entirely.  After all, it's only used for reading 
font files out of the PDF, and freetype supports reading from a generic 
stream, so it should be possible to write some glue code to make this work.

cheers,
Kristian

> Albert
> 
> 
> ------------------------------------------------------------------------
> 
> Index: goo/gfile.cc
> ===================================================================
> RCS file: /cvs/poppler/poppler/goo/gfile.cc,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 gfile.cc
> --- goo/gfile.cc	3 Mar 2005 19:45:58 -0000	1.1.1.1
> +++ goo/gfile.cc	1 Apr 2005 17:06:56 -0000
> @@ -489,6 +489,14 @@
>      }
>      (*name)->append("/XXXXXX")->append(ext);
>      fd = mkstemps((*name)->getCString(), strlen(ext));
> +#elif defined(HAVE_MKSTEMP)
> +    if ((s = getenv("TMPDIR"))) {
> +      *name = new GooString(s);
> +    } else {
> +      *name = new GooString("/tmp");
> +    }
> +    (*name)->append("/XXXXXX")->append(ext);
> +    fd = mkstemp((*name)->getCString());

mkstemp requires the last six characters of the template to be XXXXXX 
(gotta love that API) so it can't be used in this case.

cheers,
Kristian


More information about the poppler mailing list