From: Jarkko Hietaniemi Date: Tue, 29 Feb 2000 17:04:36 +0000 (+0000) Subject: The sprintf option was blithely printing long doubles as X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bbe6c963bed5430184afbcd66d96d7e202649fd2;p=p5sagit%2Fp5-mst-13.2.git The sprintf option was blithely printing long doubles as doubles (spotted by Spider Boardman); dqgcvt() wasn't ever being used; made the test more thorough. p4raw-id: //depot/cfgperl@5358 --- diff --git a/Configure b/Configure index 7a09e90..7582243 100755 --- a/Configure +++ b/Configure @@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Tue Feb 29 18:56:27 EET 2000 [metaconfig 3.0 PL70] +# Generated on Tue Feb 29 19:02:20 EET 2000 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.com) cat >/tmp/c1$$ <try.c < - -#define I_STDLIB $i_stdlib -#ifdef I_STDLIB -#include -#endif - -int -checkit(expect, got) -char *expect; -char *got; -{ - if (strcmp(expect, got)) { - printf("%s oddity: Expected %s, got %s\n", - myname, expect, got); - exit(1); - } -} - -int main() -{ - char buf[64]; - buf[63] = '\0'; - - /* This must be 1st test on (which?) platform */ - /* Alan Burlison */ - Gconvert((DOUBLETYPE)0.1, 8, 0, buf); - checkit("0.1", buf); - - Gconvert((DOUBLETYPE)1.0, 8, 0, buf); - checkit("1", buf); - - Gconvert((DOUBLETYPE)0.0, 8, 0, buf); - checkit("0", buf); - - Gconvert((DOUBLETYPE)-1.0, 8, 0, buf); - checkit("-1", buf); - - /* Some Linux gcvt's give 1.e+5 here. */ - Gconvert((DOUBLETYPE)100000.0, 8, 0, buf); - checkit("100000", buf); - - /* Some Linux gcvt's give -1.e+5 here. */ - Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf); - checkit("-100000", buf); - - exit(0); -} -EOP - case "$d_Gconvert" in - gconvert*) xxx_list='gconvert gcvt sprintf' ;; - gcvt*) xxx_list='gcvt gconvert sprintf' ;; - sprintf*) xxx_list='sprintf gconvert gcvt' ;; - *) xxx_list='gconvert gcvt sprintf' ;; - esac - - case "$d_longdbl$uselongdouble" in - definedefine) xxx_list="`echo $xxx_list|sed 's/gcvt/qgcvt gcvt/'`" ;; - esac - - for xxx_convert in $xxx_list; do - echo "Trying $xxx_convert..." - $rm -f try try$_o - set try -DTRY_$xxx_convert - if eval $compile; then - echo "$xxx_convert() found." >&4 - if ./try; then - echo "I'll use $xxx_convert to convert floats into a string." >&4 - break; - else - echo "...But $xxx_convert didn't work as I expected." - fi - else - echo "$xxx_convert NOT found." >&4 - fi - done - - case "$xxx_convert" in - gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;; - gcvt) d_Gconvert='gcvt((x),(n),(b))' ;; - qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;; - *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;; - esac -fi - echo " " if $test X"$d_longdbl" = X"$define"; then @@ -7569,6 +7462,159 @@ case "$sPRIfldbl" in ;; esac +: Check how to convert floats to strings. +if test "X$d_Gconvert" = X; then + echo " " + echo "Checking for an efficient way to convert floats to strings." + echo " " > try.c + case "$uselongdouble" in + "$define") echo "#define USE_LONG_DOUBLE" >>try.c ;; + esac + case "$d_longdbl" in + "$define") echo "#define HAS_LONG_DOUBLE" >>try.c ;; + esac + case "$d_PRIgldbl" in + "$define") echo "#define HAS_PRIgldbl" >>try.c ;; + esac + $cat >>try.c < + +#define I_STDLIB $i_stdlib +#ifdef I_STDLIB +#include +#endif + +int +checkit(expect, got) +char *expect; +char *got; +{ + if (strcmp(expect, got)) { + printf("%s oddity: Expected %s, got %s\n", + myname, expect, got); + exit(1); + } +} + +int main() +{ + char buf[64]; + buf[63] = '\0'; + + /* This must be 1st test on (which?) platform */ + /* Alan Burlison */ + Gconvert((DOUBLETYPE)0.1, 8, 0, buf); + checkit("0.1", buf); + + Gconvert((DOUBLETYPE)1.0, 8, 0, buf); + checkit("1", buf); + + Gconvert((DOUBLETYPE)1.1, 8, 0, buf); + checkit("1.1", buf); + + Gconvert((DOUBLETYPE)1.01, 8, 0, buf); + checkit("1.01", buf); + + Gconvert((DOUBLETYPE)1.001, 8, 0, buf); + checkit("1.001", buf); + + Gconvert((DOUBLETYPE)1.0001, 8, 0, buf); + checkit("1.0001", buf); + + Gconvert((DOUBLETYPE)1.00001, 8, 0, buf); + checkit("1.00001", buf); + + Gconvert((DOUBLETYPE)1.000001, 8, 0, buf); + checkit("1.000001", buf); + + Gconvert((DOUBLETYPE)0.0, 8, 0, buf); + checkit("0", buf); + + Gconvert((DOUBLETYPE)-1.0, 8, 0, buf); + checkit("-1", buf); + + /* Some Linux gcvt's give 1.e+5 here. */ + Gconvert((DOUBLETYPE)100000.0, 8, 0, buf); + checkit("100000", buf); + + /* Some Linux gcvt's give -1.e+5 here. */ + Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf); + checkit("-100000", buf); + + exit(0); +} +EOP + case "$d_Gconvert" in + gconvert*) xxx_list='gconvert gcvt sprintf' ;; + gcvt*) xxx_list='gcvt gconvert sprintf' ;; + sprintf*) xxx_list='sprintf gconvert gcvt' ;; + *) xxx_list='gconvert gcvt sprintf' ;; + esac + + case "$d_longdbl$uselongdouble$d_qgcvt" in + "$define$define$define") xxx_list="`echo $xxx_list|sed 's/gcvt/qgcvt gcvt/'`" ;; + esac + + for xxx_convert in $xxx_list; do + echo "Trying $xxx_convert..." + $rm -f try try$_o + set try -DTRY_$xxx_convert + if eval $compile; then + echo "$xxx_convert() found." >&4 + if ./try; then + echo "I'll use $xxx_convert to convert floats into a string." >&4 + break; + else + echo "...But $xxx_convert didn't work as I expected." + fi + else + echo "$xxx_convert NOT found." >&4 + fi + done + + case "$xxx_convert" in + gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;; + gcvt) d_Gconvert='gcvt((x),(n),(b))' ;; + qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;; + *) case "$uselongdouble$d_longdbl$d_PRIgldbl" in + "$define$define$define") + d_Gconvert="sprintf((b),\"%.*$sPRIgldbl\",(n),(x))" ;; + *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;; + esac + ;; + esac +fi + : Initialize h_fcntl h_fcntl=false @@ -14987,6 +15033,7 @@ d_pwexpire='$d_pwexpire' d_pwgecos='$d_pwgecos' d_pwpasswd='$d_pwpasswd' d_pwquota='$d_pwquota' +d_qgcvt='$d_qgcvt' d_quad='$d_quad' d_readdir='$d_readdir' d_readlink='$d_readlink' diff --git a/epoc/config.sh b/epoc/config.sh index 0d6017f..e0d7166 100644 --- a/epoc/config.sh +++ b/epoc/config.sh @@ -256,6 +256,7 @@ d_pwexpire='undef' d_pwgecos='undef' d_pwpasswd='undef' d_pwquota='undef' +d_qgcvt='undef' d_readdir='define' d_readlink='undef' d_readv='undef' diff --git a/vms/subconfigure.com b/vms/subconfigure.com index c846551..6f7c4a0 100644 --- a/vms/subconfigure.com +++ b/vms/subconfigure.com @@ -113,6 +113,7 @@ $ perl_installusrbinperl="undef" $ perl_CONFIG="true" $ perl_d_fseeko="undef" $ perl_d_ftello="undef" +$ perl_d_qgcvt="undef" $ perl_d_readv="undef" $ perl_d_writev="undef" $ perl_i_machcthr="undef" @@ -4024,6 +4025,7 @@ $ WC "d_cmsghdr_s='" + perl_d_cmsghdr_s + "'" $ WC "i_sysuio='" + perl_i_sysuio + "'" $ WC "d_fseeko='" + perl_d_fseeko + "'" $ WC "d_ftello='" + perl_d_ftello + "'" +$ WC "d_qgcvt='" + perl_d_qgcvt + "'" $ WC "d_readv='" + perl_d_readv + "'" $ WC "d_writev='" + perl_d_writev + "'" $ WC "i_machcthr='" + perl_i_machcthr + "'" diff --git a/vos/config.def b/vos/config.def index 8f86621..bc294dc 100644 --- a/vos/config.def +++ b/vos/config.def @@ -169,6 +169,7 @@ $d_pwexpire='undef' $d_pwgecos='undef' $d_pwpasswd='undef' $d_pwquota='undef' +$d_qgcvt='undef' $d_quad='undef' $d_readdir='define' $d_readlink='define' diff --git a/win32/config.bc b/win32/config.bc index c509683..19ce10d 100644 --- a/win32/config.bc +++ b/win32/config.bc @@ -251,6 +251,7 @@ d_pwexpire='undef' d_pwgecos='undef' d_pwpasswd='undef' d_pwquota='undef' +d_qgcvt='undef' d_quad='undef' d_readdir='define' d_readlink='undef' diff --git a/win32/config.gc b/win32/config.gc index d00cd45..b6a4175 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -251,6 +251,7 @@ d_pwexpire='undef' d_pwgecos='undef' d_pwpasswd='undef' d_pwquota='undef' +d_qgcvt='undef' d_quad='undef' d_readdir='define' d_readlink='undef' diff --git a/win32/config.vc b/win32/config.vc index 7011989..354f9be 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -251,6 +251,7 @@ d_pwexpire='undef' d_pwgecos='undef' d_pwpasswd='undef' d_pwquota='undef' +d_qgcvt='undef' d_quad='undef' d_readdir='define' d_readlink='undef'