getchar issues

Howland Craig D (Craig)
Tue Mar 11 21:33:00 GMT 2008

Here's a slightly different work-around (for if you don't want to call a
printf) in case you need to work with an older library that you don't
the liberty to update.  (I use this trick when creating a second I/O
context, which is just doing manually what ends up being done lower
/* Force init done by library routines without needing to call one.  */
In certain respects it is "dirtier" than a print work-around, but the
for either is really dependent upon using newlib.
Craig Howland

-----Original Message-----
From: []
On Behalf Of Jeff Johnston
Sent: Tuesday, March 11, 2008 3:14 PM
To: Matt Lee
Subject: Re: getchar issues


  Thanks for the analysis.  The solution is that __srget must call 
to calling __srefill_r.  This resolves fake stdin to stdin before 
accessing the read buffer.
I have checked in a fix.  Please try it out.

-- Jeff J.

-----Original Message-----
From: []
On Behalf Of Matt Lee
Sent: Tuesday, March 11, 2008 2:56 PM
Subject: Re: getchar issues
The workaround for this is to first invoke a call such as printf()
which initializes stdin so that any subsequent usage of getchar() and
friends uses the right file pointer to start with.

Ideally, this problem should be fixed in __srget (and similiar
functions). But I am not clear on how to do this. Any suggestions?


More information about the Newlib mailing list