openbsd-ports/graphics/djvulibre/patches/patch-libdjvu_DjVuDocEditor_cpp
steven 004161d071 import djvulibre 3.5.17
DjVuLibre is an open source implementation of DjVu, including viewers,
decoders, simple encoders, and utilities.

ok sturm@
2006-07-16 16:48:07 +00:00

28 lines
1.1 KiB
Plaintext

$OpenBSD: patch-libdjvu_DjVuDocEditor_cpp,v 1.1.1.1 2006/07/16 16:48:07 steven Exp $
--- libdjvu/DjVuDocEditor.cpp.orig Wed May 25 22:24:52 2005
+++ libdjvu/DjVuDocEditor.cpp Sun Jul 16 15:48:41 2006
@@ -192,8 +192,21 @@ DjVuDocEditor::init(const GURL &url)
{
// Suxx. I need to convert it NOW.
// We will unlink this file in the destructor
- tmp_doc_url=GURL::Filename::Native(tmpnam(0));
- const GP<ByteStream> gstr(ByteStream::create(tmp_doc_url, "wb"));
+ char tfn[20];
+ FILE *tfp;
+ int tfd;
+
+ strlcpy(tfn, "/tmp/djvustream.XXXXXXXX", sizeof(tfn));
+ if ((tfd = mkstemp(tfn)) == -1 || (tfp = fdopen(tfd, "w+")) == NULL) {
+ if (tfd != -1) {
+ unlink(tfn);
+ close(tfd);
+ }
+ fprintf(stderr, "problem with temporary file: %s\n", tfn);
+ G_THROW( ERR_MSG("DjVuDocEditor.init") );
+ }
+ tmp_doc_url=GURL::Filename::Native(tfn);
+ const GP<ByteStream> gstr(ByteStream::create(tfp, "w+", true));
tmp_doc->write(gstr, true); // Force DJVM format
gstr->flush();
doc_pool=DataPool::create(tmp_doc_url);