mescc: Mes C Library: Bugfix __ungetc_clear.
* lib/linux/_open3.c (_open3): Remove __ungetc_init (); * lib/mes/mes_open.c (mes_open): Likewise. * lib/mes/fdungetc.c (fdungetc): Likewise. * lib/mes/fdgetc.c (__ungetc_p, __ungetc_clear, __ungetc_set): Call __ungetc_init if buffer is uninitialized.
This commit is contained in:
parent
189b9d9e8c
commit
04061cbba5
|
@ -27,7 +27,6 @@ int
|
|||
_open3 (char const *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
|
||||
__ungetc_init ();
|
||||
if (r > 2)
|
||||
{
|
||||
__ungetc_clear (r);
|
||||
|
|
|
@ -31,6 +31,8 @@ int *__ungetc_buf;
|
|||
int
|
||||
__ungetc_p (int filedes)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
return __ungetc_buf[filedes] >= 0;
|
||||
}
|
||||
|
||||
|
@ -49,18 +51,23 @@ __ungetc_init ()
|
|||
void
|
||||
__ungetc_clear (int filedes)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
__ungetc_buf[filedes] = -1;
|
||||
}
|
||||
|
||||
void
|
||||
__ungetc_set (int filedes, int c)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
__ungetc_buf[filedes] = c;
|
||||
}
|
||||
|
||||
int
|
||||
fdgetc (int fd)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
|
||||
char c;
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
int
|
||||
fdungetc (int c, int fd)
|
||||
{
|
||||
__ungetc_init ();
|
||||
if (c == -1)
|
||||
return c;
|
||||
else if (__ungetc_p (fd))
|
||||
|
|
|
@ -32,7 +32,6 @@ int __stderr = STDERR;
|
|||
int
|
||||
mes_open (char const *file_name, int flags, int mask)
|
||||
{
|
||||
__ungetc_init ();
|
||||
int filedes = open (file_name, flags, mask);
|
||||
if (filedes > 2)
|
||||
__ungetc_clear (filedes);
|
||||
|
|
Loading…
Reference in a new issue