is-a-tty?

This commit is contained in:
Alex Shinn 2009-12-31 13:40:23 +09:00
parent 5469e699b6
commit 36732f9134
3 changed files with 11 additions and 2 deletions

View file

@ -20,7 +20,7 @@
open/read open/write open/read-write
open/create open/exclusive open/truncate
open/append open/non-block
)
is-a-tty?)
(import-immutable (scheme))
(include-shared "filesystem")
(include "filesystem.scm"))

View file

@ -113,3 +113,6 @@
(define-c-const int (open/truncate "O_TRUNC"))
(define-c-const int (open/append "O_APPEND"))
(define-c-const int (open/non-block "O_NONBLOCK"))
(define-c boolean (is-a-tty? "isatty") (port-or-fd))

View file

@ -507,7 +507,10 @@
(cat "sexp_concat_env_string(" val ")"))
((string-type? base)
(cat "sexp_string_data(" val ")"))
((memq base '(port input-port output-port))
((eq? base 'port-or-fd)
(cat "(sexp_portp(" val ") ? fileno(sexp_port_stream(" val "))"
" : sexp_unbox_fixnum(" val "))"))
((port-type? base)
(cat "sexp_port_stream(" val ")"))
(else
(let ((ctype (assq base *types*)))
@ -607,6 +610,9 @@
(cat " if (! sexp_nullp(res))\n"
" return sexp_type_exception(ctx, \"not a list of "
(type-name type) "s\", " arg ");\n")))
((eq? base-type 'port-or-fd)
(cat "if (! (sexp_portp(" arg ") || sexp_fixnump(" arg ")))\n"
" return sexp_type_exception(ctx, \"not a port of file descriptor\"," arg ");\n"))
((or (int-type? base-type)
(float-type? base-type)
(string-type? base-type)