FxEvaluateSubexpression(FxInfo *,const PixelChannel,const ssize_t,
const ssize_t,const char *,const size_t,double *,ExceptionInfo *);
+static inline MagickBooleanType IsFxFunction(const char *expression,
+ const char *name,const size_t length)
+{
+ int
+ c;
+
+ c=name[length];
+ if ((LocaleNCompare(expression,name,length) == 0) &&
+ ((isspace(c) == 0) || (c == '(')))
+ return(MagickTrue);
+ return(MagickFalse);
+}
+
static MagickOffsetType FxGCD(MagickOffsetType alpha,MagickOffsetType beta)
{
if (beta != 0)
case 'C':
case 'c':
{
- if (LocaleNCompare(symbol,"channel",7) == 0)
+ if (IsFxFunction(symbol,"channel",7) != MagickFalse)
{
GeometryInfo
channel_info;
case 'a':
{
#if defined(MAGICKCORE_HAVE_ACOSH)
- if (LocaleNCompare(expression,"acosh",5) == 0)
+ if (IsFxFunction(expression,"acosh",5) != MagickFalse)
{
expression+=5;
break;
}
#endif
#if defined(MAGICKCORE_HAVE_ASINH)
- if (LocaleNCompare(expression,"asinh",5) == 0)
+ if (IsFxFunction(expression,"asinh",5) != MagickFalse)
{
expression+=5;
break;
}
#endif
#if defined(MAGICKCORE_HAVE_ATANH)
- if (LocaleNCompare(expression,"atanh",5) == 0)
+ if (IsFxFunction(expression,"atanh",5) != MagickFalse)
{
expression+=5;
break;
}
#endif
- if (LocaleNCompare(expression,"atan2",5) == 0)
+ if (IsFxFunction(expression,"atan2",5) != MagickFalse)
{
expression+=5;
break;
case 'J':
case 'j':
{
- if ((LocaleNCompare(expression,"j0",2) == 0) ||
- (LocaleNCompare(expression,"j1",2) == 0))
+ if ((IsFxFunction(expression,"j0",2) != MagickFalse) ||
+ (IsFxFunction(expression,"j1",2) != MagickFalse))
{
expression+=2;
break;
case 'A':
case 'a':
{
- if (LocaleNCompare(expression,"abs",3) == 0)
+ if (IsFxFunction(expression,"abs",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(fabs(alpha));
}
#if defined(MAGICKCORE_HAVE_ACOSH)
- if (LocaleNCompare(expression,"acosh",5) == 0)
+ if (IsFxFunction(expression,"acosh",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
FxReturn(acosh(alpha));
}
#endif
- if (LocaleNCompare(expression,"acos",4) == 0)
+ if (IsFxFunction(expression,"acos",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(acos(alpha));
}
#if defined(MAGICKCORE_HAVE_J1)
- if (LocaleNCompare(expression,"airy",4) == 0)
+ if (IsFxFunction(expression,"airy",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
}
#endif
#if defined(MAGICKCORE_HAVE_ASINH)
- if (LocaleNCompare(expression,"asinh",5) == 0)
+ if (IsFxFunction(expression,"asinh",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
FxReturn(asinh(alpha));
}
#endif
- if (LocaleNCompare(expression,"asin",4) == 0)
+ if (IsFxFunction(expression,"asin",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(asin(alpha));
}
- if (LocaleNCompare(expression,"alt",3) == 0)
+ if (IsFxFunction(expression,"alt",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(((ssize_t) alpha) & 0x01 ? -1.0 : 1.0);
}
- if (LocaleNCompare(expression,"atan2",5) == 0)
+ if (IsFxFunction(expression,"atan2",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
FxReturn(atan2(alpha,*beta));
}
#if defined(MAGICKCORE_HAVE_ATANH)
- if (LocaleNCompare(expression,"atanh",5) == 0)
+ if (IsFxFunction(expression,"atanh",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
FxReturn(atanh(alpha));
}
#endif
- if (LocaleNCompare(expression,"atan",4) == 0)
+ if (IsFxFunction(expression,"atan",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
case 'C':
case 'c':
{
- if (LocaleNCompare(expression,"ceil",4) == 0)
+ if (IsFxFunction(expression,"ceil",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(ceil(alpha));
}
- if (LocaleNCompare(expression,"clamp",5) == 0)
+ if (IsFxFunction(expression,"clamp",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
FxReturn(1.0);
FxReturn(alpha);
}
- if (LocaleNCompare(expression,"cosh",4) == 0)
+ if (IsFxFunction(expression,"cosh",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(cosh(alpha));
}
- if (LocaleNCompare(expression,"cos",3) == 0)
+ if (IsFxFunction(expression,"cos",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
case 'D':
case 'd':
{
- if (LocaleNCompare(expression,"debug",5) == 0)
+ if (IsFxFunction(expression,"debug",5) != MagickFalse)
{
const char
*type;
subexpression,GetMagickPrecision(),alpha);
FxReturn(0.0);
}
- if (LocaleNCompare(expression,"drc",3) == 0)
+ if (IsFxFunction(expression,"drc",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
if (LocaleCompare(expression,"epsilon") == 0)
FxReturn(MagickEpsilon);
#if defined(MAGICKCORE_HAVE_ERF)
- if (LocaleNCompare(expression,"erf",3) == 0)
+ if (IsFxFunction(expression,"erf",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(erf(alpha));
}
#endif
- if (LocaleNCompare(expression,"exp",3) == 0)
+ if (IsFxFunction(expression,"exp",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
case 'F':
case 'f':
{
- if (LocaleNCompare(expression,"floor",5) == 0)
+ if (IsFxFunction(expression,"floor",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
case 'G':
case 'g':
{
- if (LocaleNCompare(expression,"gauss",5) == 0)
+ if (IsFxFunction(expression,"gauss",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
gamma=exp((-alpha*alpha/2.0))/sqrt(2.0*MagickPI);
FxReturn(gamma);
}
- if (LocaleNCompare(expression,"gcd",3) == 0)
+ if (IsFxFunction(expression,"gcd",3) != MagickFalse)
{
MagickOffsetType
gcd;
FxReturn(FxGetSymbol(fx_info,channel,x,y,expression,depth+1,exception));
if (LocaleCompare(expression,"hue") == 0)
FxReturn(FxGetSymbol(fx_info,channel,x,y,expression,depth+1,exception));
- if (LocaleNCompare(expression,"hypot",5) == 0)
+ if (IsFxFunction(expression,"hypot",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
{
if (LocaleCompare(expression,"intensity") == 0)
FxReturn(FxGetSymbol(fx_info,channel,x,y,expression,depth+1,exception));
- if (LocaleNCompare(expression,"int",3) == 0)
+ if (IsFxFunction(expression,"int",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(floor(alpha));
}
- if (LocaleNCompare(expression,"isnan",5) == 0)
+ if (IsFxFunction(expression,"isnan",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
if (LocaleCompare(expression,"j") == 0)
FxReturn(FxGetSymbol(fx_info,channel,x,y,expression,depth+1,exception));
#if defined(MAGICKCORE_HAVE_J0)
- if (LocaleNCompare(expression,"j0",2) == 0)
+ if (IsFxFunction(expression,"j0",2) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,
depth+1,beta,exception);
}
#endif
#if defined(MAGICKCORE_HAVE_J1)
- if (LocaleNCompare(expression,"j1",2) == 0)
+ if (IsFxFunction(expression,"j1",2) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,
depth+1,beta,exception);
}
#endif
#if defined(MAGICKCORE_HAVE_J1)
- if (LocaleNCompare(expression,"jinc",4) == 0)
+ if (IsFxFunction(expression,"jinc",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
case 'L':
case 'l':
{
- if (LocaleNCompare(expression,"ln",2) == 0)
+ if (IsFxFunction(expression,"ln",2) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,
depth+1,beta,exception);
FxReturn(log(alpha));
}
- if (LocaleNCompare(expression,"logtwo",6) == 0)
+ if (IsFxFunction(expression,"logtwo",6) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,
depth+1,beta,exception);
FxReturn(log10(alpha)/log10(2.0));
}
- if (LocaleNCompare(expression,"log",3) == 0)
+ if (IsFxFunction(expression,"log",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(QuantumRange);
if (LocaleNCompare(expression,"maxima",6) == 0)
break;
- if (LocaleNCompare(expression,"max",3) == 0)
+ if (IsFxFunction(expression,"max",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
}
if (LocaleNCompare(expression,"minima",6) == 0)
break;
- if (LocaleNCompare(expression,"min",3) == 0)
+ if (IsFxFunction(expression,"min",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(alpha < *beta ? alpha : *beta);
}
- if (LocaleNCompare(expression,"mod",3) == 0)
+ if (IsFxFunction(expression,"mod",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
case 'N':
case 'n':
{
- if (LocaleNCompare(expression,"not",3) == 0)
+ if (IsFxFunction(expression,"not",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(MagickPHI);
if (LocaleCompare(expression,"pi") == 0)
FxReturn(MagickPI);
- if (LocaleNCompare(expression,"pow",3) == 0)
+ if (IsFxFunction(expression,"pow",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
case 'R':
case 'r':
{
- if (LocaleNCompare(expression,"rand",4) == 0)
+ if (IsFxFunction(expression,"rand",4) != MagickFalse)
{
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp critical (MagickCore_FxEvaluateSubexpression)
alpha=GetPseudoRandomValue(fx_info->random_info);
FxReturn(alpha);
}
- if (LocaleNCompare(expression,"round",5) == 0)
+ if (IsFxFunction(expression,"round",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
{
if (LocaleCompare(expression,"saturation") == 0)
FxReturn(FxGetSymbol(fx_info,channel,x,y,expression,depth+1,exception));
- if (LocaleNCompare(expression,"sign",4) == 0)
+ if (IsFxFunction(expression,"sign",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(alpha < 0.0 ? -1.0 : 1.0);
}
- if (LocaleNCompare(expression,"sinc",4) == 0)
+ if (IsFxFunction(expression,"sinc",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
gamma=sin((MagickPI*alpha))/(MagickPI*alpha);
FxReturn(gamma);
}
- if (LocaleNCompare(expression,"sinh",4) == 0)
+ if (IsFxFunction(expression,"sinh",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(sinh(alpha));
}
- if (LocaleNCompare(expression,"sin",3) == 0)
+ if (IsFxFunction(expression,"sin",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
FxReturn(sin(alpha));
}
- if (LocaleNCompare(expression,"sqrt",4) == 0)
+ if (IsFxFunction(expression,"sqrt",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(sqrt(alpha));
}
- if (LocaleNCompare(expression,"squish",6) == 0)
+ if (IsFxFunction(expression,"squish",6) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,
depth+1,beta,exception);
case 'T':
case 't':
{
- if (LocaleNCompare(expression,"tanh",4) == 0)
+ if (IsFxFunction(expression,"tanh",4) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,
depth+1,beta,exception);
FxReturn(tanh(alpha));
}
- if (LocaleNCompare(expression,"tan",3) == 0)
+ if (IsFxFunction(expression,"tan",3) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,
depth+1,beta,exception);
}
if (LocaleCompare(expression,"Transparent") == 0)
FxReturn(0.0);
- if (LocaleNCompare(expression,"trunc",5) == 0)
+ if (IsFxFunction(expression,"trunc",5) != MagickFalse)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
depth+1,beta,exception);
case 'W':
case 'w':
{
- if (LocaleNCompare(expression,"while(",6) == 0)
+ if (IsFxFunction(expression,"while",5) != MagickFalse)
{
do
{