summaryrefslogblamecommitdiff
path: root/src/stdio/gets.c
blob: 17963b93e39223a031dfbd661e34160e5fe81b58 (plain) (tree)
1
2
3
4
5
6
                       

                   


                   







                                                                        
 
#include "stdio_impl.h"
#include <limits.h>
#include <string.h>

char *gets(char *s)
{
	size_t i=0;
	int c;
	FLOCK(stdin);
	while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c;
	s[i] = 0;
	if (c != '\n' && (!feof(stdin) || !i)) s = 0;
	FUNLOCK(stdin);
	return s;
}