diff --git a/src/modules/sprintf/sprintf.c b/src/modules/sprintf/sprintf.c index 85c9486d0084c3f46258e81bea2909922251ed35..f3ef01d753670c25f9a34421a69e2a3bbd551c43 100644 --- a/src/modules/sprintf/sprintf.c +++ b/src/modules/sprintf/sprintf.c @@ -96,7 +96,7 @@ */ #include "global.h" -RCSID("$Id: sprintf.c,v 1.12 1997/06/12 01:35:40 hubbe Exp $"); +RCSID("$Id: sprintf.c,v 1.13 1997/07/20 23:56:32 hubbe Exp $"); #include "error.h" #include "array.h" #include "svalue.h" @@ -106,6 +106,7 @@ RCSID("$Id: sprintf.c,v 1.12 1997/06/12 01:35:40 hubbe Exp $"); #include "constants.h" #include "interpret.h" #include "pike_memory.h" +#include "pike_macros.h" #define FORMAT_INFO_STACK_SIZE 200 #define RETURN_SHARED_STRING @@ -714,7 +715,8 @@ static string low_pike_sprintf(char *format, case 'f': case 'g': DO_OP(); - fsp->b=(char *)xalloc(fsp->width+10); + fsp->b=(char *)xalloc(100+MAXIMUM(fsp->width,8)+ + MAXIMUM(fsp->precision,3)); sprintf(buffer,"%%*.*%c",*a); GET_FLOAT(tf); sprintf(fsp->b,buffer, diff --git a/src/modules/sprintf/testsuite.in b/src/modules/sprintf/testsuite.in index db14290640fd2a69160e93ffd3a79ed2519b331b..fc6f12afe51abbc323e5d1f372e1cde193f3e4d1 100644 --- a/src/modules/sprintf/testsuite.in +++ b/src/modules/sprintf/testsuite.in @@ -1,5 +1,6 @@ // - sprintf module test_true(stringp(sprintf(""))) +test_true(sprintf("--real %1.20f --imaginary %1.20f --scale %1.20f\n",-0.9,-0.9,-0.9)) test_eq(sprintf("%d",1),"1") test_eq(sprintf("%%"),"%") test_eq(sprintf("%d",1),"1")