]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StdLib: Fix printf issues with floating point and wide character strings. Also resol...
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Mar 2013 18:00:30 +0000 (18:00 +0000)
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Mar 2013 18:00:30 +0000 (18:00 +0000)
ISSUES.txt:  Added issue 11, updated status of issue 1.

gdtoa/gdtoaimp.h:  Fix definition of union U.

Locale/_wcstod.h:  Return 0.0 instead of 0 in the "no_convert" case.

Locale/multibyte_Utf8.c:  In wcsrtombs(), if both the destination pointer is NULL and the size, Limit, is 0; return the estimated length of the converted string up to ASCII_STRING_MAX bytes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: daryl.mcdaniel@intel.com
Reviewed-by: Aniruddha_Herekar@Dell.com
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14171 6f19259b-4bc3-4df7-8a09-765794883524

StdLib/ISSUES.txt
StdLib/LibC/Locale/_wcstod.h
StdLib/LibC/Locale/multibyte_Utf8.c
StdLib/LibC/gdtoa/gdtoaimp.h

index f2b695e473ad4650cc9ff41b1a6e06b86613f7a3..25317f7a68a33e4a571ff7f5046e2b516d2cf9f3 100644 (file)
@@ -14,16 +14,17 @@ StdLib Issues
 =============\r
       Category                             TOOLs       Reported       Status\r
     ------------------------              --------  --------------  -----------\r
-1:  Compilation Error                      vs2010             2012  Understood\r
+1:  Compilation Error                      vs2010             2012  Fixed 3/2013\r
     stdlib\libc\gdtoa\strtod.c(825) : warning C4789: destination of memory copy is too small\r
+    runtime crashes when using floating-point formats with printf\r
 \r
 2:  Compilation Error                       ALL               2012  Fixed 1/2012\r
     StdLib/LibC/Uefi/SysCalls.c: In function 'utimes': error: 'va_start' used in function with fixed args\r
 \r
-3:  Usage Clarification                                       2012  Understood/Document\r
+3:  Usage Clarification                                       2012  Document\r
     Clarify that the current StdLib may not be used for developing drivers.\r
 \r
-4:  Execution/Compile errors                                  2012  Understood\r
+4:  Execution/Compile errors                                  2012  Fixed 1/2013\r
     Mismatch in use of EFIAPI between declaration and definition of some functions.\r
 \r
 5:  Error message Quality during execution                    2012  Verified\r
@@ -48,6 +49,9 @@ StdLib Issues
     If the Shell does not have a current volume or directory, file operations\r
     may hang or fail.\r
 \r
+11: printf("-%ls-", L"test") will only print "--"             2013  Fixed 3/2013\r
+\r
+\r
 PosixLib\r
 =============\r
       Category                             TOOLs       Reported       Status\r
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
index 36e2cb379e72b4ed8e5f60b70e9f8c1b0ba9ed47..ec9b01265896850a86d09318dc4a17fdb18d1e05 100644 (file)
@@ -14,6 +14,7 @@
 #include  <stdlib.h>\r
 #include  <wchar.h>\r
 #include  <sys/types.h>\r
+#include  <limits.h>\r
 \r
 typedef      int      ch_UCS4;\r
 \r
@@ -913,6 +914,9 @@ wcsrtombs(
     return (0);\r
 \r
   if (Dest == NULL) {\r
+    if(MaxBytes <= 0) {\r
+      MaxBytes = ASCII_STRING_MAX;\r
+    }\r
     NumStored = EstimateWtoM(*Src, MaxBytes, NULL);\r
   }\r
   else {\r
index 635a177544c6f2767cc502ff0343f68bc9c8ffca..3ba2cf8fbf51615d0396a307e4dc2a00e758630e 100644 (file)
@@ -283,8 +283,7 @@ extern "C" {
 Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined.\r
 #endif\r
 \r
-typedef union { double d; ULong L[2]; } U;\r
-//typedef union { double d; UINT32 L[2]; } U;\r
+typedef union { double d; UINT32 L[2]; } U;\r
 \r
 #ifdef YES_ALIAS\r
 #define dval(x) x\r