]> granicus.if.org Git - imagemagick/commitdiff
Fixed raising exception.
authordirk <dirk@git.imagemagick.org>
Sat, 3 May 2014 16:00:28 +0000 (16:00 +0000)
committerdirk <dirk@git.imagemagick.org>
Sat, 3 May 2014 16:00:28 +0000 (16:00 +0000)
coders/pdf.c
coders/ps.c

index 90f8378a937a591fd9a52d76c9678c025fc752e1..cdce09d342c5b7d025df79aca278a0db93bcab95 100644 (file)
@@ -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)
index cdb345ecc0f7951218f92878410eb71b613f5cb1..7b2cf0f92df74ad532c931d8a104bced46dc30b5 100644 (file)
@@ -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)