[libcxx-commits] [libcxx] 1a5388c - [libcxx] [Windows] Use the standard vsnprintf instead of _vsnprintf

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 31 12:29:50 PST 2022


Author: Martin Storsjö
Date: 2022-01-31T22:29:12+02:00
New Revision: 1a5388ca67b03ca21043369f2023ffa0e9bc35dc

URL: https://github.com/llvm/llvm-project/commit/1a5388ca67b03ca21043369f2023ffa0e9bc35dc
DIFF: https://github.com/llvm/llvm-project/commit/1a5388ca67b03ca21043369f2023ffa0e9bc35dc.diff

LOG: [libcxx] [Windows] Use the standard vsnprintf instead of _vsnprintf

In ancient Microsoft C runtimes, there might only have been
a nonstandard `_vsnprintf` instead of the standard `vsnprintf`, but
in modern versions (the only ones relevant for libc++), both
are available.

In MinGW configurations built with `__USE_MINGW_ANSI_STDIO=1` (as it
is built in CI), `vsnprintf` provides a more standards compliant
behaviour than what Microsoft's CRT provides, while `_vsnprintf` retains
the Microsoft C runtime specific quirks.

Differential Revision: https://reviews.llvm.org/D118187

Added: 
    

Modified: 
    libcxx/src/support/win32/support.cpp
    libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/support/win32/support.cpp b/libcxx/src/support/win32/support.cpp
index 11702a788b10b..115d975bbf9a6 100644
--- a/libcxx/src/support/win32/support.cpp
+++ b/libcxx/src/support/win32/support.cpp
@@ -23,7 +23,7 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
     // Query the count required.
     va_list ap_copy;
     va_copy(ap_copy, ap);
-    int count = _vsnprintf( NULL, 0, format, ap_copy );
+    int count = vsnprintf( NULL, 0, format, ap_copy );
     va_end(ap_copy);
     if (count < 0)
         return count;
@@ -33,7 +33,7 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
         return -1;
     // If we haven't used exactly what was required, something is wrong.
     // Maybe bug in vsnprintf. Report the error and return.
-    if (_vsnprintf(p, buffer_size, format, ap) != count) {
+    if (vsnprintf(p, buffer_size, format, ap) != count) {
         free(p);
         return -1;
     }

diff  --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
index f0551b077d354..260fed10de595 100644
--- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
@@ -12,7 +12,10 @@
 
 // iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const;
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
+// FIXME: The printf functions in Microsoft's CRT have a couple quirks in
+// corner cases, failing this test.
+// XFAIL: msvc
+
 // XFAIL: LIBCXX-AIX-FIXME
 
 #include <locale>


        


More information about the libcxx-commits mailing list