Re: tests tweaks
| From: | (Marcus Börger) | Date: | Wed, 21 Aug 2002 23:25:21 +0000 |
| Subject: | Re: tests tweaks | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-87255@lists.php.net to get a copy of this message | ||
At 00:56 22.08.2002, you wrote:
Hi Marcus, At 23:54 21-8-2002, Marcus Börger wrote: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 marcusAt 17:58 21.08.2002, Melvyn Sopacua wrote:Yes, I saw that.At 03:36 21-8-2002, Marcus Börger wrote:That it is there does not mean it is C99 complient. We only use our own snprintf it is missing.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.Is this what you are looking for? #include <stdio.h> int main() {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.htmThere 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.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