Re: [PATCH v4] newlib: libc: Fix crash on fprintf to a wide-oriented stream.
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Hi Takashi,
On Nov 8 21:04, Takashi Yano wrote:
> --- a/newlib/libc/stdio/local.h
> +++ b/newlib/libc/stdio/local.h
> @@ -231,21 +231,23 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
> * Set the orientation for a stream. If o > 0, the stream has wide-
> * orientation. If o < 0, the stream has byte-orientation.
> */
> -#define ORIENT(fp,ori) \
> - do \
> - { \
> - if (!((fp)->_flags & __SORD)) \
> - { \
> - (fp)->_flags |= __SORD; \
> - if (ori > 0) \
> - (fp)->_flags2 |= __SWID; \
> - else \
> - (fp)->_flags2 &= ~__SWID; \
> - } \
> - } \
> - while (0)
> +#define ORIENT(fp,ori) \
> + ( \
> + ( \
> + ((fp)->_flags & __SORD) ? \
> + 0 \
> + : \
> + ( \
You're missing to set (fp)->_flags |= __SORD here.
> + (ori > 0) ? \
> + ((fp)->_flags2 |= __SWID) \
> + : \
> + ((fp)->_flags2 &= ~__SWID) \
> + ) \
> + ), \
> + (((fp)->_flags2 & __SWID) ? 1 : -1) \
> + )
Thanks,
Corinna