Piotr Caban : msvcrt: Use wcstod_l/ strtod_l in other functions that parses doubles.

Alexandre Julliard julliard at winehq.org
Mon Apr 26 13:59:28 CDT 2010


Module: wine
Branch: master
Commit: 6974abe0e67063b46dd30005d9b8b68257a376dd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6974abe0e67063b46dd30005d9b8b68257a376dd

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Mon Apr 26 12:33:49 2010 +0200

msvcrt: Use wcstod_l/strtod_l in other functions that parses doubles.

---

 dlls/msvcr80/msvcr80.spec |    8 ++--
 dlls/msvcr90/msvcr90.spec |    8 ++--
 dlls/msvcrt/msvcrt.spec   |    6 ++--
 dlls/msvcrt/string.c      |   24 +++++++++----
 dlls/msvcrt/wcs.c         |   79 ++++++++------------------------------------
 5 files changed, 42 insertions(+), 83 deletions(-)

diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index b8e89e4..65da427 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -289,7 +289,7 @@
 @ cdecl _assert(str str long) msvcrt._assert
 @ stub _atodbl
 @ stub _atodbl_l
-@ stub _atof_l
+@ cdecl _atof_l(str ptr) msvcrt._atof_l
 @ stub _atoflt
 @ stub _atoflt_l
 @ cdecl -ret64 _atoi64(str) msvcrt._atoi64
@@ -1105,7 +1105,7 @@
 @ cdecl _wcsrev(wstr) msvcrt._wcsrev
 @ cdecl _wcsset(wstr long) msvcrt._wcsset
 @ stub _wcsset_s
-@ stub _wcstod_l
+@ cdecl _wcstod_l(wstr ptr) msvcrt._wcstod_l
 @ stub _wcstoi64
 @ stub _wcstoi64_l
 @ stub _wcstol_l
@@ -1207,8 +1207,8 @@
 @ cdecl _wtempnam(wstr wstr) msvcrt._wtempnam
 @ stub _wtmpnam
 @ stub _wtmpnam_s
-@ stub _wtof
-@ stub _wtof_l
+@ cdecl _wtof(wstr) msvcrt._wtof
+@ cdecl _wtof_l(wstr ptr) msvcrt._wtof_l
 @ cdecl _wtoi(wstr) msvcrt._wtoi
 @ cdecl _wtoi64(wstr) msvcrt._wtoi64
 @ stub _wtoi64_l
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 141592d..b7884dc 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -281,7 +281,7 @@
 @ cdecl _assert(str str long) msvcrt._assert
 @ stub _atodbl
 @ stub _atodbl_l
-@ stub _atof_l
+@ cdecl _atof_l(str ptr) msvcrt._atof_l
 @ stub _atoflt
 @ stub _atoflt_l
 @ cdecl -ret64 _atoi64(str) msvcrt._atoi64
@@ -1092,7 +1092,7 @@
 @ cdecl _wcsrev(wstr) msvcrt._wcsrev
 @ cdecl _wcsset(wstr long) msvcrt._wcsset
 @ stub _wcsset_s
-@ stub _wcstod_l
+@ cdecl _wcstod_l(wstr ptr) msvcrt._wcstod_l
 @ stub _wcstoi64
 @ stub _wcstoi64_l
 @ stub _wcstol_l
@@ -1191,8 +1191,8 @@
 @ cdecl _wtempnam(wstr wstr) msvcrt._wtempnam
 @ stub _wtmpnam
 @ stub _wtmpnam_s
-@ stub _wtof
-@ stub _wtof_l
+@ cdecl _wtof(wstr) msvcrt._wtof
+@ cdecl _wtof_l(wstr ptr) msvcrt._wtof_l
 @ cdecl _wtoi(wstr) msvcrt._wtoi
 @ cdecl _wtoi64(wstr) msvcrt._wtoi64
 @ stub _wtoi64_l
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 81e07a7..0680375 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -264,7 +264,7 @@
 @ cdecl _assert(str str long) MSVCRT__assert
 @ stub _atodbl #(ptr str)
 # stub _atodbl_l
-# stub _atof_l
+@ cdecl _atof_l(str ptr) MSVCRT__atof_l
 # stub _atoflt_l
 @ cdecl -ret64 _atoi64(str) ntdll._atoi64
 # stub _atoi64_l
@@ -1136,8 +1136,8 @@
 # stub _wtempnam_dbg
 @ stub _wtmpnam #(ptr)
 # stub _wtmpnam_s
-# stub _wtof
-# stub _wtof_l
+@ cdecl _wtof(wstr) MSVCRT__wtof
+@ cdecl _wtof_l(wstr ptr) MSVCRT__wtof_l
 @ cdecl _wtoi(wstr) ntdll._wtoi
 @ cdecl _wtoi64(wstr) ntdll._wtoi64
 # stub _wtoi64_l
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 6829e25..d99c508 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -132,14 +132,6 @@ void CDECL MSVCRT__swab(char* src, char* dst, int len)
 }
 
 /*********************************************************************
- *		atof  (MSVCRT.@)
- */
-double CDECL MSVCRT_atof( const char *str )
-{
-    return atof( str );
-}
-
-/*********************************************************************
  *		strtod_l  (MSVCRT.@)
  */
 double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t locale)
@@ -253,6 +245,22 @@ double CDECL MSVCRT_strtod( const char *str, char **end )
 }
 
 /*********************************************************************
+ *		atof  (MSVCRT.@)
+ */
+double CDECL MSVCRT_atof( const char *str )
+{
+    return MSVCRT_strtod_l(str, NULL, NULL);
+}
+
+/*********************************************************************
+ *		_atof_l  (MSVCRT.@)
+ */
+double CDECL MSVCRT__atof_l( const char *str, MSVCRT__locale_t locale)
+{
+    return MSVCRT_strtod_l(str, NULL, locale);
+}
+
+/*********************************************************************
  *		strcoll (MSVCRT.@)
  */
 int CDECL MSVCRT_strcoll( const char* str1, const char* str2 )
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index 94c638b..44a3b4d 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -231,73 +231,24 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
  */
 double CDECL MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end)
 {
-  const MSVCRT_wchar_t* str = lpszStr;
-  int negative = 0;
-  double ret = 0, divisor = 10.0;
-
-  TRACE("(%s,%p) semi-stub\n", debugstr_w(lpszStr), end);
-
-  /* FIXME:
-   * - Should set errno on failure
-   * - Should fail on overflow
-   * - Need to check which input formats are allowed
-   */
-  while (isspaceW(*str))
-    str++;
-
-  if (*str == '-')
-  {
-    negative = 1;
-    str++;
-  }
-
-  while (isdigitW(*str))
-  {
-    ret = ret * 10.0 + (*str - '0');
-    str++;
-  }
-  if (*str == '.')
-    str++;
-  while (isdigitW(*str))
-  {
-    ret = ret + (*str - '0') / divisor;
-    divisor *= 10;
-    str++;
-  }
-
-  if (*str == 'E' || *str == 'e' || *str == 'D' || *str == 'd')
-  {
-    int negativeExponent = 0;
-    int exponent = 0;
-    if (*(++str) == '-')
-    {
-      negativeExponent = 1;
-      str++;
-    }
-    while (isdigitW(*str))
-    {
-      exponent = exponent * 10 + (*str - '0');
-      str++;
-    }
-    if (exponent != 0)
-    {
-      if (negativeExponent)
-        ret = ret / pow(10.0, exponent);
-      else
-        ret = ret * pow(10.0, exponent);
-    }
-  }
-
-  if (negative)
-    ret = -ret;
-
-  if (end)
-    *end = (MSVCRT_wchar_t*)str;
+    return MSVCRT__wcstod_l(lpszStr, end, NULL);
+}
 
-  TRACE("returning %g\n", ret);
-  return ret;
+/*********************************************************************
+ *		_wtof (MSVCRT.@)
+ */
+double CDECL MSVCRT__wtof(const MSVCRT_wchar_t *str)
+{
+    return MSVCRT__wcstod_l(str, NULL, NULL);
 }
 
+/*********************************************************************
+ *		_wtof_l (MSVCRT.@)
+ */
+double CDECL MSVCRT__wtof_l(const MSVCRT_wchar_t *str, MSVCRT__locale_t locale)
+{
+    return MSVCRT__wcstod_l(str, NULL, locale);
+}
 
 typedef struct pf_output_t
 {




More information about the wine-cvs mailing list