In message <[EMAIL PROTECTED]>
so spake Ray Lai (ray):
> I'm having trouble making snprintf return -1. I've tried stuff like:
>
> len = snprintf(str, 0, "%.-Z\n", 9);
> printf("%d", len);
>
> but that just prints `2'. Does snprintf ever return -1?
Not on OpenBSD. It can on other OSes when there is an encoding
error. You only get those dealing with wide characters and we don't
do that yet. From the C99 standard:
An encoding error occurs if the character sequence presented to the
underlying mbrtowc() function does not form a valid (generalized)
multibyte character, or if the code value passed to the underlying
wcrtomb() does not correspond to a valid (generalized) multibyte
character. The wide character input/output functions and the byte
input/output functions store the value of the macro EILSEQ in errno
if and only if an encoding error occurs.
When our locale code support is better this will be possible on
OpenBSD too...
- todd