diff options
author | Bruce Momjian | 2006-03-04 04:31:05 +0000 |
---|---|---|
committer | Bruce Momjian | 2006-03-04 04:31:05 +0000 |
commit | 81de905774f3c6bb144b7a98ebde19eadec75a56 (patch) | |
tree | 4ae7e9004fda64128427bd9444d592b970fad7c0 | |
parent | 921e86cab628914537bfe0bc51fd89130ef30514 (diff) |
Use DEVTTY as 'con' on Win32 as a replacement for /dev/tty.
-rw-r--r-- | src/bin/psql/command.c | 6 | ||||
-rw-r--r-- | src/include/port.h | 3 | ||||
-rw-r--r-- | src/port/sprompt.c | 14 |
3 files changed, 8 insertions, 15 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index da84657fec..6027485148 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -753,11 +753,7 @@ exec_command(const char *cmd, expand_tilde(&fname); /* This scrolls off the screen when using /dev/tty */ -#ifndef WIN32 - success = saveHistory(fname ? fname : "/dev/tty"); -#else - success = saveHistory(fname ? fname : stderr); -#endif + success = saveHistory(fname ? fname : DEVTTY); if (success && !quiet && fname) printf(gettext("Wrote history to file \"%s/%s\".\n"), pset.dirname ? pset.dirname : ".", fname); diff --git a/src/include/port.h b/src/include/port.h index cb2d99fb04..ba80a1bdda 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -84,8 +84,11 @@ extern int find_other_exec(const char *argv0, const char *target, #if defined(WIN32) && !defined(__CYGWIN__) #define DEVNULL "nul" +/* "con" does not work from the MinGW 1.0.10 console. */ +#define DEVTTY "con" #else #define DEVNULL "/dev/null" +#define DEVTTY "/dev/tty" #endif /* diff --git a/src/port/sprompt.c b/src/port/sprompt.c index 2211f813ef..a202882922 100644 --- a/src/port/sprompt.c +++ b/src/port/sprompt.c @@ -40,8 +40,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) { int length; char *destination; - FILE *termin = NULL, - *termout = NULL; + FILE *termin, + *termout; #ifdef HAVE_TERMIOS_H struct termios t_orig, @@ -63,14 +63,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) * Do not try to collapse these into one "w+" mode file. Doesn't work on * some platforms (eg, HPUX 10.20). */ -#ifndef WIN32 - /* - * Some win32 platforms actually have a /dev/tty file, but it isn't - * a device file, and it doesn't work as expected, so we avoid trying. - */ - termin = fopen("/dev/tty", "r"); - termout = fopen("/dev/tty", "w"); -#endif + termin = fopen(DEVTTY, "r"); + termout = fopen(DEVTTY, "w"); if (!termin || !termout) { if (termin) |