3 ?RCS: Copyright (c) 2005 H.Merijn Brand
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
8 ?MAKE:d_sprintf_returns_strlen: Compile cat rm run i_stdlib i_string i_math echo
10 ?S:d_sprintf_returns_strlen:
11 ?S: This variable defines whether sprintf returns the length of the string
12 ?S: (as per the ANSI spec). Some C libraries retain compatibility with
13 ?S: pre-ANSI C and return a pointer to the passed in buffer; for these
14 ?S: this variable will be undef.
16 ?C:SPRINTF_RETURNS_STRLEN:
17 ?C: This variable defines whether sprintf returns the length of the string
18 ?C: (as per the ANSI spec). Some C libraries retain compatibility with
19 ?C: pre-ANSI C and return a pointer to the passed in buffer; for these
20 ?C: this variable will be undef.
22 ?H:#$d_sprintf_returns_strlen SPRINTF_RETURNS_STRLEN /**/
25 : see if sprintf returns the length of the string in the buffer as per ANSI
26 $echo "Checking whether sprintf returns the length of the string..." >&4
46 int check (size_t expect, int test) {
47 size_t got = strlen(buffer);
51 printf("expected %ld, got %ld in test %d '%s'\n", (long) expect, (long) got,
56 int main(int argc, char **argv) {
59 check(sprintf(buffer, ""), ++test);
60 check(sprintf(buffer, "%s %s", "perl", "rules"), ++test);
61 check(sprintf(buffer, "I like %g", atan2(0,-1)), ++test);
68 d_sprintf_returns_strlen="$undef"
69 if eval $compile; then
73 sprintf returns the length of the string (as ANSI says it should)
75 d_sprintf_returns_strlen="$define"
78 sprintf does not return the length of the string (how old is this system?)
80 d_sprintf_returns_strlen="$undef"