comments and reorganise percent escapes
diff --git a/MagickCore/property.c b/MagickCore/property.c
index 6dab5b2..ab13b65 100644
--- a/MagickCore/property.c
+++ b/MagickCore/property.c
@@ -2620,374 +2620,7 @@
p++;
switch (*p)
{
- case 'b':
- {
- char
- format[MaxTextExtent];
-
- /*
- File size.
- */
- (void) FormatLocaleString(format,MaxTextExtent,"%.20g",(double)
- ((MagickOffsetType) image->extent));
- if (image->extent != (MagickSizeType) ((size_t) image->extent))
- (void) FormatMagickSize(image->extent,MagickFalse,format);
- q+=ConcatenateMagickString(q,format,extent);
- q+=ConcatenateMagickString(q,"B",extent);
- break;
- }
- case 'c':
- {
- /*
- Image comment.
- */
- value=GetImageProperty(image,"comment");
- if (value == (const char *) NULL)
- break;
- length=strlen(value);
- if ((size_t) (q-interpret_text+length+1) >= extent)
- {
- extent+=length;
- interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
- MaxTextExtent,sizeof(*interpret_text));
- if (interpret_text == (char *) NULL)
- break;
- q=interpret_text+strlen(interpret_text);
- }
- (void) CopyMagickString(q,value,extent);
- q+=length;
- break;
- }
- case 'd':
- case 'e':
- case 'f':
- case 't':
- {
- /*
- Label segment is the base of the filename.
- */
- if (*image->magick_filename == '\0')
- break;
- switch (*p)
- {
- case 'd':
- {
- /*
- Directory.
- */
- GetPathComponent(image->magick_filename,HeadPath,filename);
- q+=CopyMagickString(q,filename,extent);
- break;
- }
- case 'e':
- {
- /*
- Filename extension.
- */
- GetPathComponent(image->magick_filename,ExtensionPath,filename);
- q+=CopyMagickString(q,filename,extent);
- break;
- }
- case 'f':
- {
- /*
- Filename.
- */
- GetPathComponent(image->magick_filename,TailPath,filename);
- q+=CopyMagickString(q,filename,extent);
- break;
- }
- case 't':
- {
- /*
- Base filename.
- */
- GetPathComponent(image->magick_filename,BasePath,filename);
- q+=CopyMagickString(q,filename,extent);
- break;
- }
- }
- break;
- }
- case 'g':
- {
- /*
- Image geometry.
- */
- q+=FormatLocaleString(q,extent,"%.20gx%.20g%+.20g%+.20g",(double)
- image->page.width,(double) image->page.height,(double) image->page.x,
- (double) image->page.y);
- break;
- }
- case 'h':
- {
- /*
- Image height.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double) (image->rows != 0 ?
- image->rows : image->magick_rows));
- break;
- }
- case 'i':
- {
- /*
- Image filename.
- */
- q+=CopyMagickString(q,image->filename,extent);
- break;
- }
- case 'k':
- {
- /*
- Number of unique colors.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double) GetNumberColors(image,
- (FILE *) NULL,&image->exception));
- break;
- }
- case 'l':
- {
- /*
- Image label.
- */
- value=GetImageProperty(image,"label");
- if (value == (const char *) NULL)
- break;
- length=strlen(value);
- if ((size_t) (q-interpret_text+length+1) >= extent)
- {
- extent+=length;
- interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
- MaxTextExtent,sizeof(*interpret_text));
- if (interpret_text == (char *) NULL)
- break;
- q=interpret_text+strlen(interpret_text);
- }
- q+=CopyMagickString(q,value,extent);
- break;
- }
- case 'm':
- {
- /*
- Image format.
- */
- q+=CopyMagickString(q,image->magick,extent);
- break;
- }
- case 'M':
- {
- /*
- Image magick filename.
- */
- q+=CopyMagickString(q,image->magick_filename,extent);
- break;
- }
- case 'n':
- {
- /*
- Number of images in the list.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double)
- GetImageListLength(image));
- break;
- }
- case 'o':
- {
- /*
- Image output filename.
- */
- q+=CopyMagickString(q,image_info->filename,extent);
- break;
- }
- case 'p':
- {
- /*
- Image index in list.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double)
- GetImageIndexInList(image));
- break;
- }
- case 'q':
- {
- /*
- Image depth.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double)
- MAGICKCORE_QUANTUM_DEPTH);
- break;
- }
- case 'r':
- {
- ColorspaceType
- colorspace;
-
- /*
- Image storage class and colorspace.
- */
- colorspace=image->colorspace;
- if (IsImageGray(image,&image->exception) != MagickFalse)
- colorspace=GRAYColorspace;
- q+=FormatLocaleString(q,extent,"%s%s%s",CommandOptionToMnemonic(
- MagickClassOptions,(ssize_t) image->storage_class),
- CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
- image->matte != MagickFalse ? "Matte" : "");
- break;
- }
- case 's':
- {
- /*
- Image scene number.
- */
- if (image_info->number_scenes == 0)
- q+=FormatLocaleString(q,extent,"%.20g",(double) image->scene);
- else
- q+=FormatLocaleString(q,extent,"%.20g",(double) image_info->scene);
- break;
- }
- case 'u':
- {
- /*
- Unique filename.
- */
- (void) CopyMagickString(filename,image_info->unique,extent);
- q+=CopyMagickString(q,filename,extent);
- break;
- }
- case 'w':
- {
- /*
- Image width.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double) (image->columns != 0 ?
- image->columns : image->magick_columns));
- break;
- }
- case 'x':
- {
- /*
- Image horizontal resolution.
- */
- q+=FormatLocaleString(q,extent,"%g %s",image->x_resolution,
- CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
- image->units));
- break;
- }
- case 'y':
- {
- /*
- Image vertical resolution.
- */
- q+=FormatLocaleString(q,extent,"%g %s",image->y_resolution,
- CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
- image->units));
- break;
- }
- case 'z':
- {
- /*
- Image depth.
- */
- q+=FormatLocaleString(q,extent,"%.20g",(double) image->depth);
- break;
- }
- case 'A':
- {
- /*
- Image alpha channel.
- */
- q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
- MagickBooleanOptions,(ssize_t) image->matte));
- break;
- }
- case 'C':
- {
- /*
- Image compression method.
- */
- q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
- MagickCompressOptions,(ssize_t) image->compression));
- break;
- }
- case 'D':
- {
- /*
- Image dispose method.
- */
- q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
- MagickDisposeOptions,(ssize_t) image->dispose));
- break;
- }
- case 'G':
- {
- q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double)
- image->magick_columns,(double) image->magick_rows);
- break;
- }
- case 'H':
- {
- q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.height);
- break;
- }
- case 'O':
- {
- q+=FormatLocaleString(q,extent,"%+ld%+ld",(long) image->page.x,(long)
- image->page.y);
- break;
- }
- case 'P':
- {
- q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double) image->page.width,
- (double) image->page.height);
- break;
- }
- case 'Q':
- {
- q+=FormatLocaleString(q,extent,"%.20g",(double) image->quality);
- break;
- }
- case 'S':
- {
- /*
- Image scenes.
- */
- if (image_info->number_scenes == 0)
- q+=CopyMagickString(q,"2147483647",extent);
- else
- q+=FormatLocaleString(q,extent,"%.20g",(double) (image_info->scene+
- image_info->number_scenes));
- break;
- }
- case 'T':
- {
- q+=FormatLocaleString(q,extent,"%.20g",(double) image->delay);
- break;
- }
- case 'W':
- {
- q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.width);
- break;
- }
- case 'X':
- {
- q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.x);
- break;
- }
- case 'Y':
- {
- q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.y);
- break;
- }
- case 'Z':
- {
- /*
- Unique filename.
- */
- (void) CopyMagickString(filename,image_info->zero,extent);
- q+=CopyMagickString(q,filename,extent);
- break;
- }
- case '[':
+ case '[': /* multi-character substitution */
{
char
pattern[MaxTextExtent];
@@ -3104,25 +2737,284 @@
}
break;
}
- case '@':
+ case 'b': /* image size as read in */
+ {
+ char
+ format[MaxTextExtent];
+
+ (void) FormatLocaleString(format,MaxTextExtent,"%.20g",(double)
+ ((MagickOffsetType) image->extent));
+ if (image->extent != (MagickSizeType) ((size_t) image->extent))
+ (void) FormatMagickSize(image->extent,MagickFalse,format);
+ q+=ConcatenateMagickString(q,format,extent);
+ q+=ConcatenateMagickString(q,"B",extent);
+ break;
+ }
+ case 'c': /* image comment properity */
+ {
+ value=GetImageProperty(image,"comment");
+ if (value == (const char *) NULL)
+ break;
+ length=strlen(value);
+ if ((size_t) (q-interpret_text+length+1) >= extent)
+ {
+ extent+=length;
+ interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
+ MaxTextExtent,sizeof(*interpret_text));
+ if (interpret_text == (char *) NULL)
+ break;
+ q=interpret_text+strlen(interpret_text);
+ }
+ (void) CopyMagickString(q,value,extent);
+ q+=length;
+ break;
+ }
+ case 'd': /* Directory component of filename */
+ {
+ GetPathComponent(image->magick_filename,HeadPath,filename);
+ q+=CopyMagickString(q,filename,extent);
+ break;
+ }
+ case 'e': /* Filename extension (suffix) of image file */
+ {
+ GetPathComponent(image->magick_filename,ExtensionPath,filename);
+ q+=CopyMagickString(q,filename,extent);
+ break;
+ }
+ case 'f': /* Filename without directory component */
+ {
+ GetPathComponent(image->magick_filename,TailPath,filename);
+ q+=CopyMagickString(q,filename,extent);
+ break;
+ }
+ case 't': /* Base filename without directory or extention */
+ {
+ GetPathComponent(image->magick_filename,BasePath,filename);
+ q+=CopyMagickString(q,filename,extent);
+ break;
+ }
+ case 'g': /* Image geometry, canvas and offset */
+ {
+ q+=FormatLocaleString(q,extent,"%.20gx%.20g%+.20g%+.20g",(double)
+ image->page.width,(double) image->page.height,(double) image->page.x,
+ (double) image->page.y);
+ break;
+ }
+ case 'h': /* Image height */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) (image->rows != 0 ?
+ image->rows : image->magick_rows));
+ break;
+ }
+ case 'i': /* Images filename - (output filename with "info:" ) */
+ {
+ q+=CopyMagickString(q,image->filename,extent);
+ break;
+ }
+ case 'k': /* Number of unique colors */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) GetNumberColors(image,
+ (FILE *) NULL,&image->exception));
+ break;
+ }
+ case 'l': /* Image label */
+ {
+ value=GetImageProperty(image,"label");
+ if (value == (const char *) NULL)
+ break;
+ length=strlen(value);
+ if ((size_t) (q-interpret_text+length+1) >= extent)
+ {
+ extent+=length;
+ interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
+ MaxTextExtent,sizeof(*interpret_text));
+ if (interpret_text == (char *) NULL)
+ break;
+ q=interpret_text+strlen(interpret_text);
+ }
+ q+=CopyMagickString(q,value,extent);
+ break;
+ }
+ case 'm': /* Image format (file magick) */
+ {
+ q+=CopyMagickString(q,image->magick,extent);
+ break;
+ }
+ case 'M': /* Magick filename - exactly as given incl. read mods */
+ {
+ q+=CopyMagickString(q,image->magick_filename,extent);
+ break;
+ }
+ case 'n': /* Number of images in the list. */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double)
+ GetImageListLength(image));
+ break;
+ }
+ case 'o': /* Image output filename */
+ {
+ q+=CopyMagickString(q,image_info->filename,extent);
+ break;
+ }
+ case 'p': /* Image index in curent image list */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double)
+ GetImageIndexInList(image));
+ break;
+ }
+ case 'q': /* Quantum depth of image in memory */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double)
+ MAGICKCORE_QUANTUM_DEPTH);
+ break;
+ }
+ case 'r': /* Image storage class and colorspace. */
+ {
+ ColorspaceType
+ colorspace;
+
+ colorspace=image->colorspace;
+ if (IsImageGray(image,&image->exception) != MagickFalse)
+ colorspace=GRAYColorspace;
+ q+=FormatLocaleString(q,extent,"%s%s%s",CommandOptionToMnemonic(
+ MagickClassOptions,(ssize_t) image->storage_class),
+ CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
+ image->matte != MagickFalse ? "Matte" : "");
+ break;
+ }
+ case 's': /* Image scene number */
+ {
+ if (image_info->number_scenes == 0)
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image->scene);
+ else
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image_info->scene);
+ break;
+ }
+ case 'u': /* Unique filename */
+ {
+ (void) CopyMagickString(filename,image_info->unique,extent);
+ q+=CopyMagickString(q,filename,extent);
+ break;
+ }
+ case 'w': /* Image width */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) (image->columns != 0 ?
+ image->columns : image->magick_columns));
+ break;
+ }
+ case 'x': /* Image horizontal resolution (density). */
+ {
+ q+=FormatLocaleString(q,extent,"%g %s",image->x_resolution,
+ CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
+ image->units));
+ break;
+ }
+ case 'y': /* Image vertical resolution (density) */
+ {
+ q+=FormatLocaleString(q,extent,"%g %s",image->y_resolution,
+ CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
+ image->units));
+ break;
+ }
+ case 'z': /* Image depth as read in */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image->depth);
+ break;
+ }
+ case 'A': /* Image alpha channel */
+ {
+ q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
+ MagickBooleanOptions,(ssize_t) image->matte));
+ break;
+ }
+ case 'C': /* Image compression method. */
+ {
+ q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
+ MagickCompressOptions,(ssize_t) image->compression));
+ break;
+ }
+ case 'D': /* Image dispose method. */
+ {
+ q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
+ MagickDisposeOptions,(ssize_t) image->dispose));
+ break;
+ }
+ case 'G': /* Image size as geometry = "%wx%h" */
+ {
+ q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double)
+ image->magick_columns,(double) image->magick_rows);
+ break;
+ }
+ case 'H': /* layer canvas height */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.height);
+ break;
+ }
+ case 'O': /* layer canvas offset with sign = "+%X+%Y" */
+ {
+ q+=FormatLocaleString(q,extent,"%+ld%+ld",(long) image->page.x,(long)
+ image->page.y);
+ break;
+ }
+ case 'P': /* layer canvas page size = "%Wx%H" */
+ {
+ q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double) image->page.width,
+ (double) image->page.height);
+ break;
+ }
+ case 'Q': /* image compression quality */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image->quality);
+ break;
+ }
+ case 'S': /* Image scenes */
+ {
+ if (image_info->number_scenes == 0)
+ q+=CopyMagickString(q,"2147483647",extent);
+ else
+ q+=FormatLocaleString(q,extent,"%.20g",(double) (image_info->scene+
+ image_info->number_scenes));
+ break;
+ }
+ case 'T': /* image time delay for animations */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image->delay);
+ break;
+ }
+ case 'W': /* layer canvas width */
+ {
+ q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.width);
+ break;
+ }
+ case 'X': /* layer canvas X offset */
+ {
+ q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.x);
+ break;
+ }
+ case 'Y': /* layer canvas Y offset */
+ {
+ q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.y);
+ break;
+ }
+ case 'Z': /* Unique filename. */
+ {
+ (void) CopyMagickString(filename,image_info->zero,extent);
+ q+=CopyMagickString(q,filename,extent);
+ break;
+ }
+ case '@': /* Image bounding box. */
{
RectangleInfo
page;
- /*
- Image bounding box.
- */
page=GetImageBoundingBox(image,exception);
q+=FormatLocaleString(q,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
(double) page.width,(double) page.height,(double) page.x,(double)
page.y);
break;
}
- case '#':
+ case '#': /* Image signature */
{
- /*
- Image signature.
- */
(void) SignatureImage(image,exception);
value=GetImageProperty(image,"signature");
if (value == (const char *) NULL)
@@ -3130,12 +3022,12 @@
q+=CopyMagickString(q,value,extent);
break;
}
- case '%':
+ case '%': /* percent escaped */
{
*q++=(*p);
break;
}
- default:
+ default: /* percent not expanded */
{
*q++='%';
*q++=(*p);