Revision: 14171
          http://edk2.svn.sourceforge.net/edk2/?rev=14171&view=rev
Author:   darylm503
Date:     2013-03-11 18:00:30 +0000 (Mon, 11 Mar 2013)
Log Message:
-----------
StdLib: Fix printf issues with floating point and wide character strings.  Also 
resolves a compilation issue with VS2010.  See ISSUES.txt items 1, 11.

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:  [email protected]
Reviewed-by:    [email protected]

Modified Paths:
--------------
    trunk/edk2/StdLib/ISSUES.txt
    trunk/edk2/StdLib/LibC/Locale/_wcstod.h
    trunk/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
    trunk/edk2/StdLib/LibC/gdtoa/gdtoaimp.h

Modified: trunk/edk2/StdLib/ISSUES.txt
===================================================================
--- trunk/edk2/StdLib/ISSUES.txt        2013-03-11 08:04:39 UTC (rev 14170)
+++ trunk/edk2/StdLib/ISSUES.txt        2013-03-11 18:00:30 UTC (rev 14171)
@@ -14,16 +14,17 @@
 =============
       Category                             TOOLs       Reported       Status
     ------------------------              --------  --------------  -----------
-1:  Compilation Error                      vs2010             2012  Understood
+1:  Compilation Error                      vs2010             2012  Fixed 
3/2013
     stdlib\libc\gdtoa\strtod.c(825) : warning C4789: destination of memory 
copy is too small
+    runtime crashes when using floating-point formats with printf
 
 2:  Compilation Error                       ALL               2012  Fixed 
1/2012
     StdLib/LibC/Uefi/SysCalls.c: In function 'utimes': error: 'va_start' used 
in function with fixed args
 
-3:  Usage Clarification                                       2012  
Understood/Document
+3:  Usage Clarification                                       2012  Document
     Clarify that the current StdLib may not be used for developing drivers.
 
-4:  Execution/Compile errors                                  2012  Understood
+4:  Execution/Compile errors                                  2012  Fixed 
1/2013
     Mismatch in use of EFIAPI between declaration and definition of some 
functions.
 
 5:  Error message Quality during execution                    2012  Verified
@@ -48,6 +49,9 @@
     If the Shell does not have a current volume or directory, file operations
     may hang or fail.
 
+11: printf("-%ls-", L"test") will only print "--"             2013  Fixed 
3/2013
+
+
 PosixLib
 =============
       Category                             TOOLs       Reported       Status

Modified: trunk/edk2/StdLib/LibC/Locale/_wcstod.h
===================================================================
--- trunk/edk2/StdLib/LibC/Locale/_wcstod.h     2013-03-11 08:04:39 UTC (rev 
14170)
+++ trunk/edk2/StdLib/LibC/Locale/_wcstod.h     2013-03-11 18:00:30 UTC (rev 
14171)
@@ -34,9 +34,9 @@
  * function template for wcstof, wcstod, wcstold.
  *
  * parameters:
- *     _FUNCNAME    : function name
- *     _RETURN_TYPE : return type
- *     _STRTOD_FUNC : real conversion function
+ *  _FUNCNAME    : function name
+ *  _RETURN_TYPE : return type
+ *  _STRTOD_FUNC : real conversion function
  */
 #ifndef __WCSTOD_H_
 #define __WCSTOD_H_
@@ -54,73 +54,73 @@
 _RETURN_TYPE
 _FUNCNAME(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
 {
-       const wchar_t *src, *start;
-       _RETURN_TYPE val;
-       char *buf, *end;
-       size_t bufsiz, len;
+  const wchar_t *src, *start;
+  _RETURN_TYPE val;
+  char *buf, *end;
+  size_t bufsiz, len;
 
-       _DIAGASSERT(nptr != NULL);
-       /* endptr may be null */
+  _DIAGASSERT(nptr != NULL);
+  /* endptr may be null */
 
-       src = nptr;
-       while (iswspace((wint_t)*src) != 0)
-               ++src;
-       if (*src == L'\0')
-               goto no_convert;
+  src = nptr;
+  while (iswspace((wint_t)*src) != 0)
+    ++src;
+  if (*src == L'\0')
+    goto no_convert;
 
-       /*
-        * Convert the supplied numeric wide char. string to multibyte.
-        *
-        * We could attempt to find the end of the numeric portion of the
-        * wide char. string to avoid converting unneeded characters but
-        * choose not to bother; optimising the uncommon case where
-        * the input string contains a lot of text after the number
-        * duplicates a lot of strto{f,d,ld}()'s functionality and
-        * slows down the most common cases.
-        */
-       start = src;
-       len = wcstombs(NULL, src, 0);
-       if (len == (size_t)-1)
-               /* errno = EILSEQ */
-               goto no_convert;
+  /*
+   * Convert the supplied numeric wide char. string to multibyte.
+   *
+   * We could attempt to find the end of the numeric portion of the
+   * wide char. string to avoid converting unneeded characters but
+   * choose not to bother; optimising the uncommon case where
+   * the input string contains a lot of text after the number
+   * duplicates a lot of strto{f,d,ld}()'s functionality and
+   * slows down the most common cases.
+   */
+  start = src;
+  len = wcstombs(NULL, src, 0);
+  if (len == (size_t)-1)
+    /* errno = EILSEQ */
+    goto no_convert;
 
-       _DIAGASSERT(len > 0);
+  _DIAGASSERT(len > 0);
 
-       bufsiz = len;
-       buf = (void *)malloc(bufsiz + 1);
-       if (buf == NULL)
-               /* errno = ENOMEM */
-               goto no_convert;
+  bufsiz = len;
+  buf = (void *)malloc(bufsiz + 1);
+  if (buf == NULL)
+    /* errno = ENOMEM */
+    goto no_convert;
 
-       len = wcstombs(buf, src, bufsiz + 1);
+  len = wcstombs(buf, src, bufsiz + 1);
 
-       _DIAGASSERT(len == bufsiz);
-       _DIAGASSERT(buf[len] == '\0');
+  _DIAGASSERT(len == bufsiz);
+  _DIAGASSERT(buf[len] == '\0');
 
-       /* Let strto{f,d,ld}() do most of the work for us. */
-       val = _STRTOD_FUNC(buf, &end);
-       if (buf == end) {
-               free(buf);
-               goto no_convert;
-       }
+  /* Let strto{f,d,ld}() do most of the work for us. */
+  val = _STRTOD_FUNC(buf, &end);
+  if (buf == end) {
+    free(buf);
+    goto no_convert;
+  }
 
-       /*
-        * We only know where the number ended in the _multibyte_
-        * representation of the string. If the caller wants to know
-        * where it ended, count multibyte characters to find the
-        * corresponding position in the wide char string.
-        */
-       if (endptr != NULL)
-               /* XXX Assume each wide char is one byte. */
-               *endptr = __UNCONST(start + (size_t)(end - buf));
+  /*
+   * We only know where the number ended in the _multibyte_
+   * representation of the string. If the caller wants to know
+   * where it ended, count multibyte characters to find the
+   * corresponding position in the wide char string.
+   */
+  if (endptr != NULL)
+    /* XXX Assume each wide char is one byte. */
+    *endptr = __UNCONST(start + (size_t)(end - buf));
 
-       free(buf);
+  free(buf);
 
-       return val;
+  return val;
 
 no_convert:
-       if (endptr != NULL)
-               *endptr = __UNCONST(nptr);
-       return 0;
+  if (endptr != NULL)
+    *endptr = __UNCONST(nptr);
+  return 0.0;
 }
 #endif /*__WCSTOD_H_*/

Modified: trunk/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
===================================================================
--- trunk/edk2/StdLib/LibC/Locale/multibyte_Utf8.c      2013-03-11 08:04:39 UTC 
(rev 14170)
+++ trunk/edk2/StdLib/LibC/Locale/multibyte_Utf8.c      2013-03-11 18:00:30 UTC 
(rev 14171)
@@ -14,6 +14,7 @@
 #include  <stdlib.h>
 #include  <wchar.h>
 #include  <sys/types.h>
+#include  <limits.h>
 
 typedef      int      ch_UCS4;
 
@@ -913,6 +914,9 @@
     return (0);
 
   if (Dest == NULL) {
+    if(MaxBytes <= 0) {
+      MaxBytes = ASCII_STRING_MAX;
+    }
     NumStored = EstimateWtoM(*Src, MaxBytes, NULL);
   }
   else {

Modified: trunk/edk2/StdLib/LibC/gdtoa/gdtoaimp.h
===================================================================
--- trunk/edk2/StdLib/LibC/gdtoa/gdtoaimp.h     2013-03-11 08:04:39 UTC (rev 
14170)
+++ trunk/edk2/StdLib/LibC/gdtoa/gdtoaimp.h     2013-03-11 18:00:30 UTC (rev 
14171)
@@ -283,8 +283,7 @@
 Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be 
defined.
 #endif
 
-typedef union { double d; ULong L[2]; } U;
-//typedef union { double d; UINT32 L[2]; } U;
+typedef union { double d; UINT32 L[2]; } U;
 
 #ifdef YES_ALIAS
 #define dval(x) x

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to