public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: Takashi Yano <takashi.yano@nifty.ne.jp>
Cc: newlib@sourceware.org
Subject: Re: [PATCH v4] newlib: libc: Fix crash on fprintf to a wide-oriented stream.
Date: Wed, 8 Nov 2023 20:40:57 +0100	[thread overview]
Message-ID: <ZUvkScDMoXVrvuQW@calimero.vinschen.de> (raw)
In-Reply-To: <20231108120403.643-1-takashi.yano@nifty.ne.jp>

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


  reply	other threads:[~2023-11-08 19:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 12:04 Takashi Yano
2023-11-08 19:40 ` Corinna Vinschen [this message]
2023-11-08 22:00   ` Takashi Yano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZUvkScDMoXVrvuQW@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=newlib@sourceware.org \
    --cc=takashi.yano@nifty.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).