xref: /aosp_15_r20/external/musl/src/stdio/gets.c (revision c9945492fdd68bbe62686c5b452b4dc1be3f8453)
1 #include "stdio_impl.h"
2 #include <limits.h>
3 #include <string.h>
4 
gets(char * s)5 char *gets(char *s)
6 {
7 	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;
15 }
16