Mercurial > ecos
changeset 2264:af00278f385c
* src/wcstombs.cxx (wcstombs): Follow Single Unix Spec
and if string is NULL, return chars that would have been
returned.
| author | jlarmour |
|---|---|
| date | Thu, 10 Aug 2006 13:20:06 +0000 |
| parents | b79bf6f1fe6b |
| children | b5670f3c40f2 |
| files | packages/language/c/libc/i18n/current/ChangeLog packages/language/c/libc/i18n/current/src/wcstombs.cxx |
| diffstat | 2 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/language/c/libc/i18n/current/ChangeLog +++ b/packages/language/c/libc/i18n/current/ChangeLog @@ -1,3 +1,9 @@ +2006-08-10 Jonathan Larmour <jifl@eCosCentric.com> + + * src/wcstombs.cxx (wcstombs): Follow Single Unix Spec + and if string is NULL, return chars that would have been + returned. + 2005-07-30 Andrew Lunn <andrew.lunn@ascom.ch> * tests/i18nmb.c (main): Really silence the warnings.
--- a/packages/language/c/libc/i18n/current/src/wcstombs.cxx +++ b/packages/language/c/libc/i18n/current/src/wcstombs.cxx @@ -85,12 +85,13 @@ be restricted to a defined set of locale RETURNS This implementation of <<wcstombs>> returns <<0>> if -<[s]> is <<NULL>> or is the empty string; +<[s]> is the empty string; it returns <<-1>> if CYGINT_LIBC_I18N_MB_REQUIRED and one of the wide-char characters does not represent a valid multi-byte character; otherwise it returns the minimum of: <<n>> or the number of bytes that are transferred to <<s>>, not including the -nul terminator. +nul terminator. If <[s]> is <<NULL>> it returns the number of +bytes that would have been transferred. If the return value is -1, the state of the <<pwc>> string is indeterminate. If the input has a length of 0, the output @@ -193,11 +194,15 @@ wcstombs ( char *s, const wchar_t *pwcs, #endif /* CYGINT_LIBC_I18N_MB_REQUIRED */ int count = 0; + char c; if (n != 0) { do { - if ((*s++ = (char) *pwcs++) == 0) - break; + c = (char) *pwcs++; + if (s) + *s++ = c; + if (0 == c) + break; count++; } while (--n != 0); }
