Change IsMagickTrue() to more sensible name IsStringTrue()
diff --git a/MagickCore/coder.c b/MagickCore/coder.c
index 2dbb61c..5a97d23 100644
--- a/MagickCore/coder.c
+++ b/MagickCore/coder.c
@@ -836,7 +836,7 @@
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- coder_info->stealth=IsMagickTrue(token);
+ coder_info->stealth=IsStringTrue(token);
break;
}
break;
diff --git a/MagickCore/color.c b/MagickCore/color.c
index 0d9e761..44464b0 100644
--- a/MagickCore/color.c
+++ b/MagickCore/color.c
@@ -1995,7 +1995,7 @@
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- color_info->stealth=IsMagickTrue(token);
+ color_info->stealth=IsStringTrue(token);
break;
}
break;
diff --git a/MagickCore/configure.c b/MagickCore/configure.c
index cf41796..da3a1ea 100644
--- a/MagickCore/configure.c
+++ b/MagickCore/configure.c
@@ -1156,7 +1156,7 @@
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- configure_info->stealth=IsMagickTrue(token);
+ configure_info->stealth=IsStringTrue(token);
break;
}
break;
diff --git a/MagickCore/constitute.c b/MagickCore/constitute.c
index 2048798..375230d 100644
--- a/MagickCore/constitute.c
+++ b/MagickCore/constitute.c
@@ -1075,12 +1075,11 @@
}
(void) SyncImageProfiles(image);
option=GetImageOption(image_info,"delegate:bimodal");
- if ((option != (const char *) NULL) &&
- (IsMagickTrue(option) != MagickFalse) &&
+ if ((IfTrue(IsStringTrue(option))) &&
(write_info->page == (char *) NULL) &&
(GetPreviousImageInList(image) == (Image *) NULL) &&
(GetNextImageInList(image) == (Image *) NULL) &&
- (IsTaintImage(image) == MagickFalse))
+ (IfFalse(IsTaintImage(image))) )
{
delegate_info=GetDelegateInfo(image->magick,write_info->magick,exception);
if ((delegate_info != (const DelegateInfo *) NULL) &&
diff --git a/MagickCore/delegate.c b/MagickCore/delegate.c
index 2cff2b5..0c69a53 100644
--- a/MagickCore/delegate.c
+++ b/MagickCore/delegate.c
@@ -1405,12 +1405,12 @@
{
if (LocaleCompare((char *) keyword,"spawn") == 0)
{
- delegate_info->spawn=IsMagickTrue(token);
+ delegate_info->spawn=IsStringTrue(token);
break;
}
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- delegate_info->stealth=IsMagickTrue(token);
+ delegate_info->stealth=IsStringTrue(token);
break;
}
break;
@@ -1420,7 +1420,7 @@
{
if (LocaleCompare((char *) keyword,"thread-support") == 0)
{
- delegate_info->thread_support=IsMagickTrue(token);
+ delegate_info->thread_support=IsStringTrue(token);
break;
}
break;
diff --git a/MagickCore/distort.c b/MagickCore/distort.c
index 0e6c0a5..410f457 100644
--- a/MagickCore/distort.c
+++ b/MagickCore/distort.c
@@ -1954,7 +1954,7 @@
}
/* Verbose output */
- if ( IsMagickTrue(GetImageArtifact(image,"verbose")) != MagickFalse ) {
+ if ( IfTrue(IsStringTrue(GetImageArtifact(image,"verbose"))) ) {
register ssize_t
i;
char image_gen[MaxTextExtent];
@@ -2937,7 +2937,7 @@
}
/* Verbose output */
- if ( IsMagickTrue(GetImageArtifact(image,"verbose")) != MagickFalse ) {
+ if ( IfTrue(IsStringTrue(GetImageArtifact(image,"verbose"))) ) {
switch (sparse_method) {
case BarycentricColorInterpolate:
diff --git a/MagickCore/identify.c b/MagickCore/identify.c
index b733a9d..0245fe5 100644
--- a/MagickCore/identify.c
+++ b/MagickCore/identify.c
@@ -614,7 +614,6 @@
(void) FormatLocaleFile(file," %s\n",tuple);
}
}
- artifact=GetImageArtifact(image,"identify:unique-colors");
if (IsHistogramImage(image,exception) != MagickFalse)
{
(void) FormatLocaleFile(file," Colors: %.20g\n",(double)
@@ -622,11 +621,12 @@
(void) FormatLocaleFile(file," Histogram:\n");
(void) GetNumberColors(image,file,exception);
}
- else
- if ((artifact != (const char *) NULL) &&
- (IsMagickTrue(artifact) != MagickFalse))
- (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
- GetNumberColors(image,(FILE *) NULL,exception));
+ else {
+ artifact=GetImageArtifact(image,"identify:unique-colors");
+ if (IfTrue(IsStringTrue(artifact)))
+ (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
+ GetNumberColors(image,(FILE *) NULL,exception));
+ }
}
if (image->storage_class == PseudoClass)
{
diff --git a/MagickCore/image.c b/MagickCore/image.c
index 8072a17..8e92b59 100644
--- a/MagickCore/image.c
+++ b/MagickCore/image.c
@@ -1198,9 +1198,6 @@
*/
MagickExport void GetImageInfo(ImageInfo *image_info)
{
- const char
- *synchronize;
-
ExceptionInfo
*exception;
@@ -1216,9 +1213,8 @@
image_info->quality=UndefinedCompressionQuality;
image_info->antialias=MagickTrue;
image_info->dither=MagickTrue;
- synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE");
- if (synchronize != (const char *) NULL)
- image_info->synchronize=IsMagickTrue(synchronize);
+ image_info->synchronize=IsStringTrue(GetEnvironmentValue(
+ "MAGICK_SYNCHRONIZE"));
exception=AcquireExceptionInfo();
(void) QueryColorCompliance(BackgroundColor,AllCompliance,
&image_info->background_color,exception);
diff --git a/MagickCore/magic.c b/MagickCore/magic.c
index 79e2a69..cfbfa56 100644
--- a/MagickCore/magic.c
+++ b/MagickCore/magic.c
@@ -822,7 +822,7 @@
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- magic_info->stealth=IsMagickTrue(token);
+ magic_info->stealth=IsStringTrue(token);
break;
}
break;
diff --git a/MagickCore/magick-type.h b/MagickCore/magick-type.h
index f8fdb92..1495eb3 100644
--- a/MagickCore/magick-type.h
+++ b/MagickCore/magick-type.h
@@ -159,6 +159,36 @@
MagickTrue = 1
} MagickBooleanType;
+/*
+ Define some short-hand macros for handling MagickBooleanType
+ Some of these assume MagickBooleanType uses values 0 and 1,
+ and uses fast C typing with C boolean operations
+
+ Is -- returns MagickBooleanType
+ If -- returns C integer boolean (for if's and while's)
+
+ IsTrue() converts a C integer boolean to a MagickBooleanType
+ IsFalse() is a MagickBooleanType 'not' operation
+
+ IfTrue() converts MagickBooleanType to C integer Boolean
+ IfFalse() Not the MagickBooleanType to C integer Boolean
+
+ IsNULL() and IsNotNULL() converts C pointers to MagickBooleanType
+*/
+#if 1
+# define IsTrue(v) ((MagickBooleanType)((int)(v) != 0))
+# define IsFalse(v) ((MagickBooleanType)(!(int)(v)))
+# define IfTrue(v) ((int)(v))
+# define IfFalse(v) (!(int)(v))
+#else
+# define IsTrue(v) ((MagickBooleanType)(v)!=MagickFalse?MagickTrue:MagickFalse)
+# define IsFalse(v) ((MagickBooleanType)(v)==MagickFalse?MagickTrue:MagickFalse)
+# define IfTrue(v) ((v) != MagickFalse)
+# define IfFalse(v) ((v) == MagickFalse)
+#endif
+#define IsNULL(v) (((void *)(v) == NULL)?MagickTrue:MagickFalse)
+#define IsNotNULL(v) (((void *)(v) != NULL)?MagickTrue:MagickFalse)
+
typedef struct _BlobInfo BlobInfo;
typedef struct _ExceptionInfo ExceptionInfo;
diff --git a/MagickCore/mime.c b/MagickCore/mime.c
index 8c273b1..98acf07 100644
--- a/MagickCore/mime.c
+++ b/MagickCore/mime.c
@@ -913,8 +913,7 @@
if (attribute != (const char *) NULL)
mime_info->priority=(ssize_t) strtol(attribute,(char **) NULL,0);
attribute=GetXMLTreeAttribute(mime,"stealth");
- if (attribute != (const char *) NULL)
- mime_info->stealth=IsMagickTrue(attribute);
+ mime_info->stealth=IsStringTrue(attribute);
attribute=GetXMLTreeAttribute(mime,"type");
if (attribute != (const char *) NULL)
mime_info->type=ConstantString(attribute);
diff --git a/MagickCore/morphology.c b/MagickCore/morphology.c
index ed99e2f..55ba9b6 100644
--- a/MagickCore/morphology.c
+++ b/MagickCore/morphology.c
@@ -3802,7 +3802,7 @@
if ( iterations < 0 ) /* negative interations = infinite (well alomst) */
kernel_limit = image->columns>image->rows ? image->columns : image->rows;
- verbose = IsMagickTrue(GetImageArtifact(image,"verbose"));
+ verbose = IsStringTrue(GetImageArtifact(image,"verbose"));
/* initialise for cleanup */
curr_image = (Image *) image;
@@ -3863,7 +3863,7 @@
changed = MorphologyPrimitiveDirect(rslt_image, method,
kernel, exception);
- if ( verbose == MagickTrue )
+ if ( IfTrue(verbose) )
(void) (void) FormatLocaleFile(stderr,
"%s:%.20g.%.20g #%.20g => Changed %.20g\n",
CommandOptionToMnemonic(MagickMorphologyOptions, method),
@@ -4011,7 +4011,7 @@
assert( this_kernel != (KernelInfo *) NULL );
/* Extra information for debugging compound operations */
- if ( verbose == MagickTrue ) {
+ if ( IfTrue(verbose) ) {
if ( stage_limit > 1 )
(void) FormatLocaleString(v_info,MaxTextExtent,"%s:%.20g.%.20g -> ",
CommandOptionToMnemonic(MagickMorphologyOptions,method),(double)
@@ -4047,7 +4047,7 @@
changed = MorphologyPrimitive(curr_image, work_image, primitive,
this_kernel, bias, exception);
- if ( verbose == MagickTrue ) {
+ if ( IfTrue(verbose) ) {
if ( kernel_loop > 1 )
(void) FormatLocaleFile(stderr, "\n"); /* add end-of-line from previous */
(void) (void) FormatLocaleFile(stderr,
@@ -4072,9 +4072,9 @@
} /* End Loop 4: Iterate the kernel with primitive */
- if ( verbose == MagickTrue && kernel_changed != (size_t)changed )
+ if ( IfTrue(verbose) && kernel_changed != (size_t)changed )
(void) FormatLocaleFile(stderr, " Total %.20g",(double) kernel_changed);
- if ( verbose == MagickTrue && stage_loop < stage_limit )
+ if ( IfTrue(verbose) && stage_loop < stage_limit )
(void) FormatLocaleFile(stderr, "\n"); /* add end-of-line before looping */
#if 0
@@ -4099,7 +4099,7 @@
case EdgeInMorphology:
case TopHatMorphology:
case BottomHatMorphology:
- if ( verbose == MagickTrue )
+ if ( IfTrue(verbose) )
(void) FormatLocaleFile(stderr,
"\n%s: Difference with original image",CommandOptionToMnemonic(
MagickMorphologyOptions, method) );
@@ -4107,7 +4107,7 @@
MagickFalse,0,0,exception);
break;
case EdgeMorphology:
- if ( verbose == MagickTrue )
+ if ( IfTrue(verbose) )
(void) FormatLocaleFile(stderr,
"\n%s: Difference of Dilate and Erode",CommandOptionToMnemonic(
MagickMorphologyOptions, method) );
@@ -4123,7 +4123,7 @@
if ( kernel->next == (KernelInfo *) NULL )
rslt_image = curr_image; /* just return the resulting image */
else if ( rslt_compose == NoCompositeOp )
- { if ( verbose == MagickTrue ) {
+ { if ( IfTrue(verbose) ) {
if ( this_kernel->next != (KernelInfo *) NULL )
(void) FormatLocaleFile(stderr, " (re-iterate)");
else
@@ -4132,7 +4132,7 @@
rslt_image = curr_image; /* return result, and re-iterate */
}
else if ( rslt_image == (Image *) NULL)
- { if ( verbose == MagickTrue )
+ { if ( IfTrue(verbose) )
(void) FormatLocaleFile(stderr, " (save for compose)");
rslt_image = curr_image;
curr_image = (Image *) image; /* continue with original image */
@@ -4145,7 +4145,7 @@
** purely mathematical way, and only to the selected channels.
** IE: Turn off SVG composition 'alpha blending'.
*/
- if ( verbose == MagickTrue )
+ if ( IfTrue(verbose) )
(void) FormatLocaleFile(stderr, " (compose \"%s\")",
CommandOptionToMnemonic(MagickComposeOptions, rslt_compose) );
(void) CompositeImage(rslt_image,curr_image,rslt_compose,MagickFalse,
@@ -4153,7 +4153,7 @@
curr_image = DestroyImage(curr_image);
curr_image = (Image *) image; /* continue with original image */
}
- if ( verbose == MagickTrue )
+ if ( IfTrue(verbose) )
(void) FormatLocaleFile(stderr, "\n");
/* loop to the next kernel in a multi-kernel list */
@@ -4282,9 +4282,9 @@
}
/* display the (normalized) kernel via stderr */
- if ( IsMagickTrue(GetImageArtifact(image,"showkernel"))
- || IsMagickTrue(GetImageArtifact(image,"convolve:showkernel"))
- || IsMagickTrue(GetImageArtifact(image,"morphology:showkernel")) )
+ if ( IfTrue(IsStringTrue(GetImageArtifact(image,"showkernel")))
+ || IfTrue(IsStringTrue(GetImageArtifact(image,"convolve:showkernel")))
+ || IfTrue(IsStringTrue(GetImageArtifact(image,"morphology:showkernel"))) )
ShowKernelInfo(curr_kernel);
/* Override the default handling of multi-kernel morphology results
diff --git a/MagickCore/policy.c b/MagickCore/policy.c
index 7bf07de..6659e50 100644
--- a/MagickCore/policy.c
+++ b/MagickCore/policy.c
@@ -825,7 +825,7 @@
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- policy_info->stealth=IsMagickTrue(token);
+ policy_info->stealth=IsStringTrue(token);
break;
}
break;
diff --git a/MagickCore/resample.c b/MagickCore/resample.c
index fa8efc1..c62560c 100644
--- a/MagickCore/resample.c
+++ b/MagickCore/resample.c
@@ -1326,7 +1326,8 @@
/* Scale radius so the filter LUT covers the full support range */
r_scale = resample_filter->support*sqrt(1.0/(double)WLUT_WIDTH);
- if (IsMagickTrue(GetImageArtifact(resample_filter->image,"resample:verbose")) )
+ if (IfTrue(IsStringTrue(GetImageArtifact(resample_filter->image,
+ "resample:verbose"))) )
{
/* Debug output of the filter weighting LUT
Gnuplot the LUT with hoizontal adjusted to 'r' using...
diff --git a/MagickCore/resize.c b/MagickCore/resize.c
index 13221aa..3e8b38b 100644
--- a/MagickCore/resize.c
+++ b/MagickCore/resize.c
@@ -1054,7 +1054,7 @@
{
#endif
artifact=GetImageArtifact(image,"filter:verbose");
- if (IsMagickTrue(artifact) != MagickFalse)
+ if (IfTrue(IsStringTrue(artifact)))
{
double
support,
diff --git a/MagickCore/string.c b/MagickCore/string.c
index fc9bb57..a2ed535 100644
--- a/MagickCore/string.c
+++ b/MagickCore/string.c
@@ -1408,6 +1408,89 @@
% %
% %
% %
+% I s S t r i n g T r u e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% IsStringTrue() returns MagickTrue if the value is "true", "on", "yes" or
+% "1". Any other string or undefined returns MagickFalse.
+%
+% Typically this is used to look at strings (options or artifacts) which
+% has a default value of "false", when not defined.
+%
+% The format of the IsStringTrue method is:
+%
+% MagickBooleanType IsStringTrue(const char *value)
+%
+% A description of each parameter follows:
+%
+% o value: Specifies a pointer to a character array.
+%
+*/
+MagickExport MagickBooleanType IsStringTrue(const char *value)
+{
+ if (value == (const char *) NULL)
+ return(MagickFalse);
+ if (LocaleCompare(value,"true") == 0)
+ return(MagickTrue);
+ if (LocaleCompare(value,"on") == 0)
+ return(MagickTrue);
+ if (LocaleCompare(value,"yes") == 0)
+ return(MagickTrue);
+ if (LocaleCompare(value,"1") == 0)
+ return(MagickTrue);
+ return(MagickFalse);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% I s S t r i n g N o t F a l s e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% IsStringNotFalse() returns MagickTrue, unless the string specifically
+% has a value that makes this false. that is if it has a value of
+% "false", "off", "no" or "0".
+%
+% Typically this is used to look at strings (options or artifacts) which
+% has a default value of "true", when it has not been defined.
+%
+% The format of the IsStringNotFalse method is:
+%
+% MagickBooleanType IsStringNotFalse(const char *value)
+%
+% A description of each parameter follows:
+%
+% o value: Specifies a pointer to a character array.
+%
+*/
+MagickExport MagickBooleanType IsStringNotFalse(const char *value)
+{
+ if (value == (const char *) NULL)
+ return(MagickTrue);
+ if (LocaleCompare(value,"false") == 0)
+ return(MagickFalse);
+ if (LocaleCompare(value,"off") == 0)
+ return(MagickFalse);
+ if (LocaleCompare(value,"no") == 0)
+ return(MagickFalse);
+ if (LocaleCompare(value,"0") == 0)
+ return(MagickFalse);
+ return(MagickTrue);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% L o c a l e C o m p a r e %
% %
% %
diff --git a/MagickCore/string_.h b/MagickCore/string_.h
index 5a2050c..60640cc 100644
--- a/MagickCore/string_.h
+++ b/MagickCore/string_.h
@@ -67,6 +67,8 @@
extern MagickExport MagickBooleanType
ConcatenateString(char **,const char *),
+ IsStringTrue(const char *),
+ IsStringNotFalse(const char *),
SubstituteString(char **,const char *,const char *);
extern MagickExport size_t
diff --git a/MagickCore/token.c b/MagickCore/token.c
index 0752ee1..c32ec63 100644
--- a/MagickCore/token.c
+++ b/MagickCore/token.c
@@ -612,47 +612,6 @@
% %
% %
% %
-% I s M a g i c k T r u e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% IsMagickTrue() returns MagickTrue if the value is "true", "on", "yes" or
-% "1".
-%
-% The format of the IsMagickTrue method is:
-%
-% MagickBooleanType IsMagickTrue(const char *value)
-%
-% A description of each parameter follows:
-%
-% o option: either MagickTrue or MagickFalse depending on the value
-% parameter.
-%
-% o value: Specifies a pointer to a character array.
-%
-*/
-MagickExport MagickBooleanType IsMagickTrue(const char *value)
-{
- if (value == (const char *) NULL)
- return(MagickFalse);
- if (LocaleCompare(value,"true") == 0)
- return(MagickTrue);
- if (LocaleCompare(value,"on") == 0)
- return(MagickTrue);
- if (LocaleCompare(value,"yes") == 0)
- return(MagickTrue);
- if (LocaleCompare(value,"1") == 0)
- return(MagickTrue);
- return(MagickFalse);
-}
-
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
% T o k e n i z e r %
% %
% %
diff --git a/MagickCore/token.h b/MagickCore/token.h
index 79768ac..9055eb6 100644
--- a/MagickCore/token.h
+++ b/MagickCore/token.h
@@ -33,8 +33,10 @@
const char *,const char *,const char *,const char,char *,int *,char *);
extern MagickExport MagickBooleanType
- GlobExpression(const char *,const char *,const MagickBooleanType),
- IsMagickTrue(const char *);
+ GlobExpression(const char *,const char *,const MagickBooleanType);
+
+/* Depreciated Function equivelent */
+// #define IsMagickTrue(v) IsStringTrue(v)
extern MagickExport TokenInfo
*AcquireTokenInfo(void),
diff --git a/MagickCore/type.c b/MagickCore/type.c
index 6699e98..8e9d26c 100644
--- a/MagickCore/type.c
+++ b/MagickCore/type.c
@@ -1208,7 +1208,7 @@
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- type_info->stealth=IsMagickTrue(token);
+ type_info->stealth=IsStringTrue(token);
break;
}
if (LocaleCompare((char *) keyword,"stretch") == 0)
diff --git a/MagickCore/xwindow.c b/MagickCore/xwindow.c
index 12eb39d..733469b 100644
--- a/MagickCore/xwindow.c
+++ b/MagickCore/xwindow.c
@@ -3493,7 +3493,7 @@
resource_info->client_name=AcquireString(client_name);
resource_value=XGetResourceClass(database,client_name,"backdrop",
(char *) "False");
- resource_info->backdrop=IsMagickTrue(resource_value);
+ resource_info->backdrop=IsStringTrue(resource_value);
resource_info->background_color=XGetResourceInstance(database,client_name,
"background",(char *) "#d6d6d6d6d6d6");
resource_info->border_color=XGetResourceInstance(database,client_name,
@@ -3514,20 +3514,20 @@
resource_value);
resource_value=XGetResourceClass(database,client_name,
"colorRecovery",(char *) "False");
- resource_info->color_recovery=IsMagickTrue(resource_value);
+ resource_info->color_recovery=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"confirmExit",
(char *) "False");
- resource_info->confirm_exit=IsMagickTrue(resource_value);
+ resource_info->confirm_exit=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"confirmEdit",
(char *) "False");
- resource_info->confirm_edit=IsMagickTrue(resource_value);
+ resource_info->confirm_edit=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"delay",(char *) "1");
resource_info->delay=(unsigned int) StringToUnsignedLong(resource_value);
resource_info->display_gamma=XGetResourceClass(database,client_name,
"displayGamma",(char *) "2.2");
resource_value=XGetResourceClass(database,client_name,"displayWarnings",
(char *) "True");
- resource_info->display_warnings=IsMagickTrue(resource_value);
+ resource_info->display_warnings=IsStringTrue(resource_value);
resource_info->font=XGetResourceClass(database,client_name,"font",
(char *) NULL);
resource_info->font=XGetResourceClass(database,client_name,"fontList",
@@ -3558,7 +3558,7 @@
"foreground",ForegroundColor);
resource_value=XGetResourceClass(database,client_name,"gammaCorrect",
(char *) "True");
- resource_info->gamma_correct=IsMagickTrue(resource_value);
+ resource_info->gamma_correct=IsStringTrue(resource_value);
resource_info->image_geometry=ConstantString(XGetResourceClass(database,
client_name,"geometry",(char *) NULL));
resource_value=XGetResourceClass(database,client_name,"gravity",
@@ -3571,11 +3571,11 @@
"iconGeometry",(char *) NULL);
resource_value=XGetResourceClass(database,client_name,"iconic",
(char *) "False");
- resource_info->iconic=IsMagickTrue(resource_value);
+ resource_info->iconic=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"immutable",
LocaleCompare(client_name,"PerlMagick") == 0 ? (char *) "True" :
(char *) "False");
- resource_info->immutable=IsMagickTrue(resource_value);
+ resource_info->immutable=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"magnify",
(char *) "3");
resource_info->magnify=(unsigned int) StringToUnsignedLong(resource_value);
@@ -3622,13 +3622,13 @@
resource_info->undo_cache=(unsigned int) StringToUnsignedLong(resource_value);
resource_value=XGetResourceClass(database,client_name,"update",
(char *) "False");
- resource_info->update=IsMagickTrue(resource_value);
+ resource_info->update=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"usePixmap",
(char *) "True");
- resource_info->use_pixmap=IsMagickTrue(resource_value);
+ resource_info->use_pixmap=IsStringTrue(resource_value);
resource_value=XGetResourceClass(database,client_name,"sharedMemory",
(char *) "True");
- resource_info->use_shared_memory=IsMagickTrue(resource_value);
+ resource_info->use_shared_memory=IsStringTrue(resource_value);
resource_info->visual_type=XGetResourceClass(database,client_name,"visual",
(char *) NULL);
resource_info->window_group=XGetResourceClass(database,client_name,
diff --git a/coders/histogram.c b/coders/histogram.c
index a05d3bf..2f1771a 100644
--- a/coders/histogram.c
+++ b/coders/histogram.c
@@ -186,9 +186,6 @@
char
filename[MaxTextExtent];
- const char
- *option;
-
Image
*histogram_image;
@@ -337,12 +334,11 @@
if (status == MagickFalse)
break;
}
- /*
- Relinquish resources.
- */
histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
- option=GetImageOption(image_info,"histogram:unique-colors");
- if ((option == (const char *) NULL) || (IsMagickTrue(option) != MagickFalse))
+
+ /* output unique colors? IMv6 is on by default, IMv7 is off by default */
+ if (IfTrue((IsStringTrue(GetImageOption(image_info,
+ "histogram:unique-colors")))))
{
FILE
*file;
diff --git a/coders/jpeg.c b/coders/jpeg.c
index c1a4137..bc29af4 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -1157,12 +1157,7 @@
jpeg_info.desired_number_of_colors=(int) StringToUnsignedLong(option);
}
option=GetImageOption(image_info,"jpeg:block-smoothing");
- if (option != (const char *) NULL)
- {
- jpeg_info.do_block_smoothing=MagickFalse;
- if (IsMagickTrue(option) != MagickFalse)
- jpeg_info.do_block_smoothing=MagickTrue;
- }
+ jpeg_info.do_block_smoothing=IsStringTrue(option);
jpeg_info.dct_method=JDCT_FLOAT;
option=GetImageOption(image_info,"jpeg:dct-method");
if (option != (const char *) NULL)
@@ -1195,12 +1190,7 @@
}
}
option=GetImageOption(image_info,"jpeg:fancy-upsampling");
- if (option != (const char *) NULL)
- {
- jpeg_info.do_fancy_upsampling=MagickFalse;
- if (IsMagickTrue(option) != MagickFalse)
- jpeg_info.do_fancy_upsampling=MagickTrue;
- }
+ jpeg_info.do_fancy_upsampling=IsStringTrue(option);
(void) jpeg_start_decompress(&jpeg_info);
image->columns=jpeg_info.output_width;
image->rows=jpeg_info.output_height;
@@ -2170,11 +2160,7 @@
}
option=GetImageOption(image_info,"jpeg:optimize-coding");
if (option != (const char *) NULL)
- {
- jpeg_info.optimize_coding=MagickFalse;
- if (IsMagickTrue(option) != MagickFalse)
- jpeg_info.optimize_coding=MagickTrue;
- }
+ jpeg_info.optimize_coding=IsStringTrue(option);
else
{
MagickSizeType
@@ -2188,9 +2174,8 @@
Perform optimization only if available memory resources permit it.
*/
status=AcquireMagickResource(MemoryResource,length);
- if (status != MagickFalse)
- jpeg_info.optimize_coding=MagickTrue;
RelinquishMagickResource(MemoryResource,length);
+ jpeg_info.optimize_coding=status;
}
}
#if (JPEG_LIB_VERSION >= 61) && defined(C_PROGRESSIVE_SUPPORTED)
diff --git a/coders/pango.c b/coders/pango.c
index c02c50f..c440939 100644
--- a/coders/pango.c
+++ b/coders/pango.c
@@ -275,10 +275,10 @@
pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_START);
}
option=GetImageOption(image_info,"pango:justify");
- if ((option != (const char *) NULL) && (IsMagickTrue(option) != MagickFalse))
+ if (IfTrue(IsStringTrue(option)))
pango_layout_set_justify(layout,1);
option=GetImageOption(image_info,"pango:single-paragraph");
- if ((option != (const char *) NULL) && (IsMagickTrue(option) != MagickFalse))
+ if (IfTrue(IsStringTrue(option)))
pango_layout_set_single_paragraph_mode(layout,1);
option=GetImageOption(image_info,"pango:wrap");
if (option != (const char *) NULL)
@@ -329,7 +329,7 @@
pango_font_description_free(description);
}
option=GetImageOption(image_info,"pango:markup");
- if ((option != (const char *) NULL) && (IsMagickTrue(option) == MagickFalse))
+ if (IfTrue(IsStringNotFalse(option))) /* enabled by default */
pango_layout_set_text(layout,caption,-1);
else
{
diff --git a/coders/pcl.c b/coders/pcl.c
index 2697864..4333fdb 100644
--- a/coders/pcl.c
+++ b/coders/pcl.c
@@ -787,8 +787,7 @@
}
}
option=GetImageOption(image_info,"pcl:fit-to-page");
- if ((option != (const char *) NULL) &&
- (IsMagickTrue(option) != MagickFalse))
+ if (IfTrue(IsStringTrue(option)))
(void) WriteBlobString(image,"\033*r3A");
else
(void) WriteBlobString(image,"\033*r1A"); /* start raster graphics */
diff --git a/coders/pdf.c b/coders/pdf.c
index b7c39c3..e9a5c74 100644
--- a/coders/pdf.c
+++ b/coders/pdf.c
@@ -425,14 +425,8 @@
Determine page geometry from the PDF media box.
*/
cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
- cropbox=MagickFalse;
- option=GetImageOption(image_info,"pdf:use-cropbox");
- if (option != (const char *) NULL)
- cropbox=IsMagickTrue(option);
- trimbox=MagickFalse;
- option=GetImageOption(image_info,"pdf:use-trimbox");
- if (option != (const char *) NULL)
- trimbox=IsMagickTrue(option);
+ cropbox=IsStringTrue(GetImageOption(image_info,"pdf:use-cropbox"));
+ trimbox=IsStringTrue(GetImageOption(image_info,"pdf:use-trimbox"));
count=0;
spotcolor=0;
(void) ResetMagickMemory(&bounding_box,0,sizeof(bounding_box));
diff --git a/coders/ps.c b/coders/ps.c
index 01f0203..3aaf6a8 100644
--- a/coders/ps.c
+++ b/coders/ps.c
@@ -346,9 +346,6 @@
options[MaxTextExtent],
postscript_filename[MaxTextExtent];
- const char
- *option;
-
const DelegateInfo
*delegate_info;
@@ -775,8 +772,7 @@
if (read_info->scenes != (char *) NULL)
*read_info->scenes='\0';
}
- option=GetImageOption(image_info,"ps:use-cropbox");
- if ((option != (const char *) NULL) && (IsMagickTrue(option) != MagickFalse))
+ if (IfTrue(IsStringTrue(GetImageOption(image_info,"ps:use-cropbox"))))
(void) ConcatenateMagickString(options,"-dEPSCrop ",MaxTextExtent);
(void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
(void) AcquireUniqueFilename(filename);
diff --git a/coders/tiff.c b/coders/tiff.c
index c7a5992..83c48f5 100644
--- a/coders/tiff.c
+++ b/coders/tiff.c
@@ -1106,8 +1106,7 @@
TIFFGetProfiles(tiff,image,exception);
TIFFGetProperties(tiff,image,exception);
option=GetImageOption(image_info,"tiff:exif-properties");
- if ((option == (const char *) NULL) ||
- (IsMagickTrue(option) != MagickFalse))
+ if (IfTrue(IsStringNotFalse(option))) /* enabled by default */
TIFFGetEXIFProperties(tiff,image,exception);
/*
Allocate memory for the image and pixel buffer.
diff --git a/coders/x.c b/coders/x.c
index 7294f6a..8e6e601 100644
--- a/coders/x.c
+++ b/coders/x.c
@@ -96,20 +96,13 @@
*/
static Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
- const char
- *option;
-
XImportInfo
ximage_info;
(void) exception;
XGetImportInfo(&ximage_info);
- option=GetImageOption(image_info,"x:screen");
- if (option != (const char *) NULL)
- ximage_info.screen=IsMagickTrue(option);
- option=GetImageOption(image_info,"x:silent");
- if (option != (const char *) NULL)
- ximage_info.silent=IsMagickTrue(option);
+ ximage_info.screen=IsStringTrue(GetImageOption(image_info,"x:screen"));
+ ximage_info.silent=IsStringTrue(GetImageOption(image_info,"x:silent"));
return(XImportImage(image_info,&ximage_info,exception));
}
#endif