From: <and...@us...> - 2009-11-16 15:54:49
|
Revision: 10603 http://plplot.svn.sourceforge.net/plplot/?rev=10603&view=rev Author: andrewross Date: 2009-11-16 15:54:40 +0000 (Mon, 16 Nov 2009) Log Message: ----------- Fix up pl_create_tempfile to correctly open the file stream for reading as well as writing. Replace calls to tmpfile with pl_create_tempfile. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/plbuf.c trunk/src/plcore.c trunk/src/plstdio.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-11-16 15:17:45 UTC (rev 10602) +++ trunk/include/plplotP.h 2009-11-16 15:54:40 UTC (rev 10603) @@ -112,11 +112,7 @@ #include <string.h> #include <limits.h> #include <float.h> -#if defined ( PLPLOT_WINTK ) -#elif defined ( WIN32 ) & !defined ( __GNUC__ ) -/* Redefine tmpfile()! (AM)*/ -/* #define tmpfile w32_tmpfile */ -#else +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #endif Modified: trunk/src/plbuf.c =================================================================== --- trunk/src/plbuf.c 2009-11-16 15:17:45 UTC (rev 10602) +++ trunk/src/plbuf.c 2009-11-16 15:54:40 UTC (rev 10603) @@ -150,7 +150,7 @@ plbuf_tidy( pls ); #ifdef BUFFERED_FILE - pls->plbufFile = tmpfile(); + pls->plbufFile = pl_create_tempfile( NULL ); if ( pls->plbufFile == NULL ) plexit( "plbuf_bop: Error opening plot data storage file." ); #else @@ -1231,7 +1231,7 @@ } /* Copy the plot buffer to a tempfile */ - if (( plot_state->plbufFile = tmpfile()) == NULL ) + if (( plot_state->plbufFile = pl_create_tempfile( NULL )) == NULL ) { /* Throw a warning since this might be a permissions problem * and we may not want to force an exit Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2009-11-16 15:17:45 UTC (rev 10602) +++ trunk/src/plcore.c 2009-11-16 15:54:40 UTC (rev 10603) @@ -88,6 +88,8 @@ #define BUFFER2_SIZE 300 #define DRVSPEC_SIZE 400 +#include <errno.h> + /*--------------------------------------------------------------------------*\ * Driver Interface * @@ -2597,7 +2599,12 @@ /* Open a temporary file in which all the plD_DEVICE_INFO_<driver> strings * will be stored */ - fp_drvdb = tmpfile(); + fp_drvdb = pl_create_tempfile( NULL ); + if ( fp_drvdb == NULL ) + { + plabort( "plInitDispatchTable: Could not open temporary file" ); + return; + } /* Open the drivers directory */ drvdir = plGetDrvDir(); Modified: trunk/src/plstdio.c =================================================================== --- trunk/src/plstdio.c 2009-11-16 15:17:45 UTC (rev 10602) +++ trunk/src/plstdio.c 2009-11-16 15:54:40 UTC (rev 10603) @@ -210,7 +210,7 @@ strcat( template, tmpname ); #ifdef PL_HAVE_MKSTEMP - fd = fdopen( mkstemp( template ), "wb" ); + fd = fdopen( mkstemp( template ), "wb+" ); if ( fd == NULL ) { plwarn( "pl_create_tempfile: Unable to open temporary file - returning" ); @@ -220,8 +220,8 @@ } /* If we are not returning the file name then unlink the file so it is * automatically deleted. */ - if ( fd != NULL && fname == NULL ) - unlink( template ); + //if ( fname == NULL ) + // unlink( template ); #else #if !defined ( _S_IREAD ) #define _S_IREAD 256 @@ -236,7 +236,7 @@ if ( fname == NULL ) flags = flags | _O_TEMPORARY; mktemp( template ); - fd = fdopen( open( template, flags, _S_IREAD | _S_IWRITE ), "wb" ); + fd = fdopen( open( template, flags, _S_IREAD | _S_IWRITE ), "wb+" ); #endif if ( fname != NULL ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |