diff options
author | H.Merijn Brand <h.m.brand@xs4all.nl> | 2006-01-05 21:04:32 +0000 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2006-01-05 21:04:32 +0000 |
commit | 2478f7a0ecfc00f4d83ec0abe7521859385d9893 (patch) | |
tree | 479c93cece28dda0a54f81ac0105359af2fd8d02 /Configure | |
parent | 1a43333d9bf51719e5b1f8ad083714177a89e6b7 (diff) | |
download | perl-2478f7a0ecfc00f4d83ec0abe7521859385d9893.tar.gz |
Test if the probed availability of v?snprintf () is
actually usable. Thanks to Russ and Jarkko.
p4raw-id: //depot/perl@26668
Diffstat (limited to 'Configure')
-rwxr-xr-x | Configure | 59 |
1 files changed, 58 insertions, 1 deletions
@@ -26,7 +26,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Tue Jan 3 16:44:36 CET 2006 [metaconfig 3.0 PL70] +# Generated on Thu Jan 5 22:03:19 CET 2006 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.org) cat >c1$$ <<EOF @@ -16546,6 +16546,63 @@ eval $inlibc set vsnprintf d_vsnprintf eval $inlibc +case "$d_snprintf-$d_vsnprintf" in +"$define-$define") + $cat <<EOM +Checking whether your snprintf() and vsnprintf() work okay... +EOM + $cat >try.c <<'EOCP' +/* v?snprintf testing logic courtesy of Russ Allbery. + * According to C99: + * - if the buffer is too short it still must be \0-terminated + * - if the buffer is too short the potentially required length + * must be returned and not -1 + * - if the buffer is NULL the potentially required length + * must be returned and not -1 or core dump + */ +#include <stdio.h> +#include <stdarg.h> + +char buf[2]; + +int test (char *format, ...) +{ + va_list args; + int count; + + va_start (args, format); + count = vsnprintf (buf, sizeof buf, format, args); + va_end (args); + return count; +} + +int main () +{ + return ((test ("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0' + && snprintf (NULL, 0, "%s", "abcd") == 4) ? 0 : 1); +} +EOCP + set try + if eval $compile; then + `$run ./try` + case "$?" in + 0) echo "Your snprintf() and vsnprintf() seem to be working okay." ;; + *) cat <<EOM >&4 +Your snprintf() and snprintf() don't seem to be working okay. +EOM + d_snprintf="$undef" + d_vsnprintf="$undef" + ;; + esac + else + echo "(I can't seem to compile the test program--assuming they don't)" + d_snprintf="$undef" + d_vsnprintf="$undef" + fi + $rm -f try.* try core core.try.* + ;; +esac + : see if sockatmark exists set sockatmark d_sockatmark eval $inlibc |