コード例 #1
0
ファイル: strtod.cpp プロジェクト: ashmew2/kolibriosSVN
/**
 * Wrapper around strtof which uses the "C" locale so the decimal
 * point is always '.'
 */
float
_mesa_strtof(const char *s, char **end)
{
#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
   return strtof_l(s, end, loc_init.loc);
#elif defined(HAVE_STRTOF)
   return strtof(s, end);
#else
   return (float) strtod(s, end);
#endif
}
コード例 #2
0
float parseFloat(const char *&current, const char *end) {
    while (current != end && *current == ' ')
        current += 1;
    
    // Sadly can't pass length or end pointer into strtod_l (only get it out), so we have to do this dance to avoid any buffer overflows
    const char *tokenEnd = current;
    while (tokenEnd != end && *tokenEnd != ' ' && *tokenEnd != '\n' && *tokenEnd != '\r')
        tokenEnd += 1;
    
    size_t size = tokenEnd - current;
    char value[size+1];
    memcpy(value, current, size);
    value[size] = 0;
    current = tokenEnd;
    
    return strtof_l(value, nullptr, nullptr);
}
コード例 #3
0
ファイル: strtod.c プロジェクト: 0/julia
JL_DLLEXPORT float jl_strtof_c(const char *nptr, char **endptr)
{
  return strtof_l(nptr, endptr, get_c_locale());
}
コード例 #4
0
ファイル: strtof.c プロジェクト: 0mp/freebsd
strtof(CONST char *s, char **sp)
#endif
{
	return strtof_l(s, sp, __get_locale());
}
コード例 #5
0
ファイル: strtod.c プロジェクト: burrowsa/julia
float strtof_c(const char *nptr, char **endptr)
{
  return strtof_l(nptr, endptr, get_c_locale());
}
コード例 #6
0
ファイル: duration.c プロジェクト: allenway/onvif
int soap_s2xsd__duration(struct soap *soap, const char *s, LONG64 *a)
{ LONG64 sign = 1, Y = 0, M = 0, D = 0, H = 0, N = 0, S = 0;
  float f = 0;
  *a = 0;
  if (s)
  { if (*s == '-')
    { sign = -1;
      s++;
    }
    if (*s != 'P' && *s != 'p')
      return soap->error = SOAP_TYPE;
    s++;
    /* date part */
    while (s && *s)
    { char *r = NULL;
      LONG64 n;
      if (*s == 'T' || *s == 't')
      { s++;
	break;
      }
      n = soap_strtol(s, &r, 10);
      if (!r)
	return soap->error = SOAP_TYPE;
      s = r;
      switch (*s)
      { case 'Y':
        case 'y':
	  Y = n;
	  break;
	case 'M':
	case 'm':
	  M = n;
	  break;
	case 'D':
	case 'd':
	  D = n;
	  break;
	default:
	  return soap->error = SOAP_TYPE;
      }
      s++;
    }
    /* time part */
    while (s && *s)
    { char *r = NULL;
      LONG64 n;
      n = soap_strtol(s, &r, 10);
      if (!r)
	return soap->error = SOAP_TYPE;
      s = r;
      switch (*s)
      { case 'H':
        case 'h':
	  H = n;
	  break;
	case 'M':
	case 'm':
	  N = n;
	  break;
	case '.':
	  S = n;
#if defined(WITH_C_LOCALE) && defined(HAVE_STRTOD_L)
# ifdef WIN32
          f = (float)_strtod_l(s, NULL, SOAP_LOCALE(soap));
# else
          f = (float)strtod_l(s, NULL, SOAP_LOCALE(soap));
# endif
#elif defined(HAVE_STRTOD)
          f = (float)strtod(s, NULL);
#elif defined(WITH_C_LOCALE) && defined(HAVE_STRTOF_L)
          f = strtof_l((char*)s, NULL, SOAP_LOCALE(soap));
#elif defined(HAVE_STRTOF)
          f = strtof((char*)s, NULL);
#endif
	  s = NULL;
	  continue;
	case 'S':
	case 's':
	  S = n;
	  break;
	default:
	  return soap->error = SOAP_TYPE;
      }
      s++;
    }
    /* convert Y-M-D H:N:S.f to signed long long int milliseconds */
    *a = sign * ((((((((((((Y * 12) + M) * 30) + D) * 24) + H) * 60) + N) * 60) + S) * 1000) + (LONG64)(1000.0 * f + 0.5));
  }
  return soap->error;
}