From: <and...@us...> - 2010-06-01 08:49:42
|
Revision: 11047 http://plplot.svn.sourceforge.net/plplot/?rev=11047&view=rev Author: andrewross Date: 2010-06-01 08:49:36 +0000 (Tue, 01 Jun 2010) Log Message: ----------- Add internal plCloseFile function, in analog to plOpenFile - this will close the output file unless the output is to stdout. Update drivers to i use this new function. Modified Paths: -------------- trunk/drivers/cairo.c trunk/drivers/cgm.c trunk/drivers/gd.c trunk/drivers/hpgl.c trunk/drivers/impress.c trunk/drivers/ljii.c trunk/drivers/ljiip.c trunk/drivers/pbm.c trunk/drivers/pdf.c trunk/drivers/ps.c trunk/drivers/pstex.c trunk/drivers/psttf.cc trunk/drivers/qt.cpp trunk/drivers/svg.c trunk/drivers/tek.c trunk/drivers/tk.c trunk/drivers/xfig.c trunk/include/plstrm.h trunk/src/plctrl.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/cairo.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -536,8 +536,7 @@ cairo_destroy( aStream->cairoContext ); cairo_surface_destroy( aStream->cairoSurface ); - if ( pls->OutFile ) - fclose( pls->OutFile ); + plCloseFile( pls ); } /*--------------------------------------------------------------------- Modified: trunk/drivers/cgm.c =================================================================== --- trunk/drivers/cgm.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/cgm.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -727,7 +727,7 @@ } cdImageDestroy( dev->im_out ); - fclose( pls->OutFile ); + plCloseFile( pls ); free_mem( pls->dev ); } Modified: trunk/drivers/gd.c =================================================================== --- trunk/drivers/gd.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/gd.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -1149,7 +1149,7 @@ } #endif - fclose( pls->OutFile ); + plCloseFile( pls ); free_mem( pls->dev ); } Modified: trunk/drivers/hpgl.c =================================================================== --- trunk/drivers/hpgl.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/hpgl.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -333,7 +333,7 @@ plD_tidy_hpgl( PLStream *pls ) { fputs( "SP0\n", OF ); - fclose( OF ); + plCloseFile( pls ); } /*--------------------------------------------------------------------------*\ Modified: trunk/drivers/impress.c =================================================================== --- trunk/drivers/impress.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/impress.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -244,7 +244,7 @@ plD_tidy_imp( PLStream *pls ) { free( (void *) LineBuff ); - fclose( pls->OutFile ); + plCloseFile( pls ); } /*--------------------------------------------------------------------------*\ Modified: trunk/drivers/ljii.c =================================================================== --- trunk/drivers/ljii.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/ljii.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -284,7 +284,7 @@ /* Reset Printer */ fprintf( OF, "%cE", ESC ); - fclose( OF ); + plCloseFile( pls ); free( (void *) bitmap ); } Modified: trunk/drivers/ljiip.c =================================================================== --- trunk/drivers/ljiip.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/ljiip.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -470,7 +470,7 @@ /* Reset Printer */ fprintf( OF, "%cE", ESC ); - fclose( OF ); + plCloseFile( pls ); free( (char *) bitmap ); } Modified: trunk/drivers/pbm.c =================================================================== --- trunk/drivers/pbm.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/pbm.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -263,7 +263,7 @@ if ( nwrite != im_size ) plabort( "pbm driver: Error writing pbm file" ); - fclose( fp ); + plCloseFile( pls ); } free( cmap ); cmap = 0; Modified: trunk/drivers/pdf.c =================================================================== --- trunk/drivers/pdf.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/pdf.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -399,7 +399,7 @@ plexit( "ERROR: Cannot write to file!" ); } - fclose( dev->pdfFile ); + plCloseFile( pls ); /* cleanup */ HPDF_Free( dev->pdf ); Modified: trunk/drivers/ps.c =================================================================== --- trunk/drivers/ps.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/ps.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -566,7 +566,7 @@ fprintf( OF, "%%!PS-Adobe-2.0 EPSF-2.0\n" ); fprintf( OF, "%%%%BoundingBox: %d %d %d %d\n", dev->llx, dev->lly, dev->urx, dev->ury ); - fclose( OF ); + plCloseFile( pls ); } /*--------------------------------------------------------------------------*\ Modified: trunk/drivers/pstex.c =================================================================== --- trunk/drivers/pstex.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/pstex.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -132,7 +132,7 @@ ROUND( ( dev->llx - XOFFSET ) * scale ), ROUND( ( dev->lly - YOFFSET ) * scale ) ); - fclose( fp ); + plCloseFile( pls ); } void Modified: trunk/drivers/psttf.cc =================================================================== --- trunk/drivers/psttf.cc 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/psttf.cc 2010-06-01 08:49:36 UTC (rev 11047) @@ -626,7 +626,7 @@ doc->write(cout,dev->llx,dev->lly,dev->urx,dev->ury); } else { - fclose(pls->OutFile); + plCloseFile( pls ); ofstream out; out.open(pls->FileName); doc->write(out,dev->llx,dev->lly,dev->urx,dev->ury); Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/qt.cpp 2010-06-01 08:49:36 UTC (rev 11047) @@ -452,7 +452,7 @@ delete widget; pls->dev = NULL; } - fclose( pls->OutFile ); + plCloseFile( pls ); closeQtApp(); } @@ -882,7 +882,7 @@ delete widget; pls->dev = NULL; } - fclose( pls->OutFile ); + plCloseFile( pls ); closeQtApp(); } @@ -1163,7 +1163,7 @@ delete widget; pls->dev = NULL; } - fclose( pls->OutFile ); + plCloseFile( pls ); closeQtApp(); } Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/svg.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -361,7 +361,7 @@ { return; } - fclose( aStream->svgFile ); + plCloseFile( pls ); } /*--------------------------------------------------------------------- Modified: trunk/drivers/tek.c =================================================================== --- trunk/drivers/tek.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/tek.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -583,7 +583,7 @@ { if ( !pls->termin ) { - fclose( pls->OutFile ); + plCloseFile( pls ); } else { Modified: trunk/drivers/tk.c =================================================================== --- trunk/drivers/tk.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/tk.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -885,7 +885,7 @@ if ( dev->iodev != NULL ) { if ( dev->iodev->file != NULL ) - fclose( dev->iodev->file ); + plCloseFile( pls ); free( (void *) dev->iodev ); } Modified: trunk/drivers/xfig.c =================================================================== --- trunk/drivers/xfig.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/drivers/xfig.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -371,7 +371,7 @@ flushbuffer( pls ); free( (void *) dev->buffptr ); - fclose( pls->OutFile ); + plCloseFile( pls ); } /*--------------------------------------------------------------------------*\ Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/include/plstrm.h 2010-06-01 08:49:36 UTC (rev 11047) @@ -789,6 +789,11 @@ PLDLLIMPEXP void plOpenFile( PLStream *pls ); +/* Close output file */ + +PLDLLIMPEXP void +plCloseFile( PLStream *pls ); + /* Sets up next file member name (in pls->FileName), but does not open it. */ void Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2010-05-31 19:49:08 UTC (rev 11046) +++ trunk/src/plctrl.c 2010-06-01 08:49:36 UTC (rev 11047) @@ -2294,6 +2294,25 @@ } /*--------------------------------------------------------------------------*\ + * plCloseFile() + * + * Closes output file unless it is associated with stdout. + \*--------------------------------------------------------------------------*/ + +void +plCloseFile( PLStream *pls ) +{ + if ( pls->OutFile != NULL) + { + /* Don't close if the output file was stdout */ + if ( pls->FileName && strcmp( pls->FileName, "-" ) == 0 ) return; + + fclose( pls->OutFile ); + pls->OutFile = NULL; + } +} + +/*--------------------------------------------------------------------------*\ * plP_getmember() * * Sets up next file member name (in pls->FileName), but does not open it. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |