Hi,
Todd C. Miller wrote on Sat, Feb 06, 2016 at 03:33:08PM -0700:
> This makes sense to me. It is possible that the author mistakenly
> believed the mbrtowc(3) manual.
Absolutely possible. That's why documentation is so important.
Bugs in documenation usually breed bugs in code.
So i guess i'll eventually put this in, unless somebody comes up
with good reasons not to.
But given that naddy@ already declared ports slowdown: Do you ports
people agree with my suspicion that this is unlikely to be responsible
for major issues in current ports, but that it carries a certain risk
of regressions in poorly written software? Do you agree that it
should wait until after unlock, or do you want it right now?
Yours,
Ingo
For easier reference:
Patch to make sure that mbtowc(3) always sets EILSEQ on error,
in particular for incomplete characters:
Index: mbtowc.c
===================================================================
RCS file: /cvs/src/lib/libc/locale/mbtowc.c,v
retrieving revision 1.2
diff -u -p -r1.2 mbtowc.c
--- mbtowc.c 5 Dec 2012 23:20:00 -0000 1.2
+++ mbtowc.c 6 Feb 2016 23:03:57 -0000
@@ -44,7 +44,14 @@ mbtowc(wchar_t * __restrict pwc, const c
return (0);
}
rval = mbrtowc(pwc, s, n, &mbs);
- if (rval == (size_t)-1 || rval == (size_t)-2)
- return (-1);
- return ((int)rval);
+
+ switch (rval) {
+ case (size_t)-2:
+ errno = EILSEQ;
+ /* FALLTHROUGH */
+ case (size_t)-1:
+ return -1;
+ default:
+ return (int)rval;
+ }
}