]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/string-private.h
(no commit message)
[imagemagick] / MagickCore / string-private.h
index 8d6d47b396089b4e3341fe8f6879513c9128e071..26116d979350cdbb66bad40f337350c3010d7727 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization
+  Copyright 1999-2012 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.
 extern "C" {
 #endif
 
-extern MagickPrivate char
-  *GetEnvironmentValue(const char *);
+#include <MagickCore/locale_.h>
 
-extern MagickPrivate ssize_t
-  FormatMagickSize(const MagickSizeType,const MagickBooleanType,char *);
+static inline double SiPrefixToDoubleInterval(const char *string,
+  const double interval)
+{
+  char
+    *q;
+
+  double
+    value;
+
+  value=InterpretSiPrefixValue(string,&q);
+  if (*q == '%')
+    value*=interval/100.0;
+  return(value);
+}
+
+static inline double StringToDouble(const char *restrict string,
+  char **restrict sentinal)
+{
+  return(InterpretLocaleValue(string,sentinal));
+}
 
-static inline double SiPrefixToDouble(const char *string,const double interval)
+static inline double StringToDoubleInterval(const char *string,
+  const double interval)
 {
   char
     *q;
 
   double
-    scale,
     value;
 
   value=InterpretLocaleValue(string,&q);
-  scale=1000.0;
-  if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
-    scale=1024.0;
-  switch (tolower((int) ((unsigned char) *q)))
-  {
-    case '%': value*=pow(scale,0)*interval/100.0; break;
-    case 'k': value*=pow(scale,1); break;
-    case 'm': value*=pow(scale,2); break;
-    case 'g': value*=pow(scale,3); break;
-    case 't': value*=pow(scale,4); break;
-    case 'p': value*=pow(scale,5); break;
-    case 'e': value*=pow(scale,6); break;
-    case 'z': value*=pow(scale,7); break;
-    case 'y': value*=pow(scale,8); break;
-    default:  break;
-  }
+  if (*q == '%')
+    value*=interval/100.0;
   return(value);
 }
 
-static inline int StringToInteger(const char *value)
+static inline int StringToInteger(const char *restrict value)
 {
   return((int) strtol(value,(char **) NULL,10));
 }
 
-static inline long StringToLong(const char *value)
+static inline long StringToLong(const char *restrict value)
 {
   return(strtol(value,(char **) NULL,10));
 }
 
-static inline unsigned long StringToUnsignedLong(const char *value)
+static inline unsigned long StringToUnsignedLong(const char *restrict value)
 {
   return(strtoul(value,(char **) NULL,10));
 }