2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/crtdll/stdio/gets.c
5 * PURPOSE: Get a character string from stdin
6 * PROGRAMER: DJ Delorie
8 * 28/12/98: Appropriated for Reactos
10 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
11 #include <msvcrt/stdio.h>
19 while ((c = getchar()) != '\n' && c != EOF)
21 if (c == EOF && cs==s)
28 /* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
29 This file is part of the GNU C Library.
31 The GNU C Library is free software; you can redistribute it and/or
32 modify it under the terms of the GNU Library General Public License as
33 published by the Free Software Foundation; either version 2 of the
34 License, or (at your option) any later version.
36 The GNU C Library is distributed in the hope that it will be useful,
37 but WITHOUT ANY WARRANTY; without even the implied warranty of
38 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 Library General Public License for more details.
41 You should have received a copy of the GNU Library General Public
42 License along with the GNU C Library; see the file COPYING.LIB. If
43 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
44 Cambridge, MA 02139, USA. */
50 link_warning (gets, "the `gets' function is dangerous and should not be used.")
53 /* Read a newline-terminated multibyte string from stdin into S,
54 removing the trailing newline. Return S or NULL. */
65 if (!__validfp (stream) || p == NULL)
71 if (feof (stream) || ferror (stream))
74 while ((c = getc(stdin)) != EOF) {
80 else if ( isleadbyte(c) ) {
84 if ( isleadbyte(c) || c == EOF )
85 return NULL; // encoding error
92 return NULL; // suspicious input
97 /* Return null if we had an error, or if we got EOF
98 before writing any characters. */
100 if (ferror (stream) || (feof (stream) && p == s))