This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #133510) can't use my_vsnprintf() on quadmath/threaded builds
authorTony Cook <tony@develop-help.com>
Thu, 13 Sep 2018 01:45:14 +0000 (11:45 +1000)
committerJames E Keenan <jkeenan@cpan.org>
Thu, 13 Sep 2018 01:53:18 +0000 (21:53 -0400)
Since anything with quadmath should be recent enough to have
vsnprintf() I've fallen back to that.

Calls to PerlIO_debug() in core don't include floating point values
and I expect it to be unlikely outside of core - if it is needed
they'll just have to use double formatting/types.

perlio.c

index f5eb485..3a2f912 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -371,7 +371,19 @@ PerlIO_debug(const char *fmt, ...)
        /* Use fixed buffer as sv_catpvf etc. needs SVs */
        char buffer[1024];
        const STRLEN len1 = my_snprintf(buffer, sizeof(buffer), "%.40s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop));
+#  ifdef USE_QUADMATH
+#    ifdef HAS_VSNPRINTF
+        /* my_vsnprintf() isn't available with quadmath, but the native vsnprintf()
+           should be, otherwise the system isn't likely to support quadmath.
+           Nothing should be calling PerlIO_debug() with floating point anyway.
+        */
+        const STRLEN len2 = vsnprintf(buffer + len1, sizeof(buffer) - len1, fmt, ap);
+#    else
+        STATIC_ASSERT_STMT(0);
+#    endif
+#  else
        const STRLEN len2 = my_vsnprintf(buffer + len1, sizeof(buffer) - len1, fmt, ap);
+#  endif
        PERL_UNUSED_RESULT(PerlLIO_write(PL_perlio_debug_fd, buffer, len1 + len2));
 #else
        const char *s = CopFILE(PL_curcop);