-/* Copyright (C) 1992-2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
+
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#ifdef HAVE_CONFIG_H
+#ifndef _LIBC
# include <config.h>
#endif
#include <stdio.h>
-#if !defined _WIN32
+#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
#include <stdbool.h>
-#if HAVE_STDIO_EXT_H
-# include <stdio_ext.h>
-#endif
-#if !HAVE___FSETLOCKING
-# define __fsetlocking(stream, type) /* empty */
+#if HAVE_DECL___FSETLOCKING && HAVE___FSETLOCKING
+# if HAVE_STDIO_EXT_H
+# include <stdio_ext.h>
+# endif
+#else
+# define __fsetlocking(stream, type) /* empty */
#endif
#if HAVE_TERMIOS_H
# include <termios.h>
#endif
-#include "getline.h"
-
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#else
== fileno (out). The POSIX restrictions are tricky and change
from POSIX version to POSIX version, so play it safe and invoke
fseek even if in != out. */
- fseek (out, 0, SEEK_CUR);
+ fseeko (out, 0, SEEK_CUR);
if (buf != NULL)
{
if (nread < 0)
- buf[0] = '\0';
+ buf[0] = '\0';
else if (buf[nread - 1] == '\n')
- {
- /* Remove the newline. */
- buf[nread - 1] = '\0';
- if (tty_changed)
- {
- /* Write the newline that was not echoed. */
- putc_unlocked ('\n', out);
- }
- }
+ {
+ /* Remove the newline. */
+ buf[nread - 1] = '\0';
+ if (tty_changed)
+ {
+ /* Write the newline that was not echoed. */
+ putc_unlocked ('\n', out);
+ }
+ }
}
/* Restore the original setting. */
return buf;
}
-#else /* WIN32 */
+#else /* W32 native */
/* Windows implementation by Martin Lambers <marlam@marlam.de>,
improved by Simon Josefsson. */
/* For PASS_MAX. */
#include <limits.h>
+/* For _getch(). */
+#include <conio.h>
+/* For strdup(). */
+#include <string.h>
#ifndef PASS_MAX
# define PASS_MAX 512
{
c = _getch ();
if (c == '\r')
- {
- getpassbuf[i] = '\0';
- break;
- }
+ {
+ getpassbuf[i] = '\0';
+ break;
+ }
else if (i < PASS_MAX)
- {
- getpassbuf[i++] = c;
- }
+ {
+ getpassbuf[i++] = c;
+ }
if (i >= PASS_MAX)
- {
- getpassbuf[i] = '\0';
- break;
- }
+ {
+ getpassbuf[i] = '\0';
+ break;
+ }
}
if (prompt)