]> granicus.if.org Git - imagemagick/commitdiff
Added Error Reporting
authoranthony <anthony@git.imagemagick.org>
Thu, 5 Apr 2012 14:25:46 +0000 (14:25 +0000)
committeranthony <anthony@git.imagemagick.org>
Thu, 5 Apr 2012 14:25:46 +0000 (14:25 +0000)
12 files changed:
MagickCore/fourier.c
MagickCore/list.c
MagickCore/option.c
MagickCore/option.h
MagickWand/animate.c
MagickWand/convert.c
MagickWand/magick-cli.c
MagickWand/mogrify.c
MagickWand/montage.c
MagickWand/operation.c
config/english.xml
config/francais.xml

index 658aa2c0187141499197db395cc6deb43c72f08c..b53043a5237619aa8a50883d8e5bc407e712ea5a 100644 (file)
@@ -249,7 +249,7 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info,
   if (phase_image == (Image *) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
-        "ImageSequenceRequired","`%s'",image->filename);
+        "TwoOrMoreImagesRequired","`%s'",image->filename);
       return(MagickFalse);
     }
   /*
@@ -1194,7 +1194,7 @@ MagickExport Image *InverseFourierTransformImage(const Image *magnitude_image,
   if (phase_image == (Image *) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
-        "ImageSequenceRequired","`%s'",magnitude_image->filename);
+        "TwoOrMoreImagesRequired","`%s'",magnitude_image->filename);
       return((Image *) NULL);
     }
 #if !defined(MAGICKCORE_FFTW_DELEGATE)
index 84ea4d16b5f9106508c0b77ae70187c0dbe4bbe1..1cd6d5c87ea38f5fe39234a7facc19520d72a742 100644 (file)
@@ -599,10 +599,9 @@ MagickExport Image *GetImageFromList(const Image *images,const ssize_t index)
 
   /*
     Designed to efficiently find first image (index == 0), or last image
-    (index == -1) as appropriate, without to go through the whole image list,
-    unless the offset is outside of the list length range.
-
-    That is it tries to avoid 'counting the whole list' to handle the index.
+    (index == -1) as appropriate, without to go through the whole image list.
+    That is it tries to avoid 'counting the whole list' to  handle the
+    most common image indexes.
   */
   if ( index < 0 )
     {
index 1929b0041065e04562676da5dbc2aedd37a2e54d..19a1e843c04b099293d9190f73ef52307e939aa1 100644 (file)
@@ -220,7 +220,7 @@ static const OptionInfo
     { "-backdrop", 1L, NonMagickOptionFlag, MagickFalse },
     { "+background", 0L, ImageInfoOptionFlag, MagickFalse },
     { "-background", 1L, ImageInfoOptionFlag, MagickFalse },
-    { "+bench", 0L, GenesisOptionFlag, MagickFalse },
+    { "+bench", 1L, DeprecateOptionFlag, MagickTrue },
     { "-bench", 1L, GenesisOptionFlag, MagickFalse },
     { "+bias", 0L, ImageInfoOptionFlag, MagickFalse },
     { "-bias", 1L, ImageInfoOptionFlag, MagickFalse },
@@ -293,7 +293,7 @@ static const OptionInfo
     { "-composite", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse },
     { "+compress", 0L, ImageInfoOptionFlag, MagickFalse },
     { "-compress", 1L, ImageInfoOptionFlag, MagickFalse },
-    { "+concurrent", 0L, GenesisOptionFlag, MagickFalse },
+    { "+concurrent", 0L, DeprecateOptionFlag, MagickTrue },
     { "-concurrent", 0L, GenesisOptionFlag, MagickFalse },
     { "+contrast", 0L, DeprecateOptionFlag, MagickTrue },
     { "-contrast", 0L, DeprecateOptionFlag, MagickTrue },
@@ -305,8 +305,8 @@ static const OptionInfo
     { "-crop", 1L, SimpleOperatorOptionFlag | FireOptionFlag, MagickFalse },
     { "+cycle", 1L, DeprecateOptionFlag, MagickTrue },
     { "-cycle", 1L, SimpleOperatorOptionFlag, MagickFalse },
-    { "+debug", 0L, GlobalOptionFlag|GenesisOptionFlag | FireOptionFlag, MagickFalse },
-    { "-debug", 1L, GlobalOptionFlag|GenesisOptionFlag | FireOptionFlag, MagickFalse },
+    { "+debug", 0L, GlobalOptionFlag | FireOptionFlag, MagickFalse },
+    { "-debug", 1L, GlobalOptionFlag | FireOptionFlag, MagickFalse },
     { "+decipher", 1L, DeprecateOptionFlag, MagickTrue },
     { "-decipher", 1L, SimpleOperatorOptionFlag, MagickFalse },
     { "+deconstruct", 0L, DeprecateOptionFlag, MagickTrue },
@@ -564,8 +564,8 @@ static const OptionInfo
     { "-recolor", 1L, DeprecateOptionFlag, MagickTrue },
     { "+red-primary", 0L, ImageInfoOptionFlag, MagickFalse },
     { "-red-primary", 1L, ImageInfoOptionFlag, MagickFalse },
-    { "+regard-warnings", 0L, GenesisOptionFlag, MagickFalse },
-    { "-regard-warnings", 0L, GenesisOptionFlag, MagickFalse },
+    { "+regard-warnings", 0L, ImageInfoOptionFlag, MagickFalse },
+    { "-regard-warnings", 0L, ImageInfoOptionFlag, MagickFalse },
     { "+region", 0L, SpecialOptionFlag, MagickFalse },
     { "-region", 1L, SpecialOptionFlag, MagickFalse },
     { "+remap", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse },
@@ -748,8 +748,8 @@ static const OptionInfo
     { "-window", 1L, NonMagickOptionFlag, MagickFalse },
     { "+window-group", 0L, NonMagickOptionFlag, MagickFalse },
     { "-window-group", 1L, NonMagickOptionFlag, MagickFalse },
-    { "+write", 1L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse },
-    { "-write", 1L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse },
+    { "+write", 1L, SpecialOptionFlag | FireOptionFlag, MagickFalse },
+    { "-write", 1L, SpecialOptionFlag | FireOptionFlag, MagickFalse },
     { (char *) NULL, 0L, UndefinedOptionFlag, MagickFalse }
   },
   ComposeOptions[] =
index 81ac3a55e9d927e0ca99f6b6935ef003deba86a0..35dd2e8f02e47624ecf5dcf32f7d669bb6ee0ca1 100644 (file)
@@ -145,6 +145,8 @@ typedef enum
   SpecialOptionFlag         = 0x0040,  /* Special handled Option */
   GenesisOptionFlag         = 0x0080,  /* Genesis Command Wrapper Option  */
 
+  ImageRequiredFlags        = 0x0030,  /* Flags also means Images Required */
+
   NonMagickOptionFlag       = 0x1000,  /* Option not used by Magick Command */
   FireOptionFlag            = 0x4000,  /* Convert operation seq firing point */
   DeprecateOptionFlag       = 0x8000   /* Deprecate option, give warning */
index f67725f90af77be2d9034540c306ba542e9c6139..49449793757f6f4a75351ae436902509b380b6e3 100644 (file)
@@ -574,7 +574,7 @@ WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
             if (k != 0)
               clone_images=image_stack[k-1].image;
             if (clone_images == (Image *) NULL)
-              ThrowAnimateException(ImageError,"ImageSequenceRequired",option);
+              ThrowAnimateException(ImageError,"UnableToCloneImage",option);
             FireImageStack(MagickFalse,MagickTrue,MagickTrue);
             if (*option == '+')
               clone_images=CloneImages(clone_images,"-1",exception);
index 8e13e48a59c8d968408abfb14cff88c70f683a31..016c0ac520128d7527daf4027792f419aa5508d1 100644 (file)
@@ -951,9 +951,8 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
             clone_images=image;
             if (k != 0)
               clone_images=image_stack[k-1].image;
-            /* FUTURE: Change error report to something more meaningful */
             if (clone_images == (Image *) NULL)
-              ThrowConvertException(ImageError,"ImageSequenceRequired",option);
+              ThrowConvertException(ImageError,"UnableToCloneImage",option);
             FireImageStack(MagickTrue,MagickTrue,MagickTrue);
             if (*option == '+')
               clone_images=CloneImages(clone_images,"-1",exception);
index 8177aa03f7e37eb5dd92d528221a573369783908..33ad1c7ad9305131d204f0b6c0988855a54aa7c0 100644 (file)
  \
   message=GetExceptionMessage(errno); \
   (void) ThrowMagickException(exception,GetMagickModule(),severity, \
-    tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \
+    tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context,message); \
   message=DestroyString(message); \
 }
 
 #if MagickCommandDebug >= 9
+/*
+  Temporary Debugging Information
+  FUTURE: these should be able to be printed out using 'percent escapes'
+  Actually 'Properities' can already be output with  "%[*]"
+*/
 static void OutputOptions(ImageInfo *image_info)
 {
   const char
@@ -273,10 +278,21 @@ WandExport void ProcessScriptOptions(MagickCLI *cli_wand,int argc,char **argv,
           cli_wand->line,cli_wand->line,option,count,option_type,arg1,arg2);
 #endif
 
+    if ( (option_type & GenesisOptionFlag) != 0 ) {
+      /* Genesis Options have no place in a magick script */
+      CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option);
+      goto next_token;
+    }
     if ( (option_type & DeprecateOptionFlag) != 0 ) {
       CLIWandException(OptionWarning,"DeprecatedOption",option);
       if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
         break;
+      /* fall through - do the depreciated option */
+    }
+    if (((option_type & ImageRequiredFlags) != 0 ) &&
+        ( cli_wand->wand.images != (Image *)NULL ) ) {
+      CLIWandException(OptionError,"NoImagesFound",option);
+      goto next_token;
     }
 
     /* handle special script-argument options here */
@@ -284,11 +300,18 @@ WandExport void ProcessScriptOptions(MagickCLI *cli_wand,int argc,char **argv,
     // or making use of the command line options.
     //CLICommandOptions(cli_wand,count+1,argv, MagickScriptArgsFlags);
 
-    /* Process Option from file */
+    /*
+      Process Option from file
+    */
     if ( (option_type & SpecialOptionFlag) != 0 ) {
-      if ( LocaleCompare(option,"-exit") == 0 )
-        break;
-      /* No "-script" option from script at this time - though posible */
+      if ( LocaleCompare(option,"-exit") == 0 ) {
+        break; /* forced end of script */
+      }
+      if ( LocaleCompare(option,"-script") == 0 ) {
+        CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option);
+        goto next_token;
+      }
+      /* handle any other special operators now */
       CLISpecialOperator(cli_wand,option,arg1);
     }
 
@@ -324,6 +347,10 @@ next_token:
   switch( token_info->status ) {
     case TokenStatusOK:
     case TokenStatusEOF:
+      if (cli_wand->image_list_stack != (Stack *)NULL)
+        CLIWandException(OptionError,"UnbalancedParenthesis", "(eof)");
+      else if (cli_wand->image_info_stack != (Stack *)NULL)
+        CLIWandException(OptionError,"UnbalancedBraces", "(eof)");
       break;
     case TokenStatusBadQuotes:
       /* Ensure last token has a sane length for error report */
@@ -464,11 +491,6 @@ WandExport int ProcessCommandOptions(MagickCLI *cli_wand, int argc,
       goto next_argument;
     }
 
-    if ( (option_type & DeprecateOptionFlag) != 0 ) {
-      CLIWandException(OptionWarning,"DeprecatedOption",option);
-      if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
-        return(i+count+1);
-    }
     if ((i+count) >= end ) {
       CLIWandException(OptionFatalError,"MissingArgument",option);
       if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
@@ -485,17 +507,32 @@ WandExport int ProcessCommandOptions(MagickCLI *cli_wand, int argc,
           i,option,count,option_type,arg1,arg2);
 #endif
 
+    if ( (option_type & DeprecateOptionFlag) != 0 ) {
+      CLIWandException(OptionWarning,"DeprecatedOption",option);
+      if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+        return(end);
+      /* fall through - do the depreciated option */
+    }
+    if ( (option_type & GenesisOptionFlag) != 0 ) {
+      goto next_argument;  /* ignore genesis options */
+    }
+    if (((option_type & ImageRequiredFlags) != 0 ) &&
+        ( cli_wand->wand.images == (Image *)NULL ) ) {
+      CLIWandException(OptionError,"NoImagesFound",option);
+      goto next_argument;
+    }
+
     if ( (option_type & SpecialOptionFlag) != 0 ) {
       if ( ( process_flags & ProcessExitOption ) != 0
            && LocaleCompare(option,"-exit") == 0 )
         return(i+count);
       if ( ( process_flags & ProcessScriptOption ) != 0
            && LocaleCompare(option,"-script") == 0) {
-        // Unbalanced Parenthesis if stack not empty
         // Call Script, with a filename as a zeroth argument
         ProcessScriptOptions(cli_wand,argc,argv,i+1);
         return(argc); /* no more options after script process! */
       }
+      /* handle any other special operators now */
       CLISpecialOperator(cli_wand,option,arg1);
     }
 
@@ -541,36 +578,27 @@ next_argument:
   (void) FormatLocaleFile(stderr, "CLI %d Write File: \"%s\"\n", i, option );
 #endif
 
-  // if stacks are not empty
-  //  ThrowConvertException(OptionError,"UnbalancedParenthesis",option,i);
+  /* check that stacks are empty */
+  if (cli_wand->image_list_stack != (Stack *)NULL)
+    CLIWandException(OptionError,"UnbalancedParenthesis", "(eof)");
+  else if (cli_wand->image_info_stack != (Stack *)NULL)
+    CLIWandException(OptionError,"UnbalancedBraces", "(eof)");
+  if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+    return(argc);
 
-  /* This is a valid 'do no write' option for a CLI */
+  /* This is a valid 'do no write' option - no images needed */
   if (LocaleCompare(option,"-exit") == 0 )
     return(argc);  /* just exit, no image write */
 
-  /* If there is an option -- produce an error */
+  /* If filename looks like an option -- produce an error */
   if (IsCommandOption(option) != MagickFalse) {
     CLIWandException(OptionError,"MissingOutputFilename",option);
     return(argc);
   }
 
-  /* If no images in MagickCLI */
-  if ( cli_wand->wand.images == (Image *) NULL ) {
-    /* a "null:" output coder with no images is not an error! */
-    if ( LocaleCompare(option,"null:") == 0 )
-      return(argc);
-    CLIWandException(OptionError,"NoImagesForFinalWrite",option);
-    return(argc);
-  }
-
-#if 0
-  WandListOperatorImages(cli_wand,"-write",option,(const char *)NULL);
-#else
   (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
        cli_wand->wand.exception);
-  (void) WriteImages(cli_wand->wand.image_info,cli_wand->wand.images,option,
-       cli_wand->wand.exception);
-#endif
+  CLISpecialOperator(cli_wand,"-write",option);
   return(argc);
 }
 \f
@@ -714,6 +742,7 @@ WandExport MagickBooleanType MagickImageCommand(ImageInfo *image_info,
 
   /* Initialize special "CLI Wand" to hold images and settings (empty) */
   cli_wand=AcquireMagickCLI(image_info,exception);
+  cli_wand->line=1;
 
   GetPathComponent(argv[0],TailPath,cli_wand->wand.name);
   ConcatenateMagickString(cli_wand->wand.name,"-CLI",MaxTextExtent);
@@ -727,11 +756,7 @@ WandExport MagickBooleanType MagickImageCommand(ImageInfo *image_info,
              "The convert is depreciated in IMv7, use \"magick\"\n");*/
   }
 
-  /* Special Case:  If command name ends with "script" then run it as is
-     a "-script" option is implied.  This allows you to name the "magick"
-     command "magick-script", and create scripts of the form...
-           #!/usr/bin/env magick-script
-  */
+  /* Special Case:  If command name ends with "script" implied "-script" */
   if (LocaleCompare("script",argv[0]+strlen(argv[0])-6) == 0) {
     GetPathComponent(argv[1],TailPath,cli_wand->wand.name);
     ProcessScriptOptions(cli_wand,argc,argv,1);
@@ -795,7 +820,9 @@ WandExport MagickBooleanType MagickImageCommand(ImageInfo *image_info,
   /* ------------- */
 
 Magick_Command_Cleanup:
-  /* recover original image_info from bottom of stack */
+  /* recover original image_info and clean up stacks */
+  while (cli_wand->image_list_stack != (Stack *)NULL)
+    CLISpecialOperator(cli_wand,")",(const char *)NULL);
   while (cli_wand->image_info_stack != (Stack *)NULL)
     CLISpecialOperator(cli_wand,"}",(const char *)NULL);
 
index af648f7b7e71e26de171f87373ef72d5bf8a8c84..5524af2f09b5fcb41567cad03127030fc9e3e1b0 100644 (file)
@@ -146,15 +146,15 @@ WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
     option=argv[i];
     if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
       continue;
-    if (LocaleCompare("bench",option+1) == 0)
+    if (LocaleCompare("-bench",option) == 0)
       iterations=StringToUnsignedLong(argv[++i]);
-    if (LocaleCompare("concurrent",option+1) == 0)
+    if (LocaleCompare("-concurrent",option) == 0)
       concurrent=MagickTrue;
-    if (LocaleCompare("debug",option+1) == 0)
+    if (LocaleCompare("-debug",option) == 0)
       (void) SetLogEventMask(argv[++i]);
-    if (LocaleCompare("duration",option+1) == 0)
+    if (LocaleCompare("-duration",option) == 0)
       duration=StringToDouble(argv[++i],(char **) NULL);
-    if (LocaleCompare("regard-warnings",option+1) == 0)
+    if (LocaleCompare("-regard-warnings",option) == 0)
       regard_warnings=MagickTrue;
   }
   if (iterations == 1)
index 7631d712ea06851e862ee3f6bc150b93ee4eb85e..9c8a910633d614d0f902f05e687d0b1d4bd4b0c9 100644 (file)
@@ -629,7 +629,7 @@ WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
             if (k != 0)
               clone_images=image_stack[k-1].image;
             if (clone_images == (Image *) NULL)
-              ThrowMontageException(ImageError,"ImageSequenceRequired",option);
+              ThrowMontageException(ImageError,"UnableToCloneImage",option);
             FireImageStack(MagickTrue,MagickTrue,MagickTrue);
             if (*option == '+')
               clone_images=CloneImages(clone_images,"-1",exception);
index 840c6f9225fc298b77653ddec66993e08731bca3..3f33f0bf6afb8ef76279d2beb0b5b2f3b74fbee1 100644 (file)
@@ -4405,10 +4405,14 @@ WandExport void CLIListOperatorImages(MagickCLI *cli_wand,
         }
         p=GetImageFromList(_images,index);
         q=GetImageFromList(_images,swap_index);
-        if ((p == (Image *) NULL) || (q == (Image *) NULL))
-          CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1);
+        if ((p == (Image *) NULL) || (q == (Image *) NULL)) {
+          if (IfNormalOp)
+            CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1)
+          else
+            CLIWandExceptionBreak(OptionError,"TwoOrMoreImagesRequired",option);
+        }
         if (p == q)
-          break;  /* same image - no-op - not an error */
+          CLIWandExceptArgBreak(OptionError,"InvalidImageIndex",option,arg1);
         swap=CloneImage(p,0,0,MagickTrue,_exception);
         ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));
         ReplaceImageInList(&q,swap);
@@ -4417,33 +4421,6 @@ WandExport void CLIListOperatorImages(MagickCLI *cli_wand,
       }
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
     }
-    case 'w':
-    {
-      if (LocaleCompare("write",option+1) == 0)
-        {
-          char
-            key[MaxTextExtent];
-
-          Image
-            *write_images;
-
-          ImageInfo
-            *write_info;
-
-          (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1);
-          (void) DeleteImageRegistry(key);
-          write_images=_images;
-          if (IfPlusOp)
-            write_images=CloneImageList(_images,_exception);
-          write_info=CloneImageInfo(_image_info);
-          (void) WriteImages(write_info,write_images,arg1,_exception);
-          write_info=DestroyImageInfo(write_info);
-          if (IfPlusOp)
-            write_images=DestroyImageList(write_images);
-          break;
-        }
-      CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
-    }
     default:
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
   }
@@ -4522,7 +4499,11 @@ WandExport void CLIListOperatorImages(MagickCLI *cli_wand,
 WandExport void CLISpecialOperator(MagickCLI *cli_wand,
   const char *option, const char *arg1)
 {
-#define _exception       (cli_wand->wand.exception)
+#define _image_info     (cli_wand->wand.image_info)
+#define _images         (cli_wand->wand.images)
+#define _exception      (cli_wand->wand.exception)
+#define IfNormalOp      (*option=='-')
+#define IfPlusOp        (*option!='-')
 
   assert(cli_wand != (MagickCLI *) NULL);
   assert(cli_wand->signature == WandSignature);
@@ -4530,9 +4511,8 @@ WandExport void CLISpecialOperator(MagickCLI *cli_wand,
   if (IfMagickTrue(cli_wand->wand.debug))
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
 
-  if(cli_wand->wand.images != (Image *)NULL)
-    (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
-         _exception);
+  if(_images != (Image *)NULL)
+    (void) SyncImagesSettings(cli_wand->wand.image_info,_images,_exception);
 
   /*
     No-op options
@@ -4573,11 +4553,11 @@ WandExport void CLISpecialOperator(MagickCLI *cli_wand,
 #if !USE_WAND_METHODS
       Image *
         new_images;
-      if (IfMagickTrue(cli_wand->wand.image_info->ping))
-        new_images=PingImages(cli_wand->wand.image_info,argv[i],_exception);
+      if (IfMagickTrue(_image_info->ping))
+        new_images=PingImages(_image_info,argv[i],_exception);
       else
-        new_images=ReadImages(cli_wand->wand.image_info,argv[i],_exception);
-      AppendImageToList(&cli_wand->wand.images, new_images);
+        new_images=ReadImages(_image_info,argv[i],_exception);
+      AppendImageToList(&_images, new_images);
 #else
       /* read images using MagickWand method - no ping */
       /* This is not working! - it locks up in a CPU loop! */
@@ -4590,126 +4570,158 @@ WandExport void CLISpecialOperator(MagickCLI *cli_wand,
 
     return;
   }
+  /*
+    Image Writing
+  */
+  if (LocaleCompare("write",option+1) == 0) {
+    char
+      key[MaxTextExtent];
+
+    Image
+      *write_images;
+
+    ImageInfo
+      *write_info;
+
+    /* Need images, unless a "null:" output coder is used */
+    if ( cli_wand->wand.images == (Image *) NULL ) {
+      if ( LocaleCompare(option,"null:") == 0 )
+        return;
+      CLIWandExceptArgReturn(OptionError,"NoImagesForWrite",option,arg1);
+    }
+
+    (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1);
+    (void) DeleteImageRegistry(key);
+    write_images=_images;
+    if (IfPlusOp)
+      write_images=CloneImageList(_images,_exception);
+    write_info=CloneImageInfo(_image_info);
+    (void) WriteImages(write_info,write_images,arg1,_exception);
+    write_info=DestroyImageInfo(write_info);
+    if (IfPlusOp)
+      write_images=DestroyImageList(write_images);
+    return;
+  }
   /*
     Parenthesis and Brace operations
   */
   if (LocaleCompare("respect-parenthesis",option+1) == 0) {
       /* link image and setting stacks - option is itself saved on stack! */
       (void) SetImageOption(cli_wand->wand.image_info,option+1,
-           *option == '-' ? "true" : (char *) NULL);
+           IfNormalOp ? "true" : (char *) NULL);
       return;
     }
   if (LocaleCompare("(",option) == 0) {
-      /* stack 'push' images */
-      Stack
-        *node;
-
-      size_t
-        size;
-
-      size=0;
-      node=cli_wand->image_list_stack;
-      for ( ; node != (Stack *)NULL; node=node->next)
-        size++;
-      if ( size >= MAX_STACK_DEPTH )
-        CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option);
-      node=(Stack *) AcquireMagickMemory(sizeof(*node));
-      if (node == (Stack *) NULL)
-        CLIWandExceptionReturn(ResourceLimitFatalError,
-             "MemoryAllocationFailed",option);
-      node->data = (void *)cli_wand->wand.images;
-      cli_wand->wand.images = NewImageList();
-      node->next = cli_wand->image_list_stack;
-      cli_wand->image_list_stack = node;
-
-      /* handle respect-parenthesis */
-      if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info,
-                    "respect-parenthesis"))))
-        option="{"; /* fall-thru so as to push image settings too */
-      else
-        return;
-    }
+    /* stack 'push' images */
+    Stack
+      *node;
+
+    size_t
+      size;
+
+    size=0;
+    node=cli_wand->image_list_stack;
+    for ( ; node != (Stack *)NULL; node=node->next)
+      size++;
+    if ( size >= MAX_STACK_DEPTH )
+      CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option);
+    node=(Stack *) AcquireMagickMemory(sizeof(*node));
+    if (node == (Stack *) NULL)
+      CLIWandExceptionReturn(ResourceLimitFatalError,
+           "MemoryAllocationFailed",option);
+    node->data = (void *)cli_wand->wand.images;
+    cli_wand->wand.images = NewImageList();
+    node->next = cli_wand->image_list_stack;
+    cli_wand->image_list_stack = node;
+
+    /* handle respect-parenthesis */
+    if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info,
+                  "respect-parenthesis"))))
+      option="{"; /* fall-thru so as to push image settings too */
+    else
+      return;
+  }
   if (LocaleCompare("{",option) == 0) {
-      /* stack 'push' of image_info settings */
-      Stack
-        *node;
-
-      size_t
-        size;
-
-      size=0;
-      node=cli_wand->image_info_stack;
-      for ( ; node != (Stack *)NULL; node=node->next)
-        size++;
-      if ( size >= MAX_STACK_DEPTH )
-        CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option);
-      node=(Stack *) AcquireMagickMemory(sizeof(*node));
-      if (node == (Stack *) NULL)
-        CLIWandExceptionReturn(ResourceLimitFatalError,
-             "MemoryAllocationFailed",option);
-
-      node->data = (void *)cli_wand->wand.image_info;
-      cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
-      if (cli_wand->wand.image_info == (ImageInfo *)NULL) {
-        CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed",
-             option);
-        cli_wand->wand.image_info = (ImageInfo *)node->data;
-        node = (Stack *)RelinquishMagickMemory(node);
-        return;
-      }
-
-      node->next = cli_wand->image_info_stack;
-      cli_wand->image_info_stack = node;
-
+    /* stack 'push' of image_info settings */
+    Stack
+      *node;
+
+    size_t
+      size;
+
+    size=0;
+    node=cli_wand->image_info_stack;
+    for ( ; node != (Stack *)NULL; node=node->next)
+      size++;
+    if ( size >= MAX_STACK_DEPTH )
+      CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option);
+    node=(Stack *) AcquireMagickMemory(sizeof(*node));
+    if (node == (Stack *) NULL)
+      CLIWandExceptionReturn(ResourceLimitFatalError,
+           "MemoryAllocationFailed",option);
+
+    node->data = (void *)cli_wand->wand.image_info;
+    cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
+    if (cli_wand->wand.image_info == (ImageInfo *)NULL) {
+      CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed",
+           option);
+      cli_wand->wand.image_info = (ImageInfo *)node->data;
+      node = (Stack *)RelinquishMagickMemory(node);
       return;
     }
-  if (LocaleCompare(")",option) == 0) {
-      /* pop images from stack */
-      Stack
-        *node;
 
-      node = (Stack *)cli_wand->image_list_stack;
-      if ( node == (Stack *)NULL)
-        CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option);
-      cli_wand->image_list_stack = node->next;
+    node->next = cli_wand->image_info_stack;
+    cli_wand->image_info_stack = node;
 
-      AppendImageToList((Image **)&node->data,cli_wand->wand.images);
-      cli_wand->wand.images= (Image *)node->data;
-      node = (Stack *)RelinquishMagickMemory(node);
-
-      /* handle respect-parenthesis - of the previous 'pushed' settings */
-      node = cli_wand->image_info_stack;
-      if ( node != (Stack *)NULL)
-        {
-          if (IfMagickTrue(IsStringTrue(GetImageOption(
-                 cli_wand->wand.image_info,"respect-parenthesis"))))
-            option="}"; /* fall-thru so as to pop image settings too */
-          else
-            return;
-        }
-      else
-        return;
-    }
+    return;
+  }
+  if (LocaleCompare(")",option) == 0) {
+    /* pop images from stack */
+    Stack
+      *node;
+
+    node = (Stack *)cli_wand->image_list_stack;
+    if ( node == (Stack *)NULL)
+      CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option);
+    cli_wand->image_list_stack = node->next;
+
+    AppendImageToList((Image **)&node->data,cli_wand->wand.images);
+    cli_wand->wand.images= (Image *)node->data;
+    node = (Stack *)RelinquishMagickMemory(node);
+
+    /* handle respect-parenthesis - of the previous 'pushed' settings */
+    node = cli_wand->image_info_stack;
+    if ( node != (Stack *)NULL)
+      {
+        if (IfMagickTrue(IsStringTrue(GetImageOption(
+               cli_wand->wand.image_info,"respect-parenthesis"))))
+          option="}"; /* fall-thru so as to pop image settings too */
+        else
+          return;
+      }
+    else
+      return;
+  }
   if (LocaleCompare("}",option) == 0) {
-      /* pop image_info settings from stack */
-      Stack
-        *node;
+    /* pop image_info settings from stack */
+    Stack
+      *node;
 
-      node = (Stack *)cli_wand->image_info_stack;
-      if ( node == (Stack *)NULL)
-        CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option);
-      cli_wand->image_info_stack = node->next;
+    node = (Stack *)cli_wand->image_info_stack;
+    if ( node == (Stack *)NULL)
+      CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option);
+    cli_wand->image_info_stack = node->next;
 
-      (void) DestroyImageInfo(cli_wand->wand.image_info);
-      cli_wand->wand.image_info = (ImageInfo *)node->data;
-      node = (Stack *)RelinquishMagickMemory(node);
+    (void) DestroyImageInfo(cli_wand->wand.image_info);
+    cli_wand->wand.image_info = (ImageInfo *)node->data;
+    node = (Stack *)RelinquishMagickMemory(node);
 
-      GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
-      cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
-      cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
+    GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
+    cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
+    cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
 
-      return;
-    }
+    return;
+  }
   if (LocaleCompare("clone",option+1) == 0) {
       Image
         *new_images;
@@ -4726,105 +4738,105 @@ WandExport void CLISpecialOperator(MagickCLI *cli_wand,
       new_images=CloneImages(new_images,arg1,_exception);
       if (new_images == (Image *) NULL)
         CLIWandExceptionReturn(OptionError,"NoSuchImage",option);
-      AppendImageToList(&cli_wand->wand.images,new_images);
+      AppendImageToList(&_images,new_images);
       return;
     }
   /*
     Informational Operations
   */
   if (LocaleCompare("version",option+1) == 0) {
-      (void) FormatLocaleFile(stdout,"Version: %s\n",
-        GetMagickVersion((size_t *) NULL));
-      (void) FormatLocaleFile(stdout,"Copyright: %s\n",
-        GetMagickCopyright());
-      (void) FormatLocaleFile(stdout,"Features: %s\n\n",
-        GetMagickFeatures());
+    (void) FormatLocaleFile(stdout,"Version: %s\n",
+      GetMagickVersion((size_t *) NULL));
+    (void) FormatLocaleFile(stdout,"Copyright: %s\n",
+      GetMagickCopyright());
+    (void) FormatLocaleFile(stdout,"Features: %s\n\n",
+      GetMagickFeatures());
+    return;
+  }
+  if (LocaleCompare("list",option+1) == 0) {
+    /* FUTURE: This should really be built into the MagickCore
+       It does not actually require a cli-wand or and images!
+     */
+    ssize_t
+      list;
+
+    list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
+    if ( list < 0 ) {
+      CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
       return;
     }
-  if (LocaleCompare("list",option+1) == 0) {
-      /* FUTURE: This should really be built into the MagickCore
-         It does not actually require any wand or images at all!
-       */
-      ssize_t
-        list;
-
-      list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
-      if ( list < 0 ) {
-        CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
-        return;
+    switch (list)
+    {
+      case MagickCoderOptions:
+      {
+        (void) ListCoderInfo((FILE *) NULL,_exception);
+        break;
       }
-      switch (list)
+      case MagickColorOptions:
       {
-        case MagickCoderOptions:
-        {
-          (void) ListCoderInfo((FILE *) NULL,_exception);
-          break;
-        }
-        case MagickColorOptions:
-        {
-          (void) ListColorInfo((FILE *) NULL,_exception);
-          break;
-        }
-        case MagickConfigureOptions:
-        {
-          (void) ListConfigureInfo((FILE *) NULL,_exception);
-          break;
-        }
-        case MagickDelegateOptions:
-        {
-          (void) ListDelegateInfo((FILE *) NULL,_exception);
-          break;
-        }
-        case MagickFontOptions:
-        {
-          (void) ListTypeInfo((FILE *) NULL,_exception);
-          break;
-        }
-        case MagickFormatOptions:
-          (void) ListMagickInfo((FILE *) NULL,_exception);
-          break;
-        case MagickLocaleOptions:
-          (void) ListLocaleInfo((FILE *) NULL,_exception);
-          break;
-        case MagickLogOptions:
-          (void) ListLogInfo((FILE *) NULL,_exception);
-          break;
-        case MagickMagicOptions:
-          (void) ListMagicInfo((FILE *) NULL,_exception);
-          break;
-        case MagickMimeOptions:
-          (void) ListMimeInfo((FILE *) NULL,_exception);
-          break;
-        case MagickModuleOptions:
-          (void) ListModuleInfo((FILE *) NULL,_exception);
-          break;
-        case MagickPolicyOptions:
-          (void) ListPolicyInfo((FILE *) NULL,_exception);
-          break;
-        case MagickResourceOptions:
-          (void) ListMagickResourceInfo((FILE *) NULL,_exception);
-          break;
-        case MagickThresholdOptions:
-          (void) ListThresholdMaps((FILE *) NULL,_exception);
-          break;
-        default:
-          (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
-            _exception);
-          break;
+        (void) ListColorInfo((FILE *) NULL,_exception);
+        break;
       }
-      return;
+      case MagickConfigureOptions:
+      {
+        (void) ListConfigureInfo((FILE *) NULL,_exception);
+        break;
+      }
+      case MagickDelegateOptions:
+      {
+        (void) ListDelegateInfo((FILE *) NULL,_exception);
+        break;
+      }
+      case MagickFontOptions:
+      {
+        (void) ListTypeInfo((FILE *) NULL,_exception);
+        break;
+      }
+      case MagickFormatOptions:
+        (void) ListMagickInfo((FILE *) NULL,_exception);
+        break;
+      case MagickLocaleOptions:
+        (void) ListLocaleInfo((FILE *) NULL,_exception);
+        break;
+      case MagickLogOptions:
+        (void) ListLogInfo((FILE *) NULL,_exception);
+        break;
+      case MagickMagicOptions:
+        (void) ListMagicInfo((FILE *) NULL,_exception);
+        break;
+      case MagickMimeOptions:
+        (void) ListMimeInfo((FILE *) NULL,_exception);
+        break;
+      case MagickModuleOptions:
+        (void) ListModuleInfo((FILE *) NULL,_exception);
+        break;
+      case MagickPolicyOptions:
+        (void) ListPolicyInfo((FILE *) NULL,_exception);
+        break;
+      case MagickResourceOptions:
+        (void) ListMagickResourceInfo((FILE *) NULL,_exception);
+        break;
+      case MagickThresholdOptions:
+        (void) ListThresholdMaps((FILE *) NULL,_exception);
+        break;
+      default:
+        (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
+          _exception);
+        break;
     }
+    return;
+  }
 
 #if 0
-    // adjust stack handling
   // Other 'special' options this should handle
-  //    "region" "list" "version"
-  // It does not do "exit" however as due to its side-effect requirements
-#endif
-#if 0
+  //    "region"
   if ( ( process_flags & ProcessUnknownOptionError ) != 0 )
 #endif
     CLIWandException(OptionError,"UnrecognizedOption",option);
 
+#undef _image_info
+#undef _images
 #undef _exception
+#undef IfNormalOp
+#undef IfPlusOp
 }
index 6870fda791d41b22fc36f3bc9d74c3c258837c33..79aab307d133ec5bea9def93beb647be51eb8c3d 100644 (file)
         <message name="ImageDepthNotSupported">
           image depth not supported
         </message>
-        <message name="ImageSequenceRequired">
-          image sequence is required
+        <message name="ImageListRequired">
+          image list is required
         </message>
         <message name="ImageSizeDiffers">
           image size differs
           geometry does not contain image
         </message>
         <message name="InvalidUseOfOption">
-          invalif use of option
+          invalid use of option
+        </message>
+        <message name="InvalidArgument">
+          invalid argument for option
+        </message>
+        <message name="InvalidGeometry">
+          invalid geometry
+        </message>
+        <message name="InvalidImageIndex">
+          invalid image index
         </message>
         <message name="ImagesAreNotTheSameSize">
           images are not the same size
         <message name="ImageWidthsOrHeightsDiffer">
           image widths or heights differ
         </message>
-        <message name="InvalidArgument">
-          invalid argument for option
-        </message>
-        <message name="InvalidGeometry">
-          invalid geometry
-        </message>
         <message name="KernelWidthMustBeAnOddNumber">
           kernel width must be an odd number
         </message>
         <message name="NoClipPathDefined">
           no clip path defined
         </message>
-        <message name="NoImagesDefined">
-          no images defined for operation
+        <message name="NoImagesForWrite">
+          no images for write
         </message>
-        <message name="NoImagesForFinalWrite">
-          no images for final write
+        <message name="NoImagesFound">
+          no images found for operation
         </message>
         <message name="NoImageVectorGraphics">
           no image vector graphics
         <message name="SubimageSpecificationReturnsNoImages">
           subimage specification returns no images
         </message>
+        <message name="TwoOrMoreImagesRequired">
+          two or more images required
+        </message>
         <message name="UnableToOpenFile">
           unable to open file
         </message>
         <message name="UnableToParseKernel">
           unable to parse kernel string
         </message>
+        <message name="UnbalancedBraces">
+          unbalanced braces
+        </message>
         <message name="UnbalancedParenthesis">
           unbalanced parenthesis
         </message>
index bfc86805509a256d137ec098f003fcafb155eb8d..1d338deaee53798f313e6a2dc6e1719b299bfe19 100644 (file)
         <message name="ImageDepthNotSupported">
           profondeur d'image non supportée
         </message>
-        <message name="ImageSequenceRequired">
-          une séquence d'images est requise
+        <message name="ImageListRequired">
+          une liste d'images est requise
         </message>
         <message name="ImageSizeDiffers">
           différences dans la taille de l'image
         <message name="InvalidUseOfOption">
           Invalide utilisation de l'option
         </message>
+        <message name="InvalidArgument">
+          argument invalide pour l'option
+        </message>
+        <message name="InvalidGeometry">
+          géométrie invalide
+        </message>
+        <message name="InvalidImageIndex">
+          index de l'image non valide
+        </message>
         <message name="ImagesAreNotTheSameSize">
           images diffèrent par la taille
         </message>
         <message name="ImageWidthsOrHeightsDiffer">
           différences dans la hauteur ou la largeur de l'image
         </message>
-        <message name="InvalidArgument">
-          argument invalide pour l'option
-        </message>
-        <message name="InvalidGeometry">
-          géométrie invalide
-        </message>
         <message name="KernelWidthMustBeAnOddNumber">
           la largeur du grain doit être un nombre impair
         </message>
         <message name="NoClipPathDefined">
           pas de chemin de coupe défini
         </message>
-        <message name="NoImagesDefined">
-          pas d'images définies pour un fonctionnement
+        <message name="NoImagesForWrite">
+          pas d'images pour écriture
         </message>
-        <message name="NoImagesForFinalWrite">
-          pas d'images pour écriture finales
+        <message name="NoImagesFound">
+          pas d'image pour un fonctionnement
         </message>
         <message name="NoImageVectorGraphics">
           pas de graphiques vectoriels
         <message name="SubimageSpecificationReturnsNoImages">
           la spécification de sous-image ne permet pas de fournir des images
         </message>
+        <message name="TwoOrMoreImagesRequired">
+          deux ou plusieurs images nécessaires
+        </message>
         <message name="UnableToOpenFile">
           impossible d'ouvrir le fichier
         </message>
         <message name="UnableToParseKernel">
           impossible d'analyser l'kernel string
         </message>
+        <message name="UnbalancedBraces">
+          brace non fermée
+        </message>
         <message name="UnbalancedParenthesis">
           parenthèse non fermée
         </message>