]> granicus.if.org Git - imagemagick/commitdiff
Revert "cleanup identical conditions (#1339)" (#1340)
authorImageMagick <urban-warrior@users.noreply.github.com>
Sun, 7 Oct 2018 12:12:29 +0000 (08:12 -0400)
committerGitHub <noreply@github.com>
Sun, 7 Oct 2018 12:12:29 +0000 (08:12 -0400)
This reverts commit 192780734f3ab2b322f1add273dfe730ce15e04b.

MagickCore/nt-base.c
MagickCore/prepress.c
MagickCore/quantize.c
MagickCore/xml-tree.c
coders/dds.c

index ae34a86a76f09ae04488f045ddde0bfd7ea46b31..9edba4b3f64af70831ee032b5e5f78b70f890b5b 100644 (file)
@@ -1405,19 +1405,22 @@ MagickPrivate int NTGhostscriptEXE(char *path,int length)
       if (ghost_semaphore == (SemaphoreInfo *) NULL)
         ActivateSemaphoreInfo(&ghost_semaphore);
       LockSemaphoreInfo(ghost_semaphore);
-      if (NTGhostscriptGetString("GS_DLL",&is_64_bit_version,program,
-          sizeof(program)) == FALSE)
+      if (*program == '\0')
         {
-          UnlockSemaphoreInfo(ghost_semaphore);
-          return(FALSE);
-        }
-      p=strrchr(program,'\\');
-      if (p != (char *) NULL)
-        {
-          p++;
-          *p='\0';
-          (void) ConcatenateMagickString(program,is_64_bit_version ?
-            "gswin64c.exe" : "gswin32c.exe",sizeof(program));
+          if (NTGhostscriptGetString("GS_DLL",&is_64_bit_version,program,
+              sizeof(program)) == FALSE)
+            {
+              UnlockSemaphoreInfo(ghost_semaphore);
+              return(FALSE);
+            }
+          p=strrchr(program,'\\');
+          if (p != (char *) NULL)
+            {
+              p++;
+              *p='\0';
+              (void) ConcatenateMagickString(program,is_64_bit_version ?
+                "gswin64c.exe" : "gswin32c.exe",sizeof(program));
+            }
         }
       UnlockSemaphoreInfo(ghost_semaphore);
     }
index 50da1886b6255af258abf2329e413cc413fe6ca3..4b618090b7561b8fa7a795daf6d3e098eab5bbbb 100644 (file)
@@ -141,7 +141,8 @@ MagickExport double GetImageTotalInkDensity(Image *image,
         #pragma omp critical (MagickCore_GetImageTotalInkDensity)
 #endif
         {
-          total_ink_density=density;
+          if (density > total_ink_density)
+            total_ink_density=density;
         }
       p+=GetPixelChannels(image);
     }
index e37f0464568099faf150c5d8dc772c21e80b83af..dcb8cc9f528dc319900f0453025db2eeac974f65 100644 (file)
@@ -3384,14 +3384,17 @@ static MagickBooleanType SetGrayscaleImage(Image *image,
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
               #pragma omp critical (MagickCore_SetGrayscaleImage)
 #endif
-              colormap_index[intensity]=(ssize_t) image->colors;
-              image->colormap[image->colors].red=(double)
-                GetPixelRed(image,q);
-              image->colormap[image->colors].green=(double)
-                GetPixelGreen(image,q);
-              image->colormap[image->colors].blue=(double)
-                GetPixelBlue(image,q);
-              image->colors++;
+              if (colormap_index[intensity] < 0)
+                {
+                  colormap_index[intensity]=(ssize_t) image->colors;
+                  image->colormap[image->colors].red=(double)
+                    GetPixelRed(image,q);
+                  image->colormap[image->colors].green=(double)
+                    GetPixelGreen(image,q);
+                  image->colormap[image->colors].blue=(double)
+                    GetPixelBlue(image,q);
+                  image->colors++;
+               }
             }
           SetPixelIndex(image,(Quantum) colormap_index[intensity],q);
           q+=GetPixelChannels(image);
index a23b7228ba775b96da5f631bc586048ad6b68f6f..e9b4a8a08606b3b885c6d99866855360098ed24c 100644 (file)
@@ -451,7 +451,8 @@ static char **DestroyXMLTreeAttributes(char **attributes)
     /*
       Destroy attribute tag and value.
     */
-    attributes[i]=DestroyString(attributes[i]);
+    if (attributes[i] != (char *) NULL)
+      attributes[i]=DestroyString(attributes[i]);
     if (attributes[i+1] != (char *) NULL)
       attributes[i+1]=DestroyString(attributes[i+1]);
   }
@@ -526,7 +527,8 @@ static void DestroyXMLTreeRoot(XMLTreeInfo *xml_info)
       attributes[0]=DestroyString(attributes[0]);
     for (j=1; attributes[j] != (char *) NULL; j+=3)
     {
-      attributes[j]=DestroyString(attributes[j]);
+      if (attributes[j] != (char *) NULL)
+        attributes[j]=DestroyString(attributes[j]);
       if (attributes[j+1] != (char *) NULL)
         attributes[j+1]=DestroyString(attributes[j+1]);
       if (attributes[j+2] != (char *) NULL)
index 80f58320d4997aab508e6b2cc98081793d646eb1..d7e55d5d20c6cb3a21853a6888f3f7a4500ccd91 100644 (file)
@@ -1175,13 +1175,16 @@ static void CompressClusterFit(const size_t count,
               #pragma omp critical (DDS_CompressClusterFit)
 #endif
               {
-                VectorCopy43(a,start);
-                VectorCopy43(b,end);
-                bestError = error;
-                besti = i;
-                bestj = j;
-                bestk = k;
-                bestIteration = iterationIndex;
+                if (error < bestError)
+                  {
+                    VectorCopy43(a,start);
+                    VectorCopy43(b,end);
+                    bestError = error;
+                    besti = i;
+                    bestj = j;
+                    bestk = k;
+                    bestIteration = iterationIndex;
+                  }
               }
             }