summaryrefslogtreecommitdiff
path: root/padmin
diff options
context:
space:
mode:
authorPhilipp Lohmann <Philipp.Lohmann@Sun.COM>2009-10-13 19:36:40 +0200
committerPhilipp Lohmann <Philipp.Lohmann@Sun.COM>2009-10-13 19:36:40 +0200
commit65f75b3b255a4db2484d88ba03fed71ba331aa81 (patch)
tree8a5886fc90c6a5fcd2f1dfc374870c863330dc3d /padmin
parent280df82edc59bc802dcb9615d98090002ddfeed6 (diff)
#i105876# check fgets return (thanks cmc)
Diffstat (limited to 'padmin')
-rw-r--r--padmin/source/cmddlg.cxx54
1 files changed, 29 insertions, 25 deletions
diff --git a/padmin/source/cmddlg.cxx b/padmin/source/cmddlg.cxx
index 9aa65c8ce204..c6daf547369c 100644
--- a/padmin/source/cmddlg.cxx
+++ b/padmin/source/cmddlg.cxx
@@ -79,20 +79,22 @@ void CommandStore::getSystemPdfCommands( ::std::list< String >& rCommands )
pPipe = popen( "which gs 2>/dev/null", "r" );
if( pPipe )
{
- fgets( pBuffer, sizeof( pBuffer ), pPipe );
- int nLen = strlen( pBuffer );
- if( pBuffer[nLen-1] == '\n' ) // strip newline
- pBuffer[--nLen] = 0;
- aCommand = String( ByteString( pBuffer ), aEncoding );
- if( ( ( aCommand.GetChar( 0 ) == '/' )
- || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' )
- || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) )
- && nLen > 2
- && aCommand.GetChar( nLen-2 ) == 'g'
- && aCommand.GetChar( nLen-1 ) == 's' )
+ if (fgets( pBuffer, sizeof( pBuffer ), pPipe ) != NULL)
{
- aCommand.AppendAscii( " -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"(OUTFILE)\" -" );
- aSysCommands.push_back( aCommand );
+ int nLen = strlen( pBuffer );
+ if( pBuffer[nLen-1] == '\n' ) // strip newline
+ pBuffer[--nLen] = 0;
+ aCommand = String( ByteString( pBuffer ), aEncoding );
+ if( ( ( aCommand.GetChar( 0 ) == '/' )
+ || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' )
+ || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) )
+ && nLen > 2
+ && aCommand.GetChar( nLen-2 ) == 'g'
+ && aCommand.GetChar( nLen-1 ) == 's' )
+ {
+ aCommand.AppendAscii( " -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"(OUTFILE)\" -" );
+ aSysCommands.push_back( aCommand );
+ }
}
pclose( pPipe );
}
@@ -100,19 +102,21 @@ void CommandStore::getSystemPdfCommands( ::std::list< String >& rCommands )
pPipe = popen( "which distill 2>/dev/null", "r" );
if( pPipe )
{
- fgets( pBuffer, sizeof( pBuffer ), pPipe );
- int nLen = strlen( pBuffer );
- if( pBuffer[nLen-1] == '\n' ) // strip newline
- pBuffer[--nLen] = 0;
- aCommand = String( ByteString( pBuffer ), aEncoding );
- if( ( ( aCommand.GetChar( 0 ) == '/' )
- || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' )
- || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) )
- && nLen > 7
- && aCommand.Copy( nLen - 8 ).EqualsAscii( "/distill" ) )
+ if (fgets( pBuffer, sizeof( pBuffer ), pPipe ) != NULL)
{
- aCommand.AppendAscii( " (TMP) ; mv `echo (TMP) | sed s/\\.ps\\$/.pdf/` \"(OUTFILE)\"" );
- aSysCommands.push_back( aCommand );
+ int nLen = strlen( pBuffer );
+ if( pBuffer[nLen-1] == '\n' ) // strip newline
+ pBuffer[--nLen] = 0;
+ aCommand = String( ByteString( pBuffer ), aEncoding );
+ if( ( ( aCommand.GetChar( 0 ) == '/' )
+ || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' )
+ || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) )
+ && nLen > 7
+ && aCommand.Copy( nLen - 8 ).EqualsAscii( "/distill" ) )
+ {
+ aCommand.AppendAscii( " (TMP) ; mv `echo (TMP) | sed s/\\.ps\\$/.pdf/` \"(OUTFILE)\"" );
+ aSysCommands.push_back( aCommand );
+ }
}
pclose( pPipe );
}