]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Mon, 17 Apr 2017 00:12:19 +0000 (20:12 -0400)
committerCristy <urban-warrior@imagemagick.org>
Mon, 17 Apr 2017 00:12:19 +0000 (20:12 -0400)
MagickCore/string.c

index 3693042c370c4a6f03360385fe6d309e8559db1c..d459844d2b4cb14cdcf3cbffb5ef368414b06fa3 100644 (file)
@@ -1083,6 +1083,10 @@ MagickExport ssize_t FormatMagickSize(const MagickSizeType size,
   const MagickBooleanType bi,const char *suffix,const size_t length,
   char *format)
 {
+  char
+    p[MagickPathExtent],
+    q[MagickPathExtent];
+
   const char
     **units;
 
@@ -1118,15 +1122,10 @@ MagickExport ssize_t FormatMagickSize(const MagickSizeType size,
 #else
   extent=(double) size;
 #endif
-  for (i=0; (extent >= bytes) && (units[i+1] != (const char *) NULL); i++)
-    extent/=bytes;
-  if (suffix == (const char *) NULL)
-    count=FormatLocaleString(format,length,"%.*g%s",GetMagickPrecision(),
-      extent,units[i]);
-  else
-    count=FormatLocaleString(format,length,"%.*g%s%s",GetMagickPrecision(),
-      extent,units[i],suffix);
-  if (fabs(pow(bytes,(double) i)*strtod(format,(char **) NULL)-size) < MagickEpsilon)
+  (void) FormatLocaleString(p,MagickPathExtent,"%.*g",GetMagickPrecision(),
+    extent);
+  (void) FormatLocaleString(q,MagickPathExtent,"%.20g",extent);
+  if (strtod(p,(char **) NULL) == strtod(q,(char **) NULL))
     {
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
       extent=(double) ((MagickOffsetType) size);
@@ -1138,7 +1137,16 @@ MagickExport ssize_t FormatMagickSize(const MagickSizeType size,
       else
         count=FormatLocaleString(format,length,"%.20g%s%s",extent,units[0],
           suffix);
+      return(count);
     }
+  for (i=0; (extent >= bytes) && (units[i+1] != (const char *) NULL); i++)
+    extent/=bytes;
+  if (suffix == (const char *) NULL)
+    count=FormatLocaleString(format,length,"%.*g%s",GetMagickPrecision(),
+      extent,units[i]);
+  else
+    count=FormatLocaleString(format,length,"%.*g%s%s",GetMagickPrecision(),
+      extent,units[i],suffix);
   return(count);
 }
 \f
@@ -1203,7 +1211,7 @@ MagickExport ssize_t FormatMagickTime(const time_t time,const size_t length,
   (void) gmtime_r(&time,&gm_time);
 #else
   {
-    struct tm
+        a[MaxTstruct tm
       *my_time;
 
     my_time=gmtime(&time);