[PATCH v2] newlib: libc: Fix bugs in the commit 3d94e07c49b5.
Takashi Yano
takashi.yano@nifty.ne.jp
Thu Nov 16 12:27:23 GMT 2023
Hi Corinna,
On Wed, 15 Nov 2023 17:31:39 +0100
Corinna Vinschen wrote:
> Hi Takashi,
>
> On Nov 13 14:07, Corinna Vinschen wrote:
> > On Nov 11 01:09, Takashi Yano wrote:
> > > diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c
> > > index 79914af08..5053fd6c4 100644
> > > --- a/newlib/libc/stdio/ungetc.c
> > > +++ b/newlib/libc/stdio/ungetc.c
> > > @@ -125,12 +125,6 @@ _ungetc_r (struct _reent *rptr,
> > >
> > > _newlib_flockfile_start (fp);
> > >
> > > - if (ORIENT (fp, -1) != -1)
> > > - {
> > > - _newlib_flockfile_exit (fp);
> > > - return EOF;
> > > - }
> > > -
> > > /* After ungetc, we won't be at eof anymore */
> > > fp->_flags &= ~__SEOF;
> > >
> > > @@ -213,6 +207,8 @@ int
> > > ungetc (int c,
> > > register FILE *fp)
> > > {
> > > + if (ORIENT (fp, -1) != -1)
> > > + return EOF;
> > > return _ungetc_r (_REENT, c, fp);
> > > }
> > > #endif /* !_REENT_ONLY */
> >
> > As per the reasoning in terms of old standards, we shouldn't check or set
> > the orientation in ungetc at all.
>
> Given all that has been discussed, I attached a followup proposal.
> I hope that's ok. We may want to release 3.4.10 in the next weeks.
LGTM, except for:
1) Shouldn't we add flags2 = 0 also for _fmemopen_r(), _fopencookie_r(),
_funopen_r() and internal_open_memstream_r()?
2) __swbuf_r() has ORIENT (fp, -1) call, however, result is not checked.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
More information about the Newlib
mailing list