delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/03/02/06:43:37

Date: Sun, 02 Mar 2003 11:46:15 +0000
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
Subject: Fix isatty after changing it to use _get_dev_info [PATCH]
Message-Id: <E18pRsO-0000Qu-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Here is a patch to fix isatty, after changing it to use _get_dev_info.
After Charles pointed out, it should not return -1 on error -
it should return 0.

Charles, if this looks OK, I will commit it quickly.

Bye, Rich =]

Index: src/libc/posix/unistd/isatty.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/isatty.c,v
retrieving revision 1.2
diff -p -c -3 -r1.2 isatty.c
*** src/libc/posix/unistd/isatty.c	1 Mar 2003 13:19:12 -0000	1.2
--- src/libc/posix/unistd/isatty.c	2 Mar 2003 11:40:49 -0000
*************** isatty(int fd)
*** 12,19 ****
  {
    const int dev_info = _get_dev_info(fd);
  
    if (dev_info == -1)
!     return -1;
  
    if ((dev_info & ISATTY_BITS) == ISATTY_BITS)
      return 1;
--- 12,20 ----
  {
    const int dev_info = _get_dev_info(fd);
  
+   /* Pass on errno from _get_dev_info. */
    if (dev_info == -1)
!     return 0;
  
    if ((dev_info & ISATTY_BITS) == ISATTY_BITS)
      return 1;
Index: tests/libc/posix/unistd/t-isatty.c
===================================================================
RCS file: /cvs/djgpp/djgpp/tests/libc/posix/unistd/t-isatty.c,v
retrieving revision 1.1
diff -p -c -3 -r1.1 t-isatty.c
*** tests/libc/posix/unistd/t-isatty.c	1 Mar 2003 13:17:36 -0000	1.1
--- tests/libc/posix/unistd/t-isatty.c	2 Mar 2003 11:40:49 -0000
*************** main (void)
*** 12,18 ****
    assert(!isatty(fileno(stdprn)));
  
    /* Check an invalid file descriptor. */
!   assert(isatty(99) < 0);
  
    puts("PASS");
    return(EXIT_SUCCESS);
--- 12,18 ----
    assert(!isatty(fileno(stdprn)));
  
    /* Check an invalid file descriptor. */
!   assert(!isatty(99));
  
    puts("PASS");
    return(EXIT_SUCCESS);
Index: src/docs/kb/wc204.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v
retrieving revision 1.144
diff -p -c -3 -r1.144 wc204.txi
*** src/docs/kb/wc204.txi	1 Mar 2003 14:38:26 -0000	1.144
--- src/docs/kb/wc204.txi	2 Mar 2003 11:41:00 -0000
*************** will inline to a single instruction when
*** 897,905 ****
  @code{chmod} and @code{chown} can now be hooked by File System Extensions.
  
  @findex isatty AT r{, and invalid file descriptors}
- 
  The function @code{isatty} now checks whether the file descriptor
! passed to it is a valid.  If not, it will fail and set @code{errno}
  to @code{EBADF}.
  
  @findex perror
--- 897,904 ----
  @code{chmod} and @code{chown} can now be hooked by File System Extensions.
  
  @findex isatty AT r{, and invalid file descriptors}
  The function @code{isatty} now checks whether the file descriptor
! passed to it is a valid.  If not, it will set @code{errno}
  to @code{EBADF}.
  
  @findex perror

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019