Fix for /dev/tty on Win32

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Fix for /dev/tty on Win32
Дата
Msg-id 200603040437.k244bu224602@candle.pha.pa.us
обсуждение исходный текст
Ответы Re: Fix for /dev/tty on Win32  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-patches
I found a better solution to the /dev/tty on Win32.  I used 'con' which
works fine on Win32 except using the Msys 1.0.10 console, but it is
probably the best solution.  Can someone test if newer Msys consoles
work with this?

Added DEVTTY macro for simplicity.

Applied to 8.0.X, 8.1.X, and HEAD.

--
  Bruce Momjian   http://candle.pha.pa.us
  SRA OSS, Inc.   http://www.sraoss.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/psql/command.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.162
diff -c -c -r1.162 command.c
*** src/bin/psql/command.c    3 Mar 2006 23:49:12 -0000    1.162
--- src/bin/psql/command.c    4 Mar 2006 04:29:53 -0000
***************
*** 753,763 ****

          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
          if (success && !quiet && fname)
              printf(gettext("Wrote history to file \"%s/%s\".\n"),
                     pset.dirname ? pset.dirname : ".", fname);
--- 753,759 ----

          expand_tilde(&fname);
          /* This scrolls off the screen when using /dev/tty */
!         success = saveHistory(fname ? fname : DEVTTY);
          if (success && !quiet && fname)
              printf(gettext("Wrote history to file \"%s/%s\".\n"),
                     pset.dirname ? pset.dirname : ".", fname);
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/port.h,v
retrieving revision 1.87
diff -c -c -r1.87 port.h
*** src/include/port.h    6 Dec 2005 18:35:10 -0000    1.87
--- src/include/port.h    4 Mar 2006 04:29:54 -0000
***************
*** 84,91 ****
--- 84,94 ----

  #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

  /*
Index: src/port/sprompt.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/sprompt.c,v
retrieving revision 1.13
diff -c -c -r1.13 sprompt.c
*** src/port/sprompt.c    3 Mar 2006 23:49:12 -0000    1.13
--- src/port/sprompt.c    4 Mar 2006 04:29:54 -0000
***************
*** 40,47 ****
  {
      int            length;
      char       *destination;
!     FILE       *termin = NULL,
!                *termout = NULL;

  #ifdef HAVE_TERMIOS_H
      struct termios t_orig,
--- 40,47 ----
  {
      int            length;
      char       *destination;
!     FILE       *termin,
!                *termout;

  #ifdef HAVE_TERMIOS_H
      struct termios t_orig,
***************
*** 63,76 ****
       * 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
      if (!termin || !termout)
      {
          if (termin)
--- 63,70 ----
       * Do not try to collapse these into one "w+" mode file. Doesn't work on
       * some platforms (eg, HPUX 10.20).
       */
!     termin = fopen(DEVTTY, "r");
!     termout = fopen(DEVTTY, "w");
      if (!termin || !termout)
      {
          if (termin)

В списке pgsql-patches по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: OS X shared memory documentation
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] ACCESS EXCLUSIVE LOCK