| delorie.com/archives/browse.cgi | search |
| Subject: | Re: Non-compliant strxfrm |
| MIME-Version: | 1.0 |
| 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: | <F1A9C8D7A58D1B45A9C16FE7E3DA83D702188F@server.HME.hme.ltd.uk> |
| X-MS-Has-Attach: | |
| X-MS-TNEF-Correlator: | |
| Thread-Topic: | Re: Non-compliant strxfrm |
| Thread-Index: | AcNxLPt4hwwr5d0hEdeGDgBQvzMKIA== |
| From: | "Melvin Curran" <Melvin AT HME DOT Ltd DOT uk> |
| To: | <djgpp-workers AT delorie DOT com> |
| 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 |
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |