Mercurial > ecos
changeset 2269:6cd92ec5bc13
* src/wcstombs.cxx (wcstombs): Previous change should have
disregarded 'n'. Now fixed. Thanks to Klaas Gadeyne.
| author | jlarmour |
|---|---|
| date | Fri, 11 Aug 2006 12:16:36 +0000 |
| parents | 67303228ae86 |
| children | 0b2803660786 |
| files | packages/language/c/libc/i18n/current/ChangeLog packages/language/c/libc/i18n/current/src/wcstombs.cxx |
| diffstat | 2 files changed, 18 insertions(+), 10 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,8 @@ +2006-08-11 Jonathan Larmour <jifl@eCosCentric.com> + + * src/wcstombs.cxx (wcstombs): Previous change should have + disregarded 'n'. Now fixed. Thanks to Klaas Gadeyne. + 2006-08-10 Jonathan Larmour <jifl@eCosCentric.com> * src/wcstombs.cxx (wcstombs): Follow Single Unix Spec
--- a/packages/language/c/libc/i18n/current/src/wcstombs.cxx +++ b/packages/language/c/libc/i18n/current/src/wcstombs.cxx @@ -91,7 +91,7 @@ wide-char characters does not represent otherwise it returns the minimum of: <<n>> or the number of bytes that are transferred to <<s>>, not including the nul terminator. If <[s]> is <<NULL>> it returns the number of -bytes that would have been transferred. +bytes that would have been transferred, regardless of <<[n]>>. If the return value is -1, the state of the <<pwc>> string is indeterminate. If the input has a length of 0, the output @@ -196,15 +196,18 @@ wcstombs ( char *s, const wchar_t *pwcs, int count = 0; char c; - if (n != 0) { - do { - c = (char) *pwcs++; - if (s) - *s++ = c; - if (0 == c) - break; - count++; - } while (--n != 0); + if (s == NULL) { + while (*pwcs++ != 0) { + count++; + } + } else { + if (n != 0) { + do { + if ((*s++ = (char) *pwcs++) == 0) + break; + count++; + } while (--n != 0); + } } retval = count;
