Changeset 7954
- Timestamp:
- 05/17/12 19:39:46 (12 months ago)
- Location:
- ImageMagick/trunk
- Files:
-
- 1 added
- 8 edited
-
MagickCore/option.c (modified) (6 diffs)
-
MagickCore/option.h (modified) (2 diffs)
-
MagickCore/property.c (modified) (1 diff)
-
MagickWand/magick-cli.c (modified) (10 diffs)
-
MagickWand/operation.c (modified) (27 diffs)
-
MagickWand/tests/README (added)
-
MagickWand/wandcli-private.h (modified) (2 diffs)
-
config/english.xml (modified) (2 diffs)
-
config/francais.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ImageMagick/trunk/MagickCore/option.c
r7924 r7954 200 200 { "-alpha", 1L, SimpleOperatorFlag, MagickFalse }, 201 201 { "+annotate", 0L, DeprecateOptionFlag, MagickTrue }, 202 { "-annotate", 2L, SimpleOperatorFlag , MagickFalse },202 { "-annotate", 2L, SimpleOperatorFlag | AlwaysInterpretArgsFlag, MagickFalse }, 203 203 { "+antialias", 0L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse }, 204 204 { "-antialias", 0L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse }, … … 340 340 { "+dissimilarity-threshold", 0L, NonMagickOptionFlag | ImageInfoOptionFlag, MagickFalse }, 341 341 { "-dissimilarity-threshold", 1L, NonMagickOptionFlag | ImageInfoOptionFlag, MagickFalse }, 342 { "+distort", 2L, SimpleOperatorFlag , MagickFalse },343 { "-distort", 2L, SimpleOperatorFlag , MagickFalse },342 { "+distort", 2L, SimpleOperatorFlag | AlwaysInterpretArgsFlag, MagickFalse }, 343 { "-distort", 2L, SimpleOperatorFlag | AlwaysInterpretArgsFlag, MagickFalse }, 344 344 { "+dither", 0L, ImageInfoOptionFlag | QuantizeInfoOptionFlag, MagickFalse }, 345 345 { "-dither", 1L, ImageInfoOptionFlag | QuantizeInfoOptionFlag, MagickFalse }, … … 400 400 { "-frame", 1L, SimpleOperatorFlag, MagickFalse }, 401 401 { "+function", 2L, DeprecateOptionFlag, MagickTrue }, 402 { "-function", 2L,SimpleOperatorFlag , MagickFalse },402 { "-function", 2L,SimpleOperatorFlag | AlwaysInterpretArgsFlag, MagickFalse }, 403 403 { "+fuzz", 0L, ImageInfoOptionFlag, MagickFalse }, 404 404 { "-fuzz", 1L, ImageInfoOptionFlag, MagickFalse }, … … 543 543 { "-preview", 1L, GlobalOptionFlag, MagickFalse }, 544 544 { "+print", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, 545 { "-print", 1L, ListOperatorFlag | FireOptionFlag, MagickFalse },545 { "-print", 1L, ListOperatorFlag | AlwaysInterpretArgsFlag | FireOptionFlag, MagickFalse }, 546 546 { "+process", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue }, 547 547 { "-process", 1L, ListOperatorFlag | FireOptionFlag, MagickFalse }, … … 618 618 { "+sepia-tone", 1L, DeprecateOptionFlag, MagickTrue }, 619 619 { "-sepia-tone", 1L, SimpleOperatorFlag, MagickFalse }, 620 { "+set", 1L, SimpleOperatorFlag , MagickFalse },621 { "-set", 2L, SimpleOperatorFlag , MagickFalse },620 { "+set", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse }, 621 { "-set", 2L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse }, 622 622 { "+shade", 0L, DeprecateOptionFlag, MagickTrue }, 623 623 { "-shade", 1L, SimpleOperatorFlag, MagickFalse }, … … 647 647 { "-solarize", 1L, SimpleOperatorFlag, MagickFalse }, 648 648 { "+sparse-color", 1L, DeprecateOptionFlag, MagickTrue }, 649 { "-sparse-color", 2L, SimpleOperatorFlag , MagickFalse },649 { "-sparse-color", 2L, SimpleOperatorFlag | AlwaysInterpretArgsFlag, MagickFalse }, 650 650 { "+splice", 1L, DeprecateOptionFlag, MagickTrue }, 651 651 { "-splice", 1L, SimpleOperatorFlag, MagickFalse }, -
ImageMagick/trunk/MagickCore/option.h
r7587 r7954 126 126 QuantizeInfoOptionFlag = 0x0004, /* Setting stored in QuantizeInfo */ 127 127 GlobalOptionFlag = 0x0008, /* Global Setting or Control */ 128 SettingOptionFlags = 0x000F, /* mask for all setting options*/128 SettingOptionFlags = 0x000F, /* mask any setting option */ 129 129 130 130 NoImageOperatorFlag = 0x0010, /* Images not required operator */ … … 135 135 SpecialOptionFlag = 0x0100, /* Operator with Special Requirements */ 136 136 /* EG: for specific CLI commands */ 137 138 AlwaysInterpretArgsFlag = 0x0400, /* Always Interpret escapes in Args */ 139 NeverInterpretArgsFlag = 0x0800, /* Never Interpret escapes in Args */ 137 140 138 141 NonMagickOptionFlag = 0x1000, /* Option not used by Magick Command */ -
ImageMagick/trunk/MagickCore/property.c
r7928 r7954 2956 2956 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 2957 2957 2958 if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))2958 if ((embed_text == (const char *) NULL)) 2959 2959 return((char *) NULL); 2960 2960 p=embed_text; 2961 2962 if (*p == '\0') 2963 return(ConstantString("")); 2961 2964 2962 2965 /* handle a '@' replace string from file */ -
ImageMagick/trunk/MagickWand/magick-cli.c
r7883 r7954 65 65 #define MagickCommandDebug 0 66 66 67 68 67 #if MagickCommandDebug >= 9 69 68 /* … … 78 77 *value; 79 78 80 (void) FormatLocaleFile(std out," Global Options:\n");79 (void) FormatLocaleFile(stderr," Global Options:\n"); 81 80 ResetImageOptionIterator(image_info); 82 81 while ((option=GetNextImageOption(image_info)) != (const char *) NULL ) { 83 (void) FormatLocaleFile(std out," %s: ",option);82 (void) FormatLocaleFile(stderr," %s: ",option); 84 83 value=GetImageOption(image_info,option); 85 84 if (value != (const char *) NULL) 86 (void) FormatLocaleFile(std out,"%s\n",value);85 (void) FormatLocaleFile(stderr,"%s\n",value); 87 86 } 88 87 ResetImageOptionIterator(image_info); … … 95 94 *value; 96 95 97 (void) FormatLocaleFile(std out," Image Artifacts:\n");96 (void) FormatLocaleFile(stderr," Image Artifacts:\n"); 98 97 ResetImageArtifactIterator(image); 99 98 while ((artifact=GetNextImageArtifact(image)) != (const char *) NULL ) { 100 (void) FormatLocaleFile(std out," %s: ",artifact);99 (void) FormatLocaleFile(stderr," %s: ",artifact); 101 100 value=GetImageArtifact(image,artifact); 102 101 if (value != (const char *) NULL) 103 (void) FormatLocaleFile(std out,"%s\n",value);102 (void) FormatLocaleFile(stderr,"%s\n",value); 104 103 } 105 104 ResetImageArtifactIterator(image); … … 112 111 *value; 113 112 114 (void) FormatLocaleFile(std out," Image Properity:\n");113 (void) FormatLocaleFile(stderr," Image Properity:\n"); 115 114 ResetImagePropertyIterator(image); 116 115 while ((property=GetNextImageProperty(image)) != (const char *) NULL ) { 117 (void) FormatLocaleFile(std out," %s: ",property);116 (void) FormatLocaleFile(stderr," %s: ",property); 118 117 value=GetImageProperty(image,property,exception); 119 118 if (value != (const char *) NULL) 120 (void) FormatLocaleFile(std out,"%s\n",value);119 (void) FormatLocaleFile(stderr,"%s\n",value); 121 120 } 122 121 ResetImagePropertyIterator(image); … … 217 216 } 218 217 219 /* save option details */ 220 CloneString(&option,token_info->token); 221 222 /* get option, its argument count, and option type */ 223 cli_wand->command = GetCommandOptionInfo(option); 224 count=cli_wand->command->type; 225 option_type=(CommandOptionFlags) cli_wand->command->flags; 218 do { /* use break to loop to exception handler and loop */ 219 220 /* save option details */ 221 CloneString(&option,token_info->token); 222 223 /* get option, its argument count, and option type */ 224 cli_wand->command = GetCommandOptionInfo(option); 225 count=cli_wand->command->type; 226 option_type=(CommandOptionFlags) cli_wand->command->flags; 226 227 #if 0 227 (void) FormatLocaleFile(stderr, "Script: %u,%u: \"%s\" matched \"%s\"\n",228 (void) FormatLocaleFile(stderr, "Script: %u,%u: \"%s\" matched \"%s\"\n", 228 229 cli_wand->line, cli_wand->line, option, cli_wand->command->mnemonic ); 229 230 #endif 230 231 231 /* handle a undefined option - image read?*/232 if ( option_type == UndefinedOptionFlag ||233 (option_type & NonMagickOptionFlag) != 0 ) {232 /* handle a undefined option - image read - always for "magick-script" */ 233 if ( option_type == UndefinedOptionFlag || 234 (option_type & NonMagickOptionFlag) != 0 ) { 234 235 #if MagickCommandDebug >= 3 235 (void) FormatLocaleFile(stderr, "Script %u,%u Non-Option: \"%s\"\n", 236 cli_wand->line, cli_wand->line, option); 237 #endif 238 if ( IfMagickFalse(IsCommandOption(option))) { 239 /* non-option -- treat as a image read */ 240 cli_wand->command=(const OptionInfo *)NULL; 241 CLIOption(cli_wand,"-read",option); 242 goto next_token; 243 } 244 CLIWandExceptionBreak(OptionFatalError,"UnrecognizedOption",option); 245 goto next_token; 246 } 247 248 if ( count >= 1 ) { 249 if( IfMagickFalse(GetScriptToken(token_info)) ) 250 CLIWandException(OptionFatalError,"MissingArgument",option); 251 CloneString(&arg1,token_info->token); 252 } 253 else 254 CloneString(&arg1,(char *)NULL); 255 256 if ( count >= 2 ) { 257 if( IfMagickFalse(GetScriptToken(token_info)) ) 258 CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option); 259 CloneString(&arg2,token_info->token); 260 } 261 else 262 CloneString(&arg2,(char *)NULL); 263 264 265 /* 266 Process Options 267 */ 236 (void) FormatLocaleFile(stderr, "Script %u,%u Non-Option: \"%s\"\n", 237 cli_wand->line, cli_wand->line, option); 238 #endif 239 if ( IfMagickFalse(IsCommandOption(option))) { 240 /* non-option -- treat as a image read */ 241 cli_wand->command=(const OptionInfo *)NULL; 242 CLIOption(cli_wand,"-read",option); 243 break; /* next option */ 244 } 245 CLIWandException(OptionFatalError,"UnrecognizedOption",option); 246 break; /* next option */ 247 } 248 249 if ( count >= 1 ) { 250 if( IfMagickFalse(GetScriptToken(token_info)) ) 251 CLIWandException(OptionFatalError,"MissingArgument",option); 252 CloneString(&arg1,token_info->token); 253 } 254 else 255 CloneString(&arg1,(char *)NULL); 256 257 if ( count >= 2 ) { 258 if( IfMagickFalse(GetScriptToken(token_info)) ) 259 CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option); 260 CloneString(&arg2,token_info->token); 261 } 262 else 263 CloneString(&arg2,(char *)NULL); 264 265 /* 266 Process Options 267 */ 268 268 #if MagickCommandDebug >= 3 269 (void) FormatLocaleFile(stderr,270 "Script %u,%u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n",271 cli_wand->line,cli_wand->line,option,count,option_type,arg1,arg2);272 #endif 273 /* Hard Depreciated Options, no code to execute - error */274 if ( (option_type & DeprecateOptionFlag) != 0 ) {275 CLIWandException(OptionError,"DeprecatedOptionNoCode",option);276 if ( IfMagickTrue(CLICatchException(cli_wand, MagickFalse)) )277 break;278 goto next_token; 279 }280 281 /* MagickCommandGenesis() options have no place in a magick script */282 if ( (option_type & GenesisOptionFlag) != 0 ) {283 CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option);284 goto next_token; 285 }286 287 if ( (option_type & SpecialOptionFlag) != 0 ) {288 if ( LocaleCompare(option,"-exit") == 0 ) {289 break; /* forced end of script */290 }291 if ( LocaleCompare(option,"-script") == 0 ) {292 /* FUTURE: call new script from this script */293 CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option);294 goto next_token;295 }296 /* FUTURE: handle special script-argument options here*/297 /* handle any other special operators now */298 CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option);299 goto next_token;300 } 301 302 /* Process non-specific Option */303 CLIOption(cli_wand, option, arg1, arg2); 304 305 next_token: 269 (void) FormatLocaleFile(stderr, 270 "Script %u,%u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", 271 cli_wand->line,cli_wand->line,option,count,option_type,arg1,arg2); 272 #endif 273 /* Hard Depreciated Options, no code to execute - error */ 274 if ( (option_type & DeprecateOptionFlag) != 0 ) { 275 CLIWandException(OptionError,"DeprecatedOptionNoCode",option); 276 break; /* next option */ 277 } 278 279 /* MagickCommandGenesis() options have no place in a magick script */ 280 if ( (option_type & GenesisOptionFlag) != 0 ) { 281 CLIWandException(OptionError,"InvalidUseOfOption",option); 282 break; /* next option */ 283 } 284 285 /* handle any special 'script' options */ 286 if ( (option_type & SpecialOptionFlag) != 0 ) { 287 if ( LocaleCompare(option,"-exit") == 0 ) { 288 break; /* forced end of script */ 289 } 290 if ( LocaleCompare(option,"-script") == 0 ) { 291 /* FUTURE: call new script from this script - error for now */ 292 CLIWandException(OptionError,"InvalidUseOfOption",option); 293 break; /* next option */ 294 } 295 /* FUTURE: handle special script-argument options here */ 296 /* handle any other special operators now */ 297 CLIWandException(OptionError,"InvalidUseOfOption",option); 298 break; /* next option */ 299 } 300 301 /* Process non-specific Option */ 302 CLIOption(cli_wand, option, arg1, arg2); 303 304 } while (0); /* break block to next option */ 305 306 306 #if MagickCommandDebug >= 9 307 307 OutputOptions(cli_wand->wand.image_info); … … 311 311 } 312 312 #endif 313 if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) 314 break; 315 } 316 313 if ( IfMagickTrue(CLICatchException(cli_wand, MagickFalse)) ) 314 break; /* exit loop */ 315 } 316 317 /* 318 Loop exit - check for some tokenization error 319 */ 317 320 #if MagickCommandDebug >= 3 318 321 (void) FormatLocaleFile(stderr, "Script End: %d\n", token_info->status); … … 429 432 430 433 end = argc; 431 if ( (cli_wand->process_flags & ProcessImpli edWrite) != 0 )434 if ( (cli_wand->process_flags & ProcessImplictWrite) != 0 ) 432 435 end--; /* the last arument is an implied write, do not process directly */ 433 436 … … 437 440 return(i); 438 441 439 option=argv[i]; 440 cli_wand->line=i; /* note the argument for this option */ 441 442 /* get option, its argument count, and option type */ 443 cli_wand->command = GetCommandOptionInfo(argv[i]); 444 count=cli_wand->command->type; 445 option_type=(CommandOptionFlags) cli_wand->command->flags; 442 do { /* use break to loop to exception handler and loop */ 443 444 option=argv[i]; 445 cli_wand->line=i; /* note the argument for this option */ 446 447 /* get option, its argument count, and option type */ 448 cli_wand->command = GetCommandOptionInfo(argv[i]); 449 count=cli_wand->command->type; 450 option_type=(CommandOptionFlags) cli_wand->command->flags; 446 451 #if 0 447 (void) FormatLocaleFile(stderr, "CLI %d: \"%s\" matched \"%s\"\n",448 i, argv[i], cli_wand->command->mnemonic );449 #endif 450 451 if ( option_type == UndefinedOptionFlag ||452 (option_type & NonMagickOptionFlag) != 0 ) {452 (void) FormatLocaleFile(stderr, "CLI %d: \"%s\" matched \"%s\"\n", 453 i, argv[i], cli_wand->command->mnemonic ); 454 #endif 455 456 if ( option_type == UndefinedOptionFlag || 457 (option_type & NonMagickOptionFlag) != 0 ) { 453 458 #if MagickCommandDebug >= 3 454 (void) FormatLocaleFile(stderr, "CLI %d Non-Option: \"%s\"\n", i, option); 455 #endif 456 if ( IfMagickFalse(IsCommandOption(option)) ) { 457 if ( (cli_wand->process_flags & ProcessNonOptionImageRead) != 0 ) { 458 /* non-option -- treat as a image read */ 459 cli_wand->command=(const OptionInfo *)NULL; 460 CLIOption(cli_wand,"-read",option); 461 goto next_argument; 459 (void) FormatLocaleFile(stderr, "CLI %d Non-Option: \"%s\"\n", i, option); 460 #endif 461 if ( IfMagickFalse(IsCommandOption(option)) ) { 462 if ( (cli_wand->process_flags & ProcessImplictRead) != 0 ) { 463 /* non-option -- treat as a image read */ 464 cli_wand->command=(const OptionInfo *)NULL; 465 CLIOption(cli_wand,"-read",option); 466 break; /* next option */ 467 } 462 468 } 463 } 464 CLIWandException(OptionFatalError,"UnrecognizedOption",option); 465 goto next_argument; 466 } 467 468 if ( ((option_type & SpecialOptionFlag) != 0 ) && 469 ((cli_wand->process_flags & ProcessScriptOption) != 0) && 470 (LocaleCompare(option,"-script") == 0) ) { 471 /* Call Script from CLI, with a filename as a zeroth argument. 472 NOTE: -script may need to use the 'implict write filename' argument 473 so it must be handled specially to prevent a 'missing argument' error. 469 CLIWandException(OptionFatalError,"UnrecognizedOption",option); 470 break; /* next option */ 471 } 472 473 if ( ((option_type & SpecialOptionFlag) != 0 ) && 474 ((cli_wand->process_flags & ProcessScriptOption) != 0) && 475 (LocaleCompare(option,"-script") == 0) ) { 476 /* Call Script from CLI, with a filename as a zeroth argument. 477 NOTE: -script may need to use the 'implict write filename' argument 478 so it must be handled specially to prevent a 'missing argument' error. 479 */ 480 if ( (i+count) >= argc ) 481 CLIWandException(OptionFatalError,"MissingArgument",option); 482 ProcessScriptOptions(cli_wand,argc,argv,i+1); 483 return(argc); /* Script does not return to CLI -- Yet */ 484 /* FUTURE: when it does, their may be no write arg! */ 485 } 486 487 if ((i+count) >= end ) { 488 CLIWandException(OptionFatalError,"MissingArgument",option); 489 if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) 490 return(end); 491 break; /* next option - not that their is any! */ 492 } 493 494 arg1 = ( count >= 1 ) ? argv[i+1] : (char *)NULL; 495 arg2 = ( count >= 2 ) ? argv[i+2] : (char *)NULL; 496 497 /* 498 Process Known Options 474 499 */ 475 if ( (i+count) >= argc )476 CLIWandException(OptionFatalError,"MissingArgument",option);477 ProcessScriptOptions(cli_wand,argc,argv,i+1);478 return(argc); /* Script does not return to CLI -- Yet */479 /* FUTURE: when it does, their may be no write arg! */480 }481 482 if ((i+count) >= end ) {483 CLIWandException(OptionFatalError,"MissingArgument",option);484 if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )485 return(end);486 goto next_argument; /* no more arguments unable to proceed */487 }488 489 arg1 = ( count >= 1 ) ? argv[i+1] : (char *)NULL;490 arg2 = ( count >= 2 ) ? argv[i+2] : (char *)NULL;491 492 /*493 Process Known Options494 */495 500 #if MagickCommandDebug >= 3 496 (void) FormatLocaleFile(stderr, 497 "CLI %u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", 498 i,option,count,option_type,arg1,arg2); 499 #endif 500 501 if ( (option_type & GenesisOptionFlag) != 0 ) 502 goto next_argument; /* ignored this from command line args */ 503 504 if ( (option_type & SpecialOptionFlag) != 0 ) { 505 if ( (cli_wand->process_flags & ProcessExitOption) != 0 506 && LocaleCompare(option,"-exit") == 0 ) 507 return(i+count); 508 goto next_argument; 509 } 510 511 /* Process a Normal Option */ 512 CLIOption(cli_wand, option, arg1, arg2); 513 514 next_argument: 501 (void) FormatLocaleFile(stderr, 502 "CLI %u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", 503 i,option,count,option_type,arg1,arg2); 504 #endif 505 506 /* ignore 'genesis options' in command line args */ 507 if ( (option_type & GenesisOptionFlag) != 0 ) 508 break; /* next option */ 509 510 /* Handle any special options for CLI (-script handled above) */ 511 if ( (option_type & SpecialOptionFlag) != 0 ) { 512 if ( (cli_wand->process_flags & ProcessExitOption) != 0 513 && LocaleCompare(option,"-exit") == 0 ) 514 return(i+count); 515 break; /* next option */ 516 } 517 518 /* Process standard image option */ 519 CLIOption(cli_wand, option, arg1, arg2); 520 521 } while (0); /* break block to next option */ 522 515 523 #if MagickCommandDebug >= 9 516 524 OutputOptions(cli_wand->wand.image_info); … … 525 533 assert(i==end); 526 534 527 if ( (cli_wand->process_flags & ProcessImpli edWrite) == 0 )535 if ( (cli_wand->process_flags & ProcessImplictWrite) == 0 ) 528 536 return(end); /* no implied write -- just return to caller */ 529 537 … … 536 544 cli_wand->line=i; 537 545 546 /* check that stacks are empty - or cause exception */ 547 if (cli_wand->image_list_stack != (Stack *)NULL) 548 CLIWandException(OptionError,"UnbalancedParenthesis", "(end of cli)"); 549 else if (cli_wand->image_info_stack != (Stack *)NULL) 550 CLIWandException(OptionError,"UnbalancedBraces", "(end of cli)"); 551 if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) 552 return(argc); 553 538 554 #if MagickCommandDebug >= 3 539 555 (void) FormatLocaleFile(stderr, "CLI %d Write File: \"%s\"\n", i, option ); 540 556 #endif 541 557 542 /* check that stacks are empty */ 543 if (cli_wand->image_list_stack != (Stack *)NULL) 544 CLIWandException(OptionError,"UnbalancedParenthesis", "(eof)"); 545 else if (cli_wand->image_info_stack != (Stack *)NULL) 546 CLIWandException(OptionError,"UnbalancedBraces", "(eof)"); 547 if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) 548 return(argc); 549 550 /* This is a valid 'do no write' option - no images needed */ 558 /* Valid 'do no write' replacement option (instead of "null:") */ 551 559 if (LocaleCompare(option,"-exit") == 0 ) 552 560 return(argc); /* just exit, no image write */ -
ImageMagick/trunk/MagickWand/operation.c
r7945 r7954 1601 1601 */ 1602 1602 static void CLISimpleOperatorImage(MagickCLI *cli_wand, 1603 const char *option, const char *arg1 , const char *arg2)1603 const char *option, const char *arg1n, const char *arg2n) 1604 1604 { 1605 1605 Image * … … 1617 1617 ssize_t 1618 1618 parse; 1619 1620 const char /* For percent escape interpretImageProperties() */ 1621 *arg1, 1622 *arg2; 1619 1623 1620 1624 #define _image_info (cli_wand->wand.image_info) … … 1623 1627 #define _draw_info (cli_wand->draw_info) 1624 1628 #define _quantize_info (cli_wand->quantize_info) 1629 #define _process_flags (cli_wand->process_flags) 1630 #define _option_type ((CommandOptionFlags) cli_wand->command->flags) 1625 1631 #define IfNormalOp (*option=='-') 1626 1632 #define IfPlusOp (*option!='-') … … 1635 1641 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); 1636 1642 1643 /* Interpret Percent Escapes in Arguments - using first image */ 1644 arg1 = arg1n, 1645 arg2 = arg2n; 1646 if ( (((_process_flags & ProcessInterpretProperities) != 0 ) 1647 || ((_option_type & AlwaysInterpretArgsFlag) != 0) 1648 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { 1649 /* Interpret Percent escapes in argument 1 */ 1650 if (arg1n != (char *) NULL) { 1651 arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); 1652 if (arg1 == (char *) NULL) { 1653 CLIWandException(OptionWarning,"InterpretPropertyFailure",option); 1654 arg1=arg1n; /* use the given argument as is */ 1655 } 1656 } 1657 if (arg2n != (char *) NULL) { 1658 arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); 1659 if (arg2 == (char *) NULL) { 1660 CLIWandException(OptionWarning,"InterpretPropertyFailure",option); 1661 arg2=arg2n; /* use the given argument as is */ 1662 } 1663 } 1664 } 1665 #undef _option_type 1666 1667 #if 0 1668 (void) FormatLocaleFile(stderr, 1669 "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); 1670 #endif 1671 1672 new_image = (Image *)NULL; /* the replacement image, if not null at end */ 1637 1673 SetGeometryInfo(&geometry_info); 1638 1674 1639 new_image = (Image *)NULL; /* the replacement image, if not null at end */1640 1641 /* FUTURE: We may need somthing a little more optimized than this!1642 Perhaps, do the 'sync' if 'settings tainted' before next operator.1643 */1644 1675 switch (*(option+1)) 1645 1676 { … … 1691 1722 { 1692 1723 char 1693 *text,1694 1724 geometry[MaxTextExtent]; 1695 1725 … … 1700 1730 if ((flags & SigmaValue) == 0) 1701 1731 geometry_info.sigma=geometry_info.rho; 1702 text=InterpretImageProperties(_image_info,_image,arg2, 1703 _exception); 1704 if (text == (char *) NULL) 1705 break; 1706 (void) CloneString(&_draw_info->text,text); 1707 text=DestroyString(text); 1732 (void) CloneString(&_draw_info->text,arg2); 1708 1733 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", 1709 1734 geometry_info.xi,geometry_info.psi); … … 2134 2159 if (LocaleCompare("distort",option+1) == 0) 2135 2160 { 2136 char2137 *arg;2138 2139 2161 double 2140 2162 *args; … … 2165 2187 break; 2166 2188 } 2167 /* allow percent escapes in argument string */2168 arg=InterpretImageProperties(_image_info,_image,arg2,_exception);2169 if (arg == (char *) NULL)2170 break;2171 2189 /* convert argument string into an array of doubles */ 2172 args = StringToArrayOfDoubles(arg,&count,_exception); 2173 arg=DestroyString(arg); 2190 args = StringToArrayOfDoubles(arg2,&count,_exception); 2174 2191 if (args == (double *)NULL ) 2175 2192 CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); … … 2338 2355 if (LocaleCompare("function",option+1) == 0) 2339 2356 { 2340 char2341 *arg;2342 2343 2357 double 2344 2358 *args; … … 2351 2365 CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction", 2352 2366 option,arg1); 2353 /* allow percent escapes in argument string */2354 arg=InterpretImageProperties(_image_info,_image,arg2,_exception);2355 if (arg == (char *) NULL)2356 break;2357 2367 /* convert argument string into an array of doubles */ 2358 args = StringToArrayOfDoubles(arg,&count,_exception); 2359 arg=DestroyString(arg); 2368 args = StringToArrayOfDoubles(arg2,&count,_exception); 2360 2369 if (args == (double *)NULL ) 2361 2370 CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2); … … 2432 2441 2433 2442 format=GetImageOption(_image_info,"format"); 2434 if (format == (char *) NULL) 2435 { 2436 (void) IdentifyImage(_image,stdout,_image_info->verbose, 2437 _exception); 2438 break; 2439 } 2443 if (format == (char *) NULL) { 2444 (void) IdentifyImage(_image,stdout,_image_info->verbose,_exception); 2445 break; 2446 } 2440 2447 text=InterpretImageProperties(_image_info,_image,format,_exception); 2441 2448 if (text == (char *) NULL) 2442 break; 2449 CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", 2450 option); 2443 2451 (void) fputs(text,stdout); 2444 2452 (void) fputc('\n',stdout); … … 3071 3079 value=InterpretImageProperties(_image_info,_image,arg2,_exception); 3072 3080 if (value == (char *) NULL) 3073 break; 3081 CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", 3082 option); 3074 3083 if (LocaleNCompare(arg1,"registry:",9) == 0) 3075 3084 (void) SetImageRegistry(StringRegistryType,arg1+9,value,_exception); … … 3177 3186 if (LocaleCompare("sparse-color",option+1) == 0) 3178 3187 { 3179 char3180 *arguments;3181 3182 3188 parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1); 3183 3189 if ( parse < 0 ) 3184 3190 CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod", 3185 3191 option,arg1); 3186 arguments=InterpretImageProperties(_image_info,_image,arg2,_exception); 3187 if (arguments == (char *) NULL) 3188 CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2); 3189 new_image=SparseColorOption(_image,(SparseColorMethod)parse, 3190 arguments,_exception); 3191 arguments=DestroyString(arguments); 3192 new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2, 3193 _exception); 3192 3194 break; 3193 3195 } … … 3405 3407 CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); 3406 3408 } 3407 /* 3408 Replace current image with any image that was generated 3409 and set image point to last image (so image->next is correct) 3410 */ 3409 /* clean up percent escape interpreted strings */ 3410 if (arg1 != arg1n ) 3411 arg1=DestroyString((char *)arg1); 3412 if (arg2 != arg2n ) 3413 arg2=DestroyString((char *)arg2); 3414 3415 /* Replace current image with any image that was generated 3416 and set image point to last image (so image->next is correct) */ 3411 3417 if (new_image != (Image *) NULL) 3412 3418 ReplaceImageInListReturnLast(&_image,new_image); … … 3492 3498 */ 3493 3499 WandExport void CLIListOperatorImages(MagickCLI *cli_wand, 3494 const char *option,const char *arg1 , const char *magick_unused(arg2))3500 const char *option,const char *arg1n, const char *arg2n) 3495 3501 { 3496 3502 ssize_t … … 3499 3505 Image 3500 3506 *new_images; 3507 3508 const char /* For percent escape interpretImageProperties() */ 3509 *arg1, 3510 *arg2; 3501 3511 3502 3512 #define _image_info (cli_wand->wand.image_info) … … 3505 3515 #define _draw_info (cli_wand->draw_info) 3506 3516 #define _quantize_info (cli_wand->quantize_info) 3517 #define _process_flags (cli_wand->process_flags) 3518 #define _option_type ((CommandOptionFlags) cli_wand->command->flags) 3507 3519 #define IfNormalOp (*option=='-') 3508 3520 #define IfPlusOp (*option!='-') … … 3515 3527 if (IfMagickTrue(cli_wand->wand.debug)) 3516 3528 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); 3529 3530 /* Interpret Percent Escapes in Arguments - using first image */ 3531 arg1 = arg1n; 3532 arg2 = arg2n; 3533 if ( (((_process_flags & ProcessInterpretProperities) != 0 ) 3534 || ((_option_type & AlwaysInterpretArgsFlag) != 0) 3535 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { 3536 /* Interpret Percent escapes in argument 1 */ 3537 if (arg1n != (char *) NULL) { 3538 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); 3539 if (arg1 == (char *) NULL) { 3540 CLIWandException(OptionWarning,"InterpretPropertyFailure",option); 3541 arg1=arg1n; /* use the given argument as is */ 3542 } 3543 } 3544 if (arg2n != (char *) NULL) { 3545 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); 3546 if (arg2 == (char *) NULL) { 3547 CLIWandException(OptionWarning,"InterpretPropertyFailure",option); 3548 arg2=arg2n; /* use the given argument as is */ 3549 } 3550 } 3551 } 3552 #undef _option_type 3553 3554 #if 0 3555 (void) FormatLocaleFile(stderr, 3556 "CLIListOperatorImages: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2); 3557 #endif 3558 3517 3559 3518 3560 new_images=NewImageList(); … … 3982 4024 if (LocaleCompare("print",option+1) == 0) 3983 4025 { 3984 char 3985 *string; 3986 3987 string=InterpretImageProperties(_image_info,_images,arg1,_exception); 3988 if (string == (char *) NULL) 3989 break; 3990 (void) FormatLocaleFile(stdout,"%s",string); 3991 string=DestroyString(string); 4026 (void) FormatLocaleFile(stdout,"%s",arg1); 3992 4027 break; 3993 4028 } … … 4193 4228 CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); 4194 4229 } 4230 4231 /* clean up percent escape interpreted strings */ 4232 if (arg1 != arg1n ) 4233 arg1=DestroyString((char *)arg1); 4234 if (arg2 != arg2n ) 4235 arg2=DestroyString((char *)arg2); 4236 4237 /* if new image list generated, replace existing image list */ 4195 4238 if (new_images == (Image *) NULL) 4196 4239 return; 4197 4198 if (_images != (Image *) NULL) 4199 _images=DestroyImageList(_images); 4240 _images=DestroyImageList(_images); 4200 4241 _images=GetFirstImageInList(new_images); 4201 4242 return; … … 4216 4257 % % 4217 4258 % % 4218 + C L I S p e c i a lO p e r a t i o n s %4259 + C L I N o I m a g e O p e r a t i o n s % 4219 4260 % % 4220 4261 % % … … 4223 4264 % 4224 4265 % CLINoImageOperator() Applies operations that may not actually need images 4225 % in an image list wen it is applied.4266 % in an image list. 4226 4267 % 4227 4268 % The classic operators of this type is -read, which actually creates images 4228 4269 % even when no images are present. Or image stack operators, which can be 4229 % applied to empty image lists.4270 % applied (push or pop) to an empty image list. 4230 4271 % 4231 4272 % Note: unlike other Operators, these may involve other special 'option' 4232 % character prefixes, other than simply '-' or '+'.4273 % characters other than '-' or '+', namely parenthesis and braces. 4233 4274 % 4234 4275 % The format of the CLINoImageOption method is: … … 4331 4372 new_images; 4332 4373 #if 0 4333 fprintf(stderr, "DEBUG: Reading image: \"%s\"\n", argv[i]);4374 fprintf(stderr, "DEBUG: Reading image: \"%s\"\n", argv[i]); 4334 4375 #endif 4335 4376 if (IfMagickTrue(_image_info->ping)) … … 4614 4655 % % 4615 4656 % % 4616 + C L I O p t i o n O p e r a t i o n s%4657 + C L I O p t i o n % 4617 4658 % % 4618 4659 % % … … 4621 4662 % 4622 4663 % CLIOption() Processes the given option using the given CLI Magick Wand. 4664 % The option arguments can be variable in number, though at this time no more 4665 % that two is actually used by any option (this may change). Excess options 4666 % are simply ignored. 4623 4667 % 4624 4668 % If the cli_wand->command pointer is non-null, then it is assumed that the 4625 4669 % option has already been search for up from the CommandOptions[] table in 4626 % "MagickCore/options.c" using GetCommandOptionInfo(), so that any command 4627 % specific options (such as "magick" scripting options, or "display" settings) 4628 % can be handled separatally. 4670 % "MagickCore/options.c" using GetCommandOptionInfo(). If not set this 4671 % routine will do the lookup instead. The pointer is reset afterward. 4672 % 4673 % This action allows the caller to lookup and pre-handle any 'special' 4674 % options, (such as implicit reads) before calling this general option 4675 % handler to deal with 'standard' command line options. 4629 4676 % 4630 4677 % The format of the CLIOption method is: … … 4638 4685 % o option: The special option (with any switch char) to process 4639 4686 % 4640 % o args: any required arguments for an option 4687 % o args: any required arguments for an option (variable number) 4641 4688 % 4642 4689 % Example Usage... … … 4663 4710 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); 4664 4711 4665 if ( cli_wand->command == (const OptionInfo *) NULL ) 4666 cli_wand->command = GetCommandOptionInfo(option); 4712 do { /* Break Code Block for error handling */ 4713 4714 /* get information about option */ 4715 if ( cli_wand->command == (const OptionInfo *) NULL ) 4716 cli_wand->command = GetCommandOptionInfo(option); 4667 4717 #if 0 4668 (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n",4669 option, cli_wand->command->mnemonic );4718 (void) FormatLocaleFile(stderr, "CLIOption \"%s\" matched \"%s\"\n", 4719 option, cli_wand->command->mnemonic ); 4670 4720 #endif 4671 4672 option_type=(CommandOptionFlags) cli_wand->command->flags; 4673 4674 if ( option_type == UndefinedOptionFlag ) 4675 CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); 4676 4677 assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); 4678 4679 if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) 4680 CLIWandExceptionReturn(OptionFatalError,"InvalidUseOfOption",option); 4681 4682 if ( (option_type & DeprecateOptionFlag) != 0 ) 4683 CLIWandExceptionReturn(OptionError,"DeprecatedOptionNoCode",option); 4684 4685 if ( IfMagickTrue(CLICatchException(cli_wand, MagickFalse)) ) 4686 return; 4687 4688 4689 { size_t 4690 count = cli_wand->command->type; 4691 4692 va_list 4693 operands; 4694 4695 va_start(operands,option); 4696 4697 arg1=arg2=NULL; 4698 if ( count >= 1 ) 4699 arg1=(const char *) va_arg(operands, const char *); 4700 if ( count >= 2 ) 4701 arg2=(const char *) va_arg(operands, const char *); 4702 4703 va_end(operands); 4721 option_type=(CommandOptionFlags) cli_wand->command->flags; 4722 4723 if ( option_type == UndefinedOptionFlag ) 4724 CLIWandExceptionReturn(OptionFatalError,"UnrecognizedOption",option); 4725 4726 assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); 4727 4728 /* depreciated options */ 4729 if ( (option_type & DeprecateOptionFlag) != 0 ) 4730 CLIWandExceptionBreak(OptionError,"DeprecatedOptionNoCode",option); 4731 4732 /* options that this module does not handle */ 4733 if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) 4734 CLIWandExceptionBreak(OptionFatalError,"InvalidUseOfOption",option); 4735 4736 /* Get argument strings from VarArgs 4737 How can you determine arguments is enough was supplied? */ 4738 { size_t 4739 count = cli_wand->command->type; 4740 4741 va_list 4742 operands; 4743 4744 va_start(operands,option); 4745 4746 arg1=arg2=NULL; 4747 if ( count >= 1 ) 4748 arg1=(const char *) va_arg(operands, const char *); 4749 if ( count >= 2 ) 4750 arg2=(const char *) va_arg(operands, const char *); 4751 4752 va_end(operands); 4704 4753 4705 4754 #if 0 4706 (void) FormatLocaleFile(stderr,4707 "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n",4708 option,(long) count,option_type,arg1,arg2);4755 (void) FormatLocaleFile(stderr, 4756 "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n", 4757 option,(long) count,option_type,arg1,arg2); 4709 4758 #endif 4710 } 4759 } 4760 4761 /* 4762 Call the appropriate option handler 4763 */ 4764 4765 /* FUTURE: this is temporary - get 'settings' to handle distribution of 4766 settings to images attributes,proprieties,artifacts */ 4767 if ( cli_wand->wand.images != (Image *)NULL ) 4768 SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, 4769 cli_wand->wand.exception); 4770 4771 if ( (option_type & SettingOptionFlags) != 0 ) { 4772 CLISettingOptionInfo(cli_wand, option, arg1, arg2); 4773 // FUTURE: Sync Specific Settings into Image Properities (not global) 4774 } 4775 4776 /* Operators that do not need images - read, write, stack, clone */ 4777 if ( (option_type & NoImageOperatorFlag) != 0) 4778 CLINoImageOperator(cli_wand, option, arg1, arg2); 4779 4780 /* FUTURE: The not a setting part below is a temporary hack due to 4781 * some options being both a Setting and a Simple operator. 4782 * Specifically -monitor, -depth, and -colorspace */ 4783 if ( cli_wand->wand.images == (Image *)NULL ) 4784 if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && 4785 ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ 4786 CLIWandExceptionBreak(OptionError,"NoImagesFound",option); 4787 4788 /* Operators work on single images, and needs a loop over the images */ 4789 if ( (option_type & SimpleOperatorFlag) != 0) 4790 CLISimpleOperatorImages(cli_wand, option, arg1, arg2); 4791 4792 /* Operators that work on the image list as a whole */ 4793 if ( (option_type & ListOperatorFlag) != 0 ) 4794 CLIListOperatorImages(cli_wand, option, arg1, arg2); 4795 4796 } while (0); /* end Break code block */ 4711 4797 4712 4798 cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ 4713 4714 4715 /*4716 Call the appropriate option handler4717 */4718 4719 /* FUTURE: this is temporary - get 'settings' to handle4720 distribution of settings to images attributes,proprieties,artifacts */4721 if ( cli_wand->wand.images != (Image *)NULL )4722 SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,4723 cli_wand->wand.exception);4724 4725 if ( (option_type & SettingOptionFlags) != 0 ) {4726 CLISettingOptionInfo(cli_wand, option, arg1, arg2);4727 // FUTURE: Sync Specific Settings into Image Properities (not global)4728 }4729 4730 if ( (option_type & NoImageOperatorFlag) != 0)4731 CLINoImageOperator(cli_wand, option, arg1, arg2);4732 4733 /* FUTURE: The not a setting part below is a temporary hack due to4734 * some options being both a Setting and a Simple operator.4735 * Specifically -monitor, -depth, and -colorspace */4736 if ( cli_wand->wand.images == (Image *)NULL ) {4737 if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) &&4738 ((option_type & SettingOptionFlags) == 0 )) /* temp hack */4739 CLIWandException(OptionError,"NoImagesFound",option);4740 return; /* on its own this is not an error */4741 }4742 4743 if ( (option_type & SimpleOperatorFlag) != 0)4744 CLISimpleOperatorImages(cli_wand, option, arg1, arg2);4745 4746 if ( (option_type & ListOperatorFlag) != 0 )4747 CLIListOperatorImages(cli_wand, option, arg1, arg2);4748 4749 4799 } -
ImageMagick/trunk/MagickWand/wandcli-private.h
r7587 r7954 60 60 typedef enum 61 61 { 62 /* NonOption Handling */63 Process NonOptionImageRead = 0x0001, /* A non-option is a image read62 /* General Option Handling */ 63 ProcessImplictRead = 0x0001, /* Non-options are image reads. 64 64 If not set then skip implied read 65 65 without producing an error. 66 66 For use with "mogrify" handling */ 67 ProcessInterpretProperities = 0x0010, /* allow general escapes in args */ 67 68 68 69 /* Special Option Handling */ … … 74 75 /* Option Processing Flags */ 75 76 ProcessOneOptionOnly = 0x4000, /* Process one option only */ 76 ProcessImpli edWrite = 0x8000, /* Last arg is an impliedwrite */77 ProcessImplictWrite = 0x8000, /* Last arg is an implict write */ 77 78 78 79 /* Flag Groups for specific Situations */ 79 MagickCommandOptionFlags = 0x8F 0F, /* Magick Command Flags */80 MagickCommandOptionFlags = 0x8FFF, /* Magick Command Flags */ 80 81 ConvertCommandOptionFlags = 0x800F, /* Convert Command Flags */ 81 82 MagickScriptArgsFlags = 0x000F, /* Script CLI Process Args Flags */ -
ImageMagick/trunk/config/english.xml
r7899 r7954 614 614 geometry does not contain image 615 615 </message> 616 <message name="InterpretPropertyFailure"> 617 failure in interpret image property escapes 618 </message> 616 619 <message name="InvalidArgument"> 617 620 invalid argument for option … … 942 945 <message name="GeometryDoesNotContainImage"> 943 946 geometry does not contain image 947 </message> 948 <message name="InterpretPropertyFailure"> 949 failure in interpret image property escapes 944 950 </message> 945 951 <message name="InvalidSetting"> -
ImageMagick/trunk/config/francais.xml
r7899 r7954 608 608 image non incluse dans la géométrie 609 609 </message> 610 <message name="InterpretPropertyFailure"> 611 *** failure in interpret image property escapes *** 612 </message> 610 613 <message name="InvalidArgument"> 611 614 argument invalide pour l'option … … 933 936 <message name="GeometryDoesNotContainImage"> 934 937 image non incluse dans la géométrie 938 </message> 939 <message name="InterpretPropertyFailure"> 940 *** failure in interpret image property escapes *** 935 941 </message> 936 942 <message name="InvalidSetting">
Note: See TracChangeset
for help on using the changeset viewer.
