+2003-10-01 Larry Jones <lawrence.jones@eds.com>
+
+ * getpass.c (getpass): Use a no-op fseek when switching from input to
+ output mode on the same stream.
+
2003-09-29 Paul Eggert <eggert@twinsun.com>
* strftime.c (tm_diff) [! HAVE_TM_GMTOFF]:
-/* Copyright (C) 1992,93,94,95,96,97,98,99,2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2001, 2003 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
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
+#include <fcntl.h>
#include "getline.h"
#include "unlocked-io.h"
/* Remove the newline. */
buf[nread - 1] = '\0';
if (tty_changed)
- /* Write the newline that was not echoed. */
- putc ('\n', out);
+ {
+ /* Write the newline that was not echoed.
+ But before doing that, do a no-op fseek. According to the C
+ standard, input may not be followed by output on the same
+ stream without an intervening call to a file positioning
+ function. Without this fseek() call, on Solaris, HP-UX,
+ AIX, OSF/1, the previous input gets echoed, whereas on IRIX,
+ the following newline is not output as it should. */
+ if (out == in)
+ fseek (out, 0, SEEK_CUR);
+ putc ('\n', out);
+ }
}
}