From: Nicholas Clark Date: Mon, 24 Oct 2005 20:03:38 +0000 (+0000) Subject: Add a probe for whether sprintf returns the length of the buffer. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=78821a22f30aaed98d9c6643adb5ed18f868dbe7;p=p5sagit%2Fp5-mst-13.2.git Add a probe for whether sprintf returns the length of the buffer. Update all the canned config.sh files. Assume that symbian and Win32 are all ANSI conformant, note that ARM Linux (ie glibc) will be, don't assume that any other platform is. p4raw-id: //depot/perl@25831 --- diff --git a/Configure b/Configure index b282a16..72028b5 100755 --- a/Configure +++ b/Configure @@ -775,6 +775,7 @@ d_voidsig='' signal_t='' d_volatile='' d_charvspr='' +d_sprintf_returns_strlen='' d_vprintf='' d_wait4='' d_waitpid='' @@ -14185,6 +14186,68 @@ EOCP esac +: see if sprintf returns the length of the string in the buffer as per ANSI +$echo "Checking whether sprintf returns the length of the string..." >&4 +$cat <try.c +#include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif +#$i_string I_STRING +#ifdef I_STRING +# include +#else +# include +#endif +#$i_math I_MATH +#ifdef I_MATH +#include +#endif + +char buffer[256]; + +int check (size_t expect, int test) { + size_t got = strlen(buffer); + if (expect == got) + return 0; + + printf("expected %ld, got %ld in test %d '%s'\n", (long) expect, (long) got, + test, buffer); + exit (test); +} + +int main(int argc, char **argv) { + int test = 0; + + check(sprintf(buffer, ""), ++test); + check(sprintf(buffer, "%s %s", "perl", "rules"), ++test); + check(sprintf(buffer, "I like %g", atan2(0,-1)), ++test); + + return 0; +} +EOP +set try + +d_sprintf_returns_strlen="$undef" +if eval $compile; then + xxx="`$run ./try`" + case "$?" in + 0) cat >&4 <&4 <