From bb45012c3918a5cc17f36e72026112a34a5734c9 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 22 Apr 2018 11:48:38 +0200 Subject: [PATCH] mes: Add isatty?. * src/posix.c (isatty_p): New function. --- lib/libc.c | 2 +- src/posix.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/libc.c b/lib/libc.c index 97565c31..2819468c 100644 --- a/lib/libc.c +++ b/lib/libc.c @@ -424,7 +424,7 @@ sprintf (char *str, char const* format, ...) int isatty (int fd) { - return ioctl (fd, TCGETS, 0) == -14; // MAGIC + return ioctl (fd, TCGETS, 0) & 0xf0; } #endif //!POSIX diff --git a/src/posix.c b/src/posix.c index 2e6b3a8c..f0a020d9 100644 --- a/src/posix.c +++ b/src/posix.c @@ -199,3 +199,9 @@ force_output (SCM p) ///((arity . n)) { return cell_unspecified; } + +SCM +isatty_p (SCM port) +{ + return isatty (VALUE (port)) ? cell_t : cell_f; +}