mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 22:59:16 +02:00
is-a-tty?
This commit is contained in:
parent
5469e699b6
commit
36732f9134
3 changed files with 11 additions and 2 deletions
|
@ -20,7 +20,7 @@
|
||||||
open/read open/write open/read-write
|
open/read open/write open/read-write
|
||||||
open/create open/exclusive open/truncate
|
open/create open/exclusive open/truncate
|
||||||
open/append open/non-block
|
open/append open/non-block
|
||||||
)
|
is-a-tty?)
|
||||||
(import-immutable (scheme))
|
(import-immutable (scheme))
|
||||||
(include-shared "filesystem")
|
(include-shared "filesystem")
|
||||||
(include "filesystem.scm"))
|
(include "filesystem.scm"))
|
||||||
|
|
|
@ -113,3 +113,6 @@
|
||||||
(define-c-const int (open/truncate "O_TRUNC"))
|
(define-c-const int (open/truncate "O_TRUNC"))
|
||||||
(define-c-const int (open/append "O_APPEND"))
|
(define-c-const int (open/append "O_APPEND"))
|
||||||
(define-c-const int (open/non-block "O_NONBLOCK"))
|
(define-c-const int (open/non-block "O_NONBLOCK"))
|
||||||
|
|
||||||
|
(define-c boolean (is-a-tty? "isatty") (port-or-fd))
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,10 @@
|
||||||
(cat "sexp_concat_env_string(" val ")"))
|
(cat "sexp_concat_env_string(" val ")"))
|
||||||
((string-type? base)
|
((string-type? base)
|
||||||
(cat "sexp_string_data(" val ")"))
|
(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 ")"))
|
(cat "sexp_port_stream(" val ")"))
|
||||||
(else
|
(else
|
||||||
(let ((ctype (assq base *types*)))
|
(let ((ctype (assq base *types*)))
|
||||||
|
@ -607,6 +610,9 @@
|
||||||
(cat " if (! sexp_nullp(res))\n"
|
(cat " if (! sexp_nullp(res))\n"
|
||||||
" return sexp_type_exception(ctx, \"not a list of "
|
" return sexp_type_exception(ctx, \"not a list of "
|
||||||
(type-name type) "s\", " arg ");\n")))
|
(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)
|
((or (int-type? base-type)
|
||||||
(float-type? base-type)
|
(float-type? base-type)
|
||||||
(string-type? base-type)
|
(string-type? base-type)
|
||||||
|
|
Loading…
Add table
Reference in a new issue