On 2020-05-29 19:38, Martin Storsjö wrote:
On Fri, 29 May 2020, Steve Lhomme wrote:

On 2020-05-29 14:29, Martin Storsjö wrote:
On Fri, 29 May 2020, Steve Lhomme wrote:

On 2020-05-27 17:16, Martin Storsjö wrote:
On Wed, 27 May 2020, Steve Lhomme wrote:

__ms_vsnprintf is not available in ucrtbase/ucrt.

__stdio_common_vsprintf is available and can be used for the same call.
---
mingw-w64-headers/crt/stdio.h | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index d7beb27a..9c233efa 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -882,10 +882,6 @@ char * tmpnam(char * __dst)
#pragma push_macro("vsnprintf")
# undef snprintf
# undef vsnprintf
-  __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3) -  int __cdecl __ms_vsnprintf(char * __restrict__ d,size_t n,const char * __restrict__ format,va_list arg) -    __MINGW_ATTRIB_DEPRECATED_MSVC2005 __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-
  __mingw_bos_ovr
  __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)   int vsnprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, va_list __local_argv)
@@ -893,7 +889,10 @@ char * tmpnam(char * __dst)
#if __MINGW_FORTIFY_LEVEL > 0
    __mingw_bos_ptr_chk_warn(__stream, __n, 1);
#endif
-    return __ms_vsnprintf (__stream, __n, __format, __local_argv);
+    int __retval = __stdio_common_vsprintf(
+        _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, +                           __stream, __n, __format, NULL, __local_argv);
+    return __retval < 0 ? -1 : __retval;
  }

Uhm, what?

It isn't visible from the patch context, but as far as I can see when reading the header, this is in a !_UCRT context?

On line 858, there's "#ifdef _UCRT", matched with an #else on line 871, and then you have this code on lines 885-897 - in the non-UCRT case?

I totally agree with that. That's incorrect when _UCRT is used.

Can you rephrase this bit, I don't exactly understand what you mean.

On line 858, there's "#ifdef _UCRT"

We are in code used when _UCRT is defined.

No?

On line 871 there's the #else that matches the #ifdef on line 858, and your patch modifies line 882 and onwards.

Ah yes, I missed the else. The #endif has a mention of _UCRT but not the else (I tend to document conditions in each in general).

A quick note on how I ended up there. I built code linking with ucrt(base) without the define. And I ended up with missing references. After updating the code I still got this reference. Probably from code that hadn't been rebuilt.

I also use SciTE to quickly view source code and it can fold code, including #ifdef. Unfortunately when folding a #ifdef to see when the block ends, it also includes the #else part. That's why I missed it.

If i do a file that only contains #include <stdio.h> and preprocess it, with headers defaulting to UCRT mode, there's no mention of __ms_vsnprintf in the output.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to