blob: 17963b93e39223a031dfbd661e34160e5fe81b58 [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#include "stdio_impl.h"
Rich Felker835f9f92012-11-08 16:39:41 -05002#include <limits.h>
3#include <string.h>
Rich Felker0b44a032011-02-12 00:22:29 -05004
5char *gets(char *s)
6{
Rich Felkerb2020572019-02-13 18:48:04 -05007 size_t i=0;
8 int c;
9 FLOCK(stdin);
10 while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c;
11 s[i] = 0;
12 if (c != '\n' && (!feof(stdin) || !i)) s = 0;
13 FUNLOCK(stdin);
14 return s;
Rich Felker0b44a032011-02-12 00:22:29 -050015}