mescc: Mes C Library: Fix isatty.
* lib/posix/isatty.c (isatty): Test ioctl == 0. * mes/module/mes/boot-0.scm.in: Update: no tty?: read from stdin.
This commit is contained in:
parent
d93b19f41f
commit
c5e098bc35
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -20,8 +20,56 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int
|
typedef unsigned char cc_t;
|
||||||
isatty (int fd)
|
typedef unsigned int speed_t;
|
||||||
|
typedef unsigned int tcflag_t;
|
||||||
|
|
||||||
|
// Use termio, termios2?
|
||||||
|
#define NCCS 19
|
||||||
|
struct termios
|
||||||
{
|
{
|
||||||
return ioctl (fd, TCGETS, 0) & 0xf0;
|
tcflag_t c_iflag;
|
||||||
|
tcflag_t c_oflag;
|
||||||
|
tcflag_t c_cflag;
|
||||||
|
tcflag_t c_lflag;
|
||||||
|
cc_t c_line;
|
||||||
|
cc_t c_cc[NCCS];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ktermios
|
||||||
|
{
|
||||||
|
tcflag_t c_iflag;
|
||||||
|
tcflag_t c_oflag;
|
||||||
|
tcflag_t c_cflag;
|
||||||
|
tcflag_t c_lflag;
|
||||||
|
cc_t c_line;
|
||||||
|
cc_t c_cc[NCCS];
|
||||||
|
speed_t c_ispeed;
|
||||||
|
speed_t c_ospeed;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
__tcgetattr (int filedes, struct termios *termios_p)
|
||||||
|
{
|
||||||
|
struct ktermios kernel_termios;
|
||||||
|
int r = ioctl (filedes, TCGETS, &kernel_termios);
|
||||||
|
|
||||||
|
termios_p->c_iflag = kernel_termios.c_iflag;
|
||||||
|
termios_p->c_oflag = kernel_termios.c_oflag;
|
||||||
|
termios_p->c_cflag = kernel_termios.c_cflag;
|
||||||
|
termios_p->c_lflag = kernel_termios.c_lflag;
|
||||||
|
termios_p->c_line = kernel_termios.c_line;
|
||||||
|
#if 0
|
||||||
|
termios_p->c_ispeed = kernel_termios.c_ispeed;
|
||||||
|
termios_p->c_ospeed = kernel_termios.c_ospeed;
|
||||||
|
#endif
|
||||||
|
memcpy (&termios_p->c_cc[0], &kernel_termios.c_cc[0], NCCS * sizeof (cc_t));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
isatty (int filedes)
|
||||||
|
{
|
||||||
|
struct termios term;
|
||||||
|
return __tcgetattr (filedes, &term) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@
|
||||||
(files (if s-index (list-tail %argv (+ s-index 1))
|
(files (if s-index (list-tail %argv (+ s-index 1))
|
||||||
(option-ref options '() '())))
|
(option-ref options '() '())))
|
||||||
(help? (option-ref options 'help #f))
|
(help? (option-ref options 'help #f))
|
||||||
(usage? (and (not help?) (null? files) (not tty?) (not main)))
|
(usage? #f)
|
||||||
(version? (option-ref options 'version #f)))
|
(version? (option-ref options 'version #f)))
|
||||||
(or
|
(or
|
||||||
(and version?
|
(and version?
|
||||||
|
|
Loading…
Reference in a new issue