diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-11-25 09:33:43 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-11-25 09:33:43 +0000 |
commit | a11451b3539639ea1d0ecb8137007a1cd4cd3bdd (patch) | |
tree | 2731b9a570ea38741f25f2a9ee986d24774ad6b3 | |
parent | de33833d1fdf0e76c7c371f5a74757a12600cd98 (diff) | |
download | newlib-a11451b3539639ea1d0ecb8137007a1cd4cd3bdd.zip newlib-a11451b3539639ea1d0ecb8137007a1cd4cd3bdd.tar.gz newlib-a11451b3539639ea1d0ecb8137007a1cd4cd3bdd.tar.bz2 |
* libc/stdio/gets.c (_gets_r): Lock stdin here and call
__sgetc_r instead of _getchar_r.
-rw-r--r-- | newlib/ChangeLog | 5 | ||||
-rw-r--r-- | newlib/libc/stdio/gets.c | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 01f3477..e624880 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2008-11-25 Corinna Vinschen <corinna@vinschen.de> + + * libc/stdio/gets.c (_gets_r): Lock stdin here and call + __sgetc_r instead of _getchar_r. + 2008-11-24 Craig Howland <howland@LGSInnovations.com> * libc/stdlib/wcstoull_r.c: Add EINVAL return for bad base value, diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c index b90271f..17d1443 100644 --- a/newlib/libc/stdio/gets.c +++ b/newlib/libc/stdio/gets.c @@ -79,15 +79,20 @@ _DEFUN(_gets_r, (ptr, buf), register int c; register char *s = buf; - while ((c = _getchar_r (ptr)) != '\n') + _flockfile (stdin); + while ((c = __sgetc_r (ptr, stdin)) != '\n') if (c == EOF) if (s == buf) - return NULL; + { + _funlockfile (stdin); + return NULL; + } else break; else *s++ = c; *s = 0; + _funlockfile (stdin); return buf; } |