netinet/in.h: add IPPROTO_MH
[uclibc-ng.git] / libc / stdio / gets.c
blob9f4b751a148b86af0a72bb1cf1d0523061eec8d5
1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
6 */
8 #include "_stdio.h"
10 /* UNSAFE FUNCTION -- do not bother optimizing */
12 /* disable macro, force actual function call */
13 #undef getchar_unlocked
15 char *gets(char *s)
17 register char *p = s;
18 int c;
19 __STDIO_AUTO_THREADLOCK_VAR;
21 __STDIO_AUTO_THREADLOCK(stdin);
23 /* Note: don't worry about performance here... this shouldn't be used!
24 * Therefore, force actual function call. */
25 while (((c = getchar_unlocked()) != EOF) && ((*p = c) != '\n')) {
26 ++p;
28 if ((c == EOF) || (s == p)) {
29 s = NULL;
30 } else {
31 *p = 0;
34 __STDIO_AUTO_THREADUNLOCK(stdin);
36 return s;