add primitive caml_sys_isatty; fix bootstrap
(Simon Cruanes) git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16346 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
3211f63a31
commit
a69e3e3099
BIN
boot/ocamlc
BIN
boot/ocamlc
Binary file not shown.
BIN
boot/ocamldep
BIN
boot/ocamldep
Binary file not shown.
BIN
boot/ocamllex
BIN
boot/ocamllex
Binary file not shown.
|
@ -22,7 +22,9 @@
|
|||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#if !_WIN32
|
||||
#if _WIN32
|
||||
#include <io.h> /* for isatty */
|
||||
#else
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
#include "caml/config.h"
|
||||
|
@ -49,6 +51,7 @@
|
|||
#include "caml/stacks.h"
|
||||
#include "caml/sys.h"
|
||||
#include "caml/gc_ctrl.h"
|
||||
#include "caml/io.h"
|
||||
|
||||
static char * error_message(void)
|
||||
{
|
||||
|
@ -485,3 +488,20 @@ CAMLprim value caml_sys_read_directory(value path)
|
|||
caml_ext_table_free(&tbl, 1);
|
||||
CAMLreturn(result);
|
||||
}
|
||||
|
||||
/* Return true if the value is a filedescriptor (int) that is
|
||||
* (presumably) open on an interactive terminal */
|
||||
CAMLprim value caml_sys_isatty(value chan)
|
||||
{
|
||||
int fd;
|
||||
value ret;
|
||||
|
||||
fd = (Channel(chan))->fd;
|
||||
#ifdef _WIN32
|
||||
ret = Val_bool(_isatty(fd)); /* https://msdn.microsoft.com/en-us/library/f4s0ddew.aspx */
|
||||
#else
|
||||
ret = Val_bool(isatty(fd));
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue