From a11451b3539639ea1d0ecb8137007a1cd4cd3bdd Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 25 Nov 2008 09:33:43 +0000 Subject: * libc/stdio/gets.c (_gets_r): Lock stdin here and call __sgetc_r instead of _getchar_r. --- newlib/libc/stdio/gets.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'newlib/libc/stdio/gets.c') diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c index b90271fb9..17d144316 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; } -- cgit v1.2.3