Run Nindent on com32/lib/math/strtod.c
authorH. Peter Anvin <hpa@zytor.com>
Fri, 29 May 2009 22:10:23 +0000 (15:10 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 29 May 2009 22:10:23 +0000 (15:10 -0700)
Automatically reformat com32/lib/math/strtod.c using Nindent.

Do this for all files except HDT, gPXE and externally maintained
libraries (zlib, tinyjpeg, libpng).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/lib/math/strtod.c

index f4e35ac..f99531a 100644 (file)
 
 static inline int is_real(double x)
 {
-  const double Inf = 1.0/0.0;
-  return (x < Inf) && (x >= -Inf);
+    const double Inf = 1.0 / 0.0;
+    return (x < Inf) && (x >= -Inf);
 }
 
 double strtod(const char *str, char **endptr)
 {
-  double number;
-  int exponent;
-  int negative;
-  char *p = (char *) str;
-  double p10;
-  int n;
-  int num_digits;
-  int num_decimals;
-  const double Inf = 1.0/0.0;
-
-  // Skip leading whitespace
-  while (isspace(*p)) p++;
-
-  // Handle optional sign
-  negative = 0;
-  switch (*p)
-  {
-    case '-': negative = 1; // Fall through to increment position
-    case '+': p++;
-  }
-
-  number = 0.;
-  exponent = 0;
-  num_digits = 0;
-  num_decimals = 0;
-
-  // Process string of digits
-  while (isdigit(*p))
-  {
-    number = number * 10. + (*p - '0');
-    p++;
-    num_digits++;
-  }
-
-  // Process decimal part
-  if (*p == '.')
-  {
-    p++;
-
-    while (isdigit(*p))
-    {
-      number = number * 10. + (*p - '0');
-      p++;
-      num_digits++;
-      num_decimals++;
-    }
-
-    exponent -= num_decimals;
-  }
-
-  if (num_digits == 0)
-  {
-    errno = ERANGE;
-    return 0.0;
-  }
-
-  // Correct for sign
-  if (negative) number = -number;
+    double number;
+    int exponent;
+    int negative;
+    char *p = (char *)str;
+    double p10;
+    int n;
+    int num_digits;
+    int num_decimals;
+    const double Inf = 1.0 / 0.0;
+
+    // Skip leading whitespace
+    while (isspace(*p))
+       p++;
 
-  // Process an exponent string
-  if (*p == 'e' || *p == 'E')
-  {
     // Handle optional sign
     negative = 0;
-    switch(*++p)
-    {
-      case '-': negative = 1;   // Fall through to increment pos
-      case '+': p++;
+    switch (*p) {
+    case '-':
+       negative = 1;           // Fall through to increment position
+    case '+':
+       p++;
     }
 
+    number = 0.;
+    exponent = 0;
+    num_digits = 0;
+    num_decimals = 0;
+
     // Process string of digits
-    n = 0;
-    while (isdigit(*p))
-    {
-      n = n * 10 + (*p - '0');
-      p++;
+    while (isdigit(*p)) {
+       number = number * 10. + (*p - '0');
+       p++;
+       num_digits++;
     }
 
+    // Process decimal part
+    if (*p == '.') {
+       p++;
+
+       while (isdigit(*p)) {
+           number = number * 10. + (*p - '0');
+           p++;
+           num_digits++;
+           num_decimals++;
+       }
+
+       exponent -= num_decimals;
+    }
+
+    if (num_digits == 0) {
+       errno = ERANGE;
+       return 0.0;
+    }
+    // Correct for sign
     if (negative)
-      exponent -= n;
-    else
-      exponent += n;
-  }
-
-  if (exponent < __DBL_MIN_EXP__  ||
-      exponent > __DBL_MAX_EXP__)
-  {
-    errno = ERANGE;
-    return Inf;
-  }
-
-  // Scale the result
-  p10 = 10.;
-  n = exponent;
-  if (n < 0) n = -n;
-  while (n)
-  {
-    if (n & 1)
-    {
-      if (exponent < 0)
-        number /= p10;
-      else
-        number *= p10;
+       number = -number;
+
+    // Process an exponent string
+    if (*p == 'e' || *p == 'E') {
+       // Handle optional sign
+       negative = 0;
+       switch (*++p) {
+       case '-':
+           negative = 1;       // Fall through to increment pos
+       case '+':
+           p++;
+       }
+
+       // Process string of digits
+       n = 0;
+       while (isdigit(*p)) {
+           n = n * 10 + (*p - '0');
+           p++;
+       }
+
+       if (negative)
+           exponent -= n;
+       else
+           exponent += n;
+    }
+
+    if (exponent < __DBL_MIN_EXP__ || exponent > __DBL_MAX_EXP__) {
+       errno = ERANGE;
+       return Inf;
+    }
+    // Scale the result
+    p10 = 10.;
+    n = exponent;
+    if (n < 0)
+       n = -n;
+    while (n) {
+       if (n & 1) {
+           if (exponent < 0)
+               number /= p10;
+           else
+               number *= p10;
+       }
+       n >>= 1;
+       p10 *= p10;
     }
-    n >>= 1;
-    p10 *= p10;
-  }
 
-  if (!is_real(number)) errno = ERANGE;
-  if (endptr) *endptr = p;
+    if (!is_real(number))
+       errno = ERANGE;
+    if (endptr)
+       *endptr = p;
 
-  return number;
+    return number;
 }