At 00:56 22.08.2002, you wrote: >Hi Marcus, > >At 23:54 21-8-2002, Marcus Börger wrote: > >>At 17:58 21.08.2002, Melvyn Sopacua wrote: >>>At 03:36 21-8-2002, Marcus Börger wrote: >>> >>>>I made the functions a bit more C99 complient (maybe we should use >>>>some C99 complience suit...) but unfortuanetley that was not all. >>>>1) someone must have changed ini setting precision from 14 to 12 >>>>Adding special INI section to array tests fixed test 1 & 2. >>>>2) test 003 Test usort, uksort and uasort >>>>All this functions fail on the subarray.... >>> >>>That test is now fixed. >>> >>>There's indeed a printf bug, for AIX: >>>float(-.3333333333) on 003.phpt. >> >>That it is there does not mean it is C99 complient. >>We only use our own snprintf it is missing. > >Yes, I saw that. > >>>Funny thing is, that AIX has snprintf, and it's used. >>> >>>The manpage is here - if you want to see whether that complies to >>>your requirements: >>>http://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/basetrf2/snprintf.htm >> >>There is nothing said about to what it conforms and that there is at >>least one >>digit infront of the decimal point is not mentioned either so i guess the >>function was created before C99. > >Is this what you are looking for? > >#include <stdio.h> > >int main() >{ > double f; > char *result; > size_t buf_len=1024; > > result = (char *) malloc(buf_len+1); > f = -.3333333333333333; > if(snprintf(result, buf_len, "Result is: %f and precision 12: > %.12f\n", f, f) < 1) > { > fprintf(stderr, "Error\n"); > } > else > { > printf("%s", result); > } >} > >$ ./snprintf >Result is: -0.333333 and precision 12: -0.333333333333
No there are more important issues in compliancy . Especially there are libraries out which do not check for the length parameter (i already have the code needed for that) The code for you provided does not work because you only check for the number of characters written. Instead you must check for the '0' in front of the decimal point. E.g: char buf[10]; if (strcmp("0.1", snprintf(buf, sizeof(buf), "%.f", .1))) ... Besides the return value is different in the libraries, too. Some return the length actually written but C99 requires to return the number of characters that could have been written if buffer was large enough. regards marcus -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php