From 8226e729aec80913941e8aa6b197e3efd03dfb43 Mon Sep 17 00:00:00 2001 From: anthony Date: Thu, 5 Apr 2012 14:25:46 +0000 Subject: [PATCH] Added Error Reporting --- MagickCore/fourier.c | 4 +- MagickCore/list.c | 7 +- MagickCore/option.c | 16 +- MagickCore/option.h | 2 + MagickWand/animate.c | 2 +- MagickWand/convert.c | 3 +- MagickWand/magick-cli.c | 99 +++++---- MagickWand/mogrify.c | 10 +- MagickWand/montage.c | 2 +- MagickWand/operation.c | 452 +++++++++++++++++++++------------------- config/english.xml | 35 ++-- config/francais.xml | 33 +-- 12 files changed, 361 insertions(+), 304 deletions(-) diff --git a/MagickCore/fourier.c b/MagickCore/fourier.c index 658aa2c01..b53043a52 100644 --- a/MagickCore/fourier.c +++ b/MagickCore/fourier.c @@ -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) diff --git a/MagickCore/list.c b/MagickCore/list.c index 84ea4d16b..1cd6d5c87 100644 --- a/MagickCore/list.c +++ b/MagickCore/list.c @@ -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 ) { diff --git a/MagickCore/option.c b/MagickCore/option.c index 1929b0041..19a1e843c 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -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[] = diff --git a/MagickCore/option.h b/MagickCore/option.h index 81ac3a55e..35dd2e8f0 100644 --- a/MagickCore/option.h +++ b/MagickCore/option.h @@ -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 */ diff --git a/MagickWand/animate.c b/MagickWand/animate.c index f67725f90..494497937 100644 --- a/MagickWand/animate.c +++ b/MagickWand/animate.c @@ -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); diff --git a/MagickWand/convert.c b/MagickWand/convert.c index 8e13e48a5..016c0ac52 100644 --- a/MagickWand/convert.c +++ b/MagickWand/convert.c @@ -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); diff --git a/MagickWand/magick-cli.c b/MagickWand/magick-cli.c index 8177aa03f..33ad1c7ad 100644 --- a/MagickWand/magick-cli.c +++ b/MagickWand/magick-cli.c @@ -69,11 +69,16 @@ \ 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); } @@ -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); diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index af648f7b7..5524af2f0 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -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) diff --git a/MagickWand/montage.c b/MagickWand/montage.c index 7631d712e..9c8a91063 100644 --- a/MagickWand/montage.c +++ b/MagickWand/montage.c @@ -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); diff --git a/MagickWand/operation.c b/MagickWand/operation.c index 840c6f922..3f33f0bf6 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -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 } diff --git a/config/english.xml b/config/english.xml index 6870fda79..79aab307d 100644 --- a/config/english.xml +++ b/config/english.xml @@ -488,8 +488,8 @@ image depth not supported - - image sequence is required + + image list is required image size differs @@ -611,7 +611,16 @@ geometry does not contain image - invalif use of option + invalid use of option + + + invalid argument for option + + + invalid geometry + + + invalid image index images are not the same size @@ -622,12 +631,6 @@ image widths or heights differ - - invalid argument for option - - - invalid geometry - kernel width must be an odd number @@ -662,11 +665,11 @@ no clip path defined - - no images defined for operation + + no images for write - - no images for final write + + no images found for operation no image vector graphics @@ -701,6 +704,9 @@ subimage specification returns no images + + two or more images required + unable to open file @@ -710,6 +716,9 @@ unable to parse kernel string + + unbalanced braces + unbalanced parenthesis diff --git a/config/francais.xml b/config/francais.xml index bfc868055..1d338deae 100644 --- a/config/francais.xml +++ b/config/francais.xml @@ -495,8 +495,8 @@ profondeur d'image non supportée - - une séquence d'images est requise + + une liste d'images est requise différences dans la taille de l'image @@ -607,6 +607,15 @@ Invalide utilisation de l'option + + argument invalide pour l'option + + + géométrie invalide + + + index de l'image non valide + images diffèrent par la taille @@ -616,12 +625,6 @@ différences dans la hauteur ou la largeur de l'image - - argument invalide pour l'option - - - géométrie invalide - la largeur du grain doit être un nombre impair @@ -656,11 +659,11 @@ pas de chemin de coupe défini - - pas d'images définies pour un fonctionnement + + pas d'images pour écriture - - pas d'images pour écriture finales + + pas d'image pour un fonctionnement pas de graphiques vectoriels @@ -695,6 +698,9 @@ la spécification de sous-image ne permet pas de fournir des images + + deux ou plusieurs images nécessaires + impossible d'ouvrir le fichier @@ -704,6 +710,9 @@ impossible d'analyser l'kernel string + + brace non fermée + parenthèse non fermée -- 2.40.0