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>
22 while ((c = getchar()) != '\n' && c != EOF)
24 if (c == EOF && cs==s)
31 /* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
32 This file is part of the GNU C Library.
34 The GNU C Library is free software; you can redistribute it and/or
35 modify it under the terms of the GNU Library General Public License as
36 published by the Free Software Foundation; either version 2 of the
37 License, or (at your option) any later version.
39 The GNU C Library is distributed in the hope that it will be useful,
40 but WITHOUT ANY WARRANTY; without even the implied warranty of
41 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 Library General Public License for more details.
44 You should have received a copy of the GNU Library General Public
45 License along with the GNU C Library; see the file COPYING.LIB. If
46 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
47 Cambridge, MA 02139, USA. */
53 link_warning (gets, "the `gets' function is dangerous and should not be used.")
56 /* Read a newline-terminated multibyte string from stdin into S,
57 removing the trailing newline. Return S or NULL. */
68 if (!__validfp (stream) || p == NULL)
74 if (feof (stream) || ferror (stream))
77 while ((c = getc(stdin)) != EOF) {
83 else if ( isleadbyte(c) ) {
87 if ( isleadbyte(c) || c == EOF )
88 return NULL; // encoding error
95 return NULL; // suspicious input
100 /* Return null if we had an error, or if we got EOF
101 before writing any characters. */
103 if (ferror (stream) || (feof (stream) && p == s))