3 * ReactOS msvcrt library
7 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
9 * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
10 * 28/12/1998: Appropriated for Reactos
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
28 #include <msvcrt/stdio.h>
36 while ((c = getc(stdin)) != '\n' && c != EOF)
38 if (c == EOF && cs == s)
45 #define WEOF (wchar_t)(0xFFFF)
49 * Get a line from the stdin stream.
53 wchar_t* _getws(wchar_t* s)
59 while ((c = getwc(stdin)) != L'\n' && c != WEOF)
61 if (c == WEOF && cs == s)
68 /* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
69 This file is part of the GNU C Library.
71 The GNU C Library is free software; you can redistribute it and/or
72 modify it under the terms of the GNU Library General Public License as
73 published by the Free Software Foundation; either version 2 of the
74 License, or (at your option) any later version.
76 The GNU C Library is distributed in the hope that it will be useful,
77 but WITHOUT ANY WARRANTY; without even the implied warranty of
78 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79 Library General Public License for more details.
81 You should have received a copy of the GNU Library General Public
82 License along with the GNU C Library; see the file COPYING.LIB. If
83 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
84 Cambridge, MA 02139, USA. */
90 link_warning (gets, "the `gets' function is dangerous and should not be used.")
93 /* Read a newline-terminated multibyte string from stdin into S,
94 removing the trailing newline. Return S or NULL. */
100 register char *p = s;
102 FILE *stream = stdin;
105 if (!__validfp (stream) || p == NULL)
107 __set_errno (EINVAL);
111 if (feof (stream) || ferror (stream))
114 while ((c = getc(stdin)) != EOF) {
120 else if ( isleadbyte(c) ) {
124 if ( isleadbyte(c) || c == EOF )
125 return NULL; // encoding error
132 return NULL; // suspicious input
137 /* Return null if we had an error, or if we got EOF
138 before writing any characters. */
140 if (ferror (stream) || (feof (stream) && p == s))