Subject: Re: Non-compliant strxfrm MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Date: Tue, 2 Sep 2003 09:37:41 +0100 content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Re: Non-compliant strxfrm Thread-Index: AcNxLPt4hwwr5d0hEdeGDgBQvzMKIA== From: "Melvin Curran" To: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id h828bsI01725 Reply-To: djgpp-workers AT delorie DOT com Right, below is the new version of the function which I believe matches the linux output (a few mods to the original function were easiest). The only thing bothering me now is the the statement in the standard that says "If n is zero, dst is permitted to be a null pointer." Does this imply that if n isn't zero then dst must point to something? If so, what should we do about it? What does linux/glibc do? At the moment, I am ignoring it because the standard doesn't explicitly say anything. I should probably take this question to comp.std.c. size_t strxfrm(dst, src, n) char *dst; const char *src; size_t n; { size_t r = 0; int c; while ((c = *src++) != 0) { r++; if (n < 2) { while (*src++ != 0) r++; break; } --n; if (dst) *dst++ = c; } if (dst && n) *dst = 0; return r; } -- || || |||||| | HME Ltd. | || ||| ||| | | |||||| | ||||| | | || || || | Melvin Curran | || || |||||| | melvin AT hme DOT ltd DOT uk |