]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Locale/_wcstod.h
StdLib: Fix printf issues with floating point and wide character strings. Also resol...
[mirror_edk2.git] / StdLib / LibC / Locale / _wcstod.h
index 1e7c47f2c03dd61a499666d770b4b45a7913e985..4b0a833728715322ef8399f9c68dac7998b80f34 100644 (file)
@@ -34,9 +34,9 @@
  * function template for wcstof, wcstod, wcstold.\r
  *\r
  * parameters:\r
- *     _FUNCNAME    : function name\r
- *     _RETURN_TYPE : return type\r
- *     _STRTOD_FUNC : real conversion function\r
+ *  _FUNCNAME    : function name\r
+ *  _RETURN_TYPE : return type\r
+ *  _STRTOD_FUNC : real conversion function\r
  */\r
 #ifndef __WCSTOD_H_\r
 #define __WCSTOD_H_\r
 _RETURN_TYPE\r
 _FUNCNAME(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)\r
 {\r
-       const wchar_t *src, *start;\r
-       _RETURN_TYPE val;\r
-       char *buf, *end;\r
-       size_t bufsiz, len;\r
+  const wchar_t *src, *start;\r
+  _RETURN_TYPE val;\r
+  char *buf, *end;\r
+  size_t bufsiz, len;\r
 \r
-       _DIAGASSERT(nptr != NULL);\r
-       /* endptr may be null */\r
+  _DIAGASSERT(nptr != NULL);\r
+  /* endptr may be null */\r
 \r
-       src = nptr;\r
-       while (iswspace((wint_t)*src) != 0)\r
-               ++src;\r
-       if (*src == L'\0')\r
-               goto no_convert;\r
+  src = nptr;\r
+  while (iswspace((wint_t)*src) != 0)\r
+    ++src;\r
+  if (*src == L'\0')\r
+    goto no_convert;\r
 \r
-       /*\r
-        * Convert the supplied numeric wide char. string to multibyte.\r
-        *\r
-        * We could attempt to find the end of the numeric portion of the\r
-        * wide char. string to avoid converting unneeded characters but\r
-        * choose not to bother; optimising the uncommon case where\r
-        * the input string contains a lot of text after the number\r
-        * duplicates a lot of strto{f,d,ld}()'s functionality and\r
-        * slows down the most common cases.\r
-        */\r
-       start = src;\r
-       len = wcstombs(NULL, src, 0);\r
-       if (len == (size_t)-1)\r
-               /* errno = EILSEQ */\r
-               goto no_convert;\r
+  /*\r
+   * Convert the supplied numeric wide char. string to multibyte.\r
+   *\r
+   * We could attempt to find the end of the numeric portion of the\r
+   * wide char. string to avoid converting unneeded characters but\r
+   * choose not to bother; optimising the uncommon case where\r
+   * the input string contains a lot of text after the number\r
+   * duplicates a lot of strto{f,d,ld}()'s functionality and\r
+   * slows down the most common cases.\r
+   */\r
+  start = src;\r
+  len = wcstombs(NULL, src, 0);\r
+  if (len == (size_t)-1)\r
+    /* errno = EILSEQ */\r
+    goto no_convert;\r
 \r
-       _DIAGASSERT(len > 0);\r
+  _DIAGASSERT(len > 0);\r
 \r
-       bufsiz = len;\r
-       buf = (void *)malloc(bufsiz + 1);\r
-       if (buf == NULL)\r
-               /* errno = ENOMEM */\r
-               goto no_convert;\r
+  bufsiz = len;\r
+  buf = (void *)malloc(bufsiz + 1);\r
+  if (buf == NULL)\r
+    /* errno = ENOMEM */\r
+    goto no_convert;\r
 \r
-       len = wcstombs(buf, src, bufsiz + 1);\r
+  len = wcstombs(buf, src, bufsiz + 1);\r
 \r
-       _DIAGASSERT(len == bufsiz);\r
-       _DIAGASSERT(buf[len] == '\0');\r
+  _DIAGASSERT(len == bufsiz);\r
+  _DIAGASSERT(buf[len] == '\0');\r
 \r
-       /* Let strto{f,d,ld}() do most of the work for us. */\r
-       val = _STRTOD_FUNC(buf, &end);\r
-       if (buf == end) {\r
-               free(buf);\r
-               goto no_convert;\r
-       }\r
+  /* Let strto{f,d,ld}() do most of the work for us. */\r
+  val = _STRTOD_FUNC(buf, &end);\r
+  if (buf == end) {\r
+    free(buf);\r
+    goto no_convert;\r
+  }\r
 \r
-       /*\r
-        * We only know where the number ended in the _multibyte_\r
-        * representation of the string. If the caller wants to know\r
-        * where it ended, count multibyte characters to find the\r
-        * corresponding position in the wide char string.\r
-        */\r
-       if (endptr != NULL)\r
-               /* XXX Assume each wide char is one byte. */\r
-               *endptr = __UNCONST(start + (size_t)(end - buf));\r
+  /*\r
+   * We only know where the number ended in the _multibyte_\r
+   * representation of the string. If the caller wants to know\r
+   * where it ended, count multibyte characters to find the\r
+   * corresponding position in the wide char string.\r
+   */\r
+  if (endptr != NULL)\r
+    /* XXX Assume each wide char is one byte. */\r
+    *endptr = __UNCONST(start + (size_t)(end - buf));\r
 \r
-       free(buf);\r
+  free(buf);\r
 \r
-       return val;\r
+  return val;\r
 \r
 no_convert:\r
-       if (endptr != NULL)\r
-               *endptr = __UNCONST(nptr);\r
-       return 0;\r
+  if (endptr != NULL)\r
+    *endptr = __UNCONST(nptr);\r
+  return 0.0;\r
 }\r
 #endif /*__WCSTOD_H_*/\r