diff options
author | Aaron Crane <arc@cpan.org> | 2017-11-18 18:07:23 +0000 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2017-11-18 18:29:51 +0000 |
commit | 4059ba8734da3986285ad50019afbd56b586ad25 (patch) | |
tree | 72f2d7f4f78af14973ad71527d7d1aef141f00ff /perl.h | |
parent | bd1f84ac544f5604940057502e2035f39c92bd4e (diff) | |
download | perl-4059ba8734da3986285ad50019afbd56b586ad25.tar.gz |
Restore ability to build on platforms without snprintf()
C89 does not in fact define snprintf() or vsnprintf(), and we must therefore
probe for the existence of those functions before trying to use them.
khw++ for pointing out my earlier error.
This reverts part or all of each of the following commits:
13d66b05c6163c3514774d3d11da5f3950e97e98 Rely on C89 vsnprintf()
e791399041815a1a45cea3c7f277c7045b96e51b Rely on C89 snprintf()
adf7d503e55721c500f0bf66560b8f5df7966fe7 pod/perlhacktips.pod: remove some outdated portability notes
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1426,15 +1426,17 @@ EXTERN_C char *crypt(const char *, const char *); */ /* Note that we do not check against snprintf()/vsnprintf() returning - * negative values because that is non-standard behaviour and we now - * assume a working C89 implementation. */ + * negative values because that is non-standard behaviour and we use + * snprintf/vsnprintf only iff HAS_VSNPRINTF has been defined, and + * that should be true only if the snprintf()/vsnprintf() are true + * to the standard. */ #define PERL_SNPRINTF_CHECK(len, max, api) STMT_START { if ((max) > 0 && (Size_t)len > (max)) Perl_croak_nocontext("panic: %s buffer overflow", STRINGIFY(api)); } STMT_END #ifdef USE_QUADMATH # define my_snprintf Perl_my_snprintf # define PERL_MY_SNPRINTF_GUARDED -#elif defined(HAS_C99_VARIADIC_MACROS) && !(defined(DEBUGGING) && !defined(PERL_USE_GCC_BRACE_GROUPS)) && !defined(PERL_GCC_PEDANTIC) +#elif defined(HAS_SNPRINTF) && defined(HAS_C99_VARIADIC_MACROS) && !(defined(DEBUGGING) && !defined(PERL_USE_GCC_BRACE_GROUPS)) && !defined(PERL_GCC_PEDANTIC) # ifdef PERL_USE_GCC_BRACE_GROUPS # define my_snprintf(buffer, max, ...) ({ int len = snprintf(buffer, max, __VA_ARGS__); PERL_SNPRINTF_CHECK(len, max, snprintf); len; }) # define PERL_MY_SNPRINTF_GUARDED @@ -1448,7 +1450,7 @@ EXTERN_C char *crypt(const char *, const char *); /* There is no quadmath_vsnprintf, and therefore my_vsnprintf() * dies if called under USE_QUADMATH. */ -#if defined(HAS_C99_VARIADIC_MACROS) && !(defined(DEBUGGING) && !defined(PERL_USE_GCC_BRACE_GROUPS)) && !defined(PERL_GCC_PEDANTIC) +#if defined(HAS_VSNPRINTF) && defined(HAS_C99_VARIADIC_MACROS) && !(defined(DEBUGGING) && !defined(PERL_USE_GCC_BRACE_GROUPS)) && !defined(PERL_GCC_PEDANTIC) # ifdef PERL_USE_GCC_BRACE_GROUPS # define my_vsnprintf(buffer, max, ...) ({ int len = vsnprintf(buffer, max, __VA_ARGS__); PERL_SNPRINTF_CHECK(len, max, vsnprintf); len; }) # define PERL_MY_VSNPRINTF_GUARDED |