From: dirk Date: Sat, 3 May 2014 16:00:28 +0000 (+0000) Subject: Fixed raising exception. X-Git-Tag: 7.0.1-0~2367 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3682e9f6f24920ae4469ae141531a464916829b;p=imagemagick Fixed raising exception. --- diff --git a/coders/pdf.c b/coders/pdf.c index 90f8378a9..cdce09d34 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -164,6 +164,18 @@ static MagickBooleanType InvokePDFDelegate(const MagickBooleanType verbose, } \ } +#define ExecuteGhostscriptCommand \ + { \ + status=SystemCommand(MagickFalse,verbose,command,exception); \ + if (status == 0) \ + return(MagickTrue); \ + if (status < 0) \ + return(MagickFalse); \ + (void) ThrowMagickException(exception,GetMagickModule(),DelegateError, \ + "FailedToExecuteCommand","`%s' (%d)",command,status); \ + return(MagickFalse); \ + } + const char *args_start=NULL; @@ -210,10 +222,7 @@ static MagickBooleanType InvokePDFDelegate(const MagickBooleanType verbose, gsapi_set_stdio; #endif if (ghost_info == (GhostInfo *) NULL) - { - status=SystemCommand(MagickFalse,verbose,command,exception); - return(status == 0 ? MagickTrue : MagickFalse); - } + ExecuteGhostscriptCommand if (verbose != MagickFalse) { (void) fputs("[ghostscript library]",stdout); @@ -223,10 +232,7 @@ static MagickBooleanType InvokePDFDelegate(const MagickBooleanType verbose, errors=(char *) NULL; status=(ghost_info->new_instance)(&interpreter,(void *) &errors); if (status < 0) - { - status=SystemCommand(MagickFalse,verbose,command,exception); - return(status == 0 ? MagickTrue : MagickFalse); - } + ExecuteGhostscriptCommand code=0; argv=StringToArgv(command,&argc); if (argv == (char **) NULL) diff --git a/coders/ps.c b/coders/ps.c index cdb345ecc..7b2cf0f92 100644 --- a/coders/ps.c +++ b/coders/ps.c @@ -153,6 +153,18 @@ static MagickBooleanType InvokePostscriptDelegate( } \ } +#define ExecuteGhostscriptCommand \ + { \ + status=SystemCommand(MagickFalse,verbose,command,exception); \ + if (status == 0) \ + return(MagickTrue); \ + if (status < 0) \ + return(MagickFalse); \ + (void) ThrowMagickException(exception,GetMagickModule(),DelegateError, \ + "FailedToExecuteCommand","`%s' (%d)",command,status); \ + return(MagickFalse); \ + } + const char *args_start=NULL; @@ -199,10 +211,7 @@ static MagickBooleanType InvokePostscriptDelegate( gsapi_set_stdio; #endif if (ghost_info == (GhostInfo *) NULL) - { - status=SystemCommand(MagickFalse,verbose,command,exception); - return(status == 0 ? MagickTrue : MagickFalse); - } + ExecuteGhostscriptCommand if (verbose != MagickFalse) { (void) fputs("[ghostscript library]",stdout); @@ -212,10 +221,7 @@ static MagickBooleanType InvokePostscriptDelegate( errors=(char *) NULL; status=(ghost_info->new_instance)(&interpreter,(void *) &errors); if (status < 0) - { - status=SystemCommand(MagickFalse,verbose,command,exception); - return(status == 0 ? MagickTrue : MagickFalse); - } + ExecuteGhostscriptCommand code=0; argv=StringToArgv(command,&argc); if (argv == (char **) NULL)