summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/stdio/gets.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libc-top-half/musl/src/stdio/gets.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/stdio/gets.c b/libc-top-half/musl/src/stdio/gets.c
new file mode 100644
index 0000000..17963b9
--- /dev/null
+++ b/libc-top-half/musl/src/stdio/gets.c
@@ -0,0 +1,15 @@
+#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;
+}