mbrtoc16: explain the line that has no test coverage.
We could remove this line, but it seems reasonable to leave it in for
clarification/safety, especially if it's moved after the common success
case?
Test: treehugger
Change-Id: I5f7e0da8397f80018e6d55321b26371790087f5c
diff --git a/libc/bionic/mbrtoc16.cpp b/libc/bionic/mbrtoc16.cpp
index acea426..154b8a3 100644
--- a/libc/bionic/mbrtoc16.cpp
+++ b/libc/bionic/mbrtoc16.cpp
@@ -77,12 +77,15 @@
return nconv;
} else if (nconv == 0) {
return mbstate_reset_and_return(nconv, state);
- } else if (c32 > 0x10ffff) {
- // Input cannot be encoded as UTF-16.
- return mbstate_reset_and_return_illegal(EILSEQ, state);
} else if (c32 < 0x10000) {
*pc16 = static_cast<char16_t>(c32);
return mbstate_reset_and_return(nconv, state);
+ } else if (c32 > 0x10ffff) {
+ // This case is currently handled by mbrtoc32() returning an error, but
+ // if that function is extended to cover 5-byte sequences (which are
+ // illegal at the moment), we'd need to explicitly handle the case of
+ // codepoints that can't be represented as a surrogate pair here.
+ return mbstate_reset_and_return_illegal(EILSEQ, state);
} else {
return begin_surrogate(c32, pc16, nconv, state);
}