From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/stdio/gets.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/stdio/gets.c (limited to 'src/stdio/gets.c') diff --git a/src/stdio/gets.c b/src/stdio/gets.c new file mode 100644 index 0000000..17963b9 --- /dev/null +++ b/src/stdio/gets.c @@ -0,0 +1,15 @@ +#include "stdio_impl.h" +#include +#include + +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; +} -- cgit v1.2.3