Subject: RE: Non-compliant strxfrm MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Date: Tue, 2 Sep 2003 14:36:13 +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: Non-compliant strxfrm Thread-Index: AcNxU5QFz9VeiYoUR96vO74kKLcSgAAAi7UQ From: "Melvin Curran" To: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id h82DaJY09535 Reply-To: djgpp-workers AT delorie DOT com >If dst points to invalid memory there is little we can do about it. >The OS will detect any access faults automatically. Letting it do >that is what most of the other libc functions do. In that case, a couple of minor changes to the function and we are left with the function below. 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; } if (--n) *dst++ = c; } if (n) *dst = 0; return r; }