]> granicus.if.org Git - imagemagick/blobdiff - coders/xpm.c
(no commit message)
[imagemagick] / coders / xpm.c
index 134f539c9f3f73c755f5bcbcfbfdca093d307c96..ba657c214efc7013e12e42cc7b152b1ac046c556 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -139,11 +139,11 @@ static MagickBooleanType IsXPM(const unsigned char *magick,const size_t length)
 */
 
 static int CompareXPMColor(const void *target,const void *source)
-{ 
+{
   const char
     *p,
     *q;
-  
   p=(const char *) target;
   q=(const char *) source;
   return(strcmp(p,q));
@@ -242,7 +242,6 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *indexes;
 
   register ssize_t
-    i,
     x;
 
   register PixelPacket
@@ -327,7 +326,6 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Remove unquoted characters.
   */
-  i=0;
   active=MagickFalse;
   q=xpm_buffer;
   while (*p != '\0')
@@ -352,7 +350,6 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read image colormap.
   */
-  i=1;
   next=NextXPMLine(xpm_buffer);
   for (j=0; (j < (ssize_t) image->colors) && (next != (char*) NULL); j++)
   {
@@ -384,7 +381,7 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         image->storage_class=DirectClass;
         image->matte=MagickTrue;
       }
-    status=QueryColorCompliance(target,XPMCompliance,&image->colormap[j],
+    status=QueryColorCompliance(target,AllCompliance,&image->colormap[j],
       exception);
     if (status == MagickFalse)
       break;
@@ -968,8 +965,10 @@ static MagickBooleanType WriteXPMImage(const ImageInfo *image_info,Image *image)
       (void) FormatMagickString(buffer,MaxTextExtent,"xpm_%s",basename);
       (void) CopyMagickString(basename,buffer,MaxTextExtent);
     }
-  for (i=0; basename[i] != '\0'; i++)
-    if (isalpha((int) ((unsigned char) basename[i])) == 0)
+  if (isalpha((int) ((unsigned char) basename[0])) == 0)
+    basename[0]='_';
+  for (i=1; basename[i] != '\0'; i++)
+    if (isalnum((int) ((unsigned char) basename[i])) == 0)
       basename[i]='_';
   (void) FormatMagickString(buffer,MaxTextExtent,
     "static char *%s[] = {\n",basename);