xref: /third_party/musl/src/stdio/gets.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/stdio/
1570af302Sopenharmony_ci#include "stdio_impl.h"
2570af302Sopenharmony_ci#include <limits.h>
3570af302Sopenharmony_ci#include <string.h>
4570af302Sopenharmony_ci
5570af302Sopenharmony_cichar *gets(char *s)
6570af302Sopenharmony_ci{
7570af302Sopenharmony_ci	size_t i=0;
8570af302Sopenharmony_ci	int c;
9570af302Sopenharmony_ci	FLOCK(stdin);
10570af302Sopenharmony_ci	while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c;
11570af302Sopenharmony_ci	s[i] = 0;
12570af302Sopenharmony_ci	if (c != '\n' && (!feof(stdin) || !i)) s = 0;
13570af302Sopenharmony_ci	FUNLOCK(stdin);
14570af302Sopenharmony_ci	return s;
15570af302Sopenharmony_ci}
16

Indexes created Thu Nov 07 10:32:03 CST 2024