From b7769d8c9eba7403488e297e36fd8ddd0aec5155 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 27 Jul 2019 21:55:06 -0400 Subject: [PATCH] Fix isalpha() --- MagickWand/mogrify.c | 72 +++++++++++++++++++++--------------------- MagickWand/operation.c | 14 ++++---- coders/svg.c | 2 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index f83bc5c62..655ae7304 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -514,8 +514,8 @@ static Image *SparseColorOption(const Image *image, while( *p != '\0' ) { (void) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == ',' ) continue; - if ( isalpha((int) token[0]) || token[0] == '#' ) { + if (*token == ',') continue; + if ( isalpha((int) ((unsigned char) *token)) || (*token == '#')) { if ( color_from_image ) { (void) ThrowMagickException(exception,GetMagickModule(), OptionError, "InvalidArgument", "'%s': %s", "sparse-color", @@ -560,9 +560,9 @@ static Image *SparseColorOption(const Image *image, x=0; while( *p != '\0' && x < number_arguments ) { /* X coordinate */ - token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' ) break; - if ( isalpha((int) token[0]) || token[0] == '#' ) { + *token=','; while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if (*token == '\0') break; + if ( isalpha((int) ((unsigned char) *token)) || (*token == '#')) { (void) ThrowMagickException(exception,GetMagickModule(), OptionError, "InvalidArgument", "'%s': %s", "sparse-color", "Color found, instead of X-coord"); @@ -571,9 +571,9 @@ static Image *SparseColorOption(const Image *image, } sparse_arguments[x++]=StringToDouble(token,(char **) NULL); /* Y coordinate */ - token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' ) break; - if ( isalpha((int) token[0]) || token[0] == '#' ) { + *token=','; while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if (*token == '\0') break; + if ( isalpha((int) ((unsigned char) *token)) || (*token == '#')) { (void) ThrowMagickException(exception,GetMagickModule(), OptionError, "InvalidArgument", "'%s': %s", "sparse-color", "Color found, instead of Y-coord"); @@ -591,9 +591,9 @@ static Image *SparseColorOption(const Image *image, #endif { /* color name or function given in string argument */ - token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' ) break; - if ( isalpha((int) token[0]) || token[0] == '#' ) { + *token=','; while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if (*token == '\0') break; + if ( isalpha((int) ((unsigned char) *token)) || (*token == '#')) { /* Color string given */ (void) QueryColorCompliance(token,AllCompliance,&color,exception); if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) @@ -614,45 +614,45 @@ static Image *SparseColorOption(const Image *image, /* NB: token contains the first floating point value to use! */ if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { - while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || (*token == '#')) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ + *token = ','; /* used this token - get another */ } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { - while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || (*token == '#')) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ + *token = ','; /* used this token - get another */ } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { - while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || (*token == '#')) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ + *token = ','; /* used this token - get another */ } if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && (image->colorspace == CMYKColorspace)) { - while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || (*token == '#')) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ + *token = ','; /* used this token - get another */ } if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && (image->alpha_trait != UndefinedPixelTrait)) { - while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token); - if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) + while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || (*token == '#')) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); - token[0] = ','; /* used this token - get another */ + *token = ','; /* used this token - get another */ } } } @@ -1999,23 +1999,23 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, p=(const char *) argv[i+1]; (void) GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */ - if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) - (void) QueryColorCompliance(token,AllCompliance, - &black_point,exception); + if ((isalpha((int) ((unsigned char) *token)) != 0) || ((*token == '#') != 0)) + (void) QueryColorCompliance(token,AllCompliance,&black_point, + exception); else - (void) QueryColorCompliance("#000000",AllCompliance, - &black_point,exception); - if (isalpha((int) token[0]) || (token[0] == '#')) + (void) QueryColorCompliance("#000000",AllCompliance,&black_point, + exception); + if (isalpha((int) ((unsigned char) *token)) || (*token == '#')) (void) GetNextToken(p,&p,MagickPathExtent,token); if (*token == '\0') white_point=black_point; /* set everything to that color */ else { - if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) + if ((isalpha((int) ((unsigned char) *token)) == 0) && ((*token == '#') == 0)) (void) GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */ - if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) - (void) QueryColorCompliance(token,AllCompliance, - &white_point,exception); + if ((isalpha((int) ((unsigned char) *token)) != 0) || ((*token == '#') != 0)) + (void) QueryColorCompliance(token,AllCompliance,&white_point, + exception); else (void) QueryColorCompliance("#ffffff",AllCompliance, &white_point,exception); diff --git a/MagickWand/operation.c b/MagickWand/operation.c index dc1343eb5..9817a218c 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -279,7 +279,7 @@ static Image *SparseColorOption(const Image *image, sparse_arguments[x++]=StringToDouble(token,(char **) NULL); /* Y coordinate */ *token=','; while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ( *token == '\0' ) break; + if (*token == '\0') break; if ( isalpha((int) ((unsigned char) *token)) || *token == '#' ) { (void) ThrowMagickException(exception,GetMagickModule(), OptionError, "InvalidArgument", "'%s': %s", "sparse-color", @@ -290,7 +290,7 @@ static Image *SparseColorOption(const Image *image, sparse_arguments[x++]=StringToDouble(token,(char **) NULL); /* color name or function given in string argument */ *token=','; while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ( *token == '\0' ) break; + if (*token == '\0') break; if ( isalpha((int) ((unsigned char) *token)) || *token == '#' ) { /* Color string given */ (void) QueryColorCompliance(token,AllCompliance,&color, @@ -314,7 +314,7 @@ static Image *SparseColorOption(const Image *image, if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ((*token == '\0') || isalpha((int)*token) || *token == '#' ) + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' ) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); *token=','; /* used this token - get another */ @@ -322,7 +322,7 @@ static Image *SparseColorOption(const Image *image, if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ((*token == '\0') || isalpha((int)*token) || *token == '#' ) + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' ) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); *token=','; /* used this token - get another */ @@ -330,7 +330,7 @@ static Image *SparseColorOption(const Image *image, if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ((*token == '\0') || isalpha((int)*token) || *token == '#' ) + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' ) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); *token = ','; /* used this token - get another */ @@ -339,7 +339,7 @@ static Image *SparseColorOption(const Image *image, (image->colorspace == CMYKColorspace)) { while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ((*token == '\0') || isalpha((int)*token) || *token == '#' ) + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' ) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); *token=','; /* used this token - get another */ @@ -348,7 +348,7 @@ static Image *SparseColorOption(const Image *image, image->alpha_trait != UndefinedPixelTrait) { while (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); - if ( *token == '\0' || isalpha((int)*token) || *token == '#' ) + if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' ) break; sparse_arguments[x++]=StringToDouble(token,(char **) NULL); *token = ','; /* used this token - get another */ diff --git a/coders/svg.c b/coders/svg.c index a0dd96464..606d9da6c 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -5097,7 +5097,7 @@ static MagickBooleanType WriteSVGImage(const ImageInfo *image_info,Image *image, (void) GetNextToken(q,&q,extent,token); number_attributes=1; for (p=token; *p != '\0'; p++) - if (isalpha((int) *p)) + if (isalpha((int) ((unsigned char) *p)) != 0) number_attributes++; if (i > (ssize_t) (number_points-6*BezierQuantum*number_attributes-1)) { -- 2.40.0