summaryrefslogtreecommitdiff
path: root/Configure
diff options
context:
space:
mode:
authorH.Merijn Brand <h.m.brand@xs4all.nl>2006-01-05 21:04:32 +0000
committerH.Merijn Brand <h.m.brand@xs4all.nl>2006-01-05 21:04:32 +0000
commit2478f7a0ecfc00f4d83ec0abe7521859385d9893 (patch)
tree479c93cece28dda0a54f81ac0105359af2fd8d02 /Configure
parent1a43333d9bf51719e5b1f8ad083714177a89e6b7 (diff)
downloadperl-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-xConfigure59
1 files changed, 58 insertions, 1 deletions
diff --git a/Configure b/Configure
index ccb7aaeeee..64ea421044 100755
--- a/Configure
+++ b/Configure
@@ -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