• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révisione54692f524c5ada8883afcdd65b2ab998083c3fe (tree)
l'heure2018-08-10 23:02:45
AuteurChristophe Lyon <christophe.lyon@st.c...>
CommiterWaldemar Brodkorb

Message de Log

mbtowc: Fix non compliant behavior for end of string

Match glibc behavior.

* libc/stdlib/stdlib.c (mbtowc): Fix end of string behavior.

Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>

Change Summary

Modification

--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -895,9 +895,13 @@ int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
895895 return is_stateful(ENCODING);
896896 }
897897
898- if (*s == '\0')
898+ if (*s == '\0') {
899899 /* According to the ISO C 89 standard this is the expected behaviour. */
900+ /* Standard not very clear here, so do like glibc. */
901+ if (pwc != NULL)
902+ *pwc = L'\0';
900903 return 0;
904+ }
901905
902906 if ((r = mbrtowc(pwc, s, n, &state)) == (size_t) -2) {
903907 /* TODO: Should we set an error state? */