[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> I think the u* versions should have the same behavior as the libc
> versions, since they're designed to be (almost) replacements for anyone
> who wants to use unicode in a program. I'd call the discrepancy a bug and
> fix it.
But the current ustrncpy() is very useful when you want to truncate a long
string to make it fit into a (supposedly) smaller one: you simply write
ustrncpy(dest, src, sizeof(dest) - ucwidth(0));
instead of
ustrncpy(dest, src, sizeof(dest) - ucwidth(0));
usetc(dest + ustrsize(dest), 0);
Moreover ustrncat(), like the ANSI strncat(), always appends the NULL
terminating character even if the specified 'n' bytes have already been
written, so that
usetc(dest, 0);
ustrncat(dest, src, sizeof(dest) - ucwidth(0));
is the same as the current
ustrncpy(dest, src, sizeof(dest) - ucwidth(0));
which I find is very consistent.
I may miss something, but the behaviour of the ANSI strncpy() is rather odd,
given that memcpy() does a very similar job.
--
Eric Botcazou
ebotcazou@xxxxxxxxxx