|
|
|
|
@ -9,6 +9,7 @@
@@ -9,6 +9,7 @@
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
#include <time.h> |
|
|
|
|
#include <unistd.h> |
|
|
|
|
|
|
|
|
|
#include <chibi/eval.h> |
|
|
|
|
@ -34,6 +35,7 @@ struct ftt_mapping
@@ -34,6 +35,7 @@ struct ftt_mapping
|
|
|
|
|
struct ftt_mapping *next; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static double g_wait_sec = 0; |
|
|
|
|
static int g_max_lines = 0; |
|
|
|
|
|
|
|
|
|
static struct ftt_mapping *gs_mappings; |
|
|
|
|
@ -318,10 +320,14 @@ static sexp display_exception(sexp ctx, sexp self, sexp_sint_t n, sexp arg0)
@@ -318,10 +320,14 @@ static sexp display_exception(sexp ctx, sexp self, sexp_sint_t n, sexp arg0)
|
|
|
|
|
|
|
|
|
|
static sexp sexp_sleep_stub(sexp ctx, sexp self, sexp_sint_t n, sexp arg0) |
|
|
|
|
{ |
|
|
|
|
struct timespec ts; |
|
|
|
|
sexp res; |
|
|
|
|
if (!sexp_numberp(arg0)) |
|
|
|
|
return sexp_type_exception(ctx, self, SEXP_NUMBER, arg0); |
|
|
|
|
sleep(sexp_uint_value(arg0)); |
|
|
|
|
if (!sexp_flonump(arg0)) |
|
|
|
|
return sexp_type_exception(ctx, self, SEXP_FLONUM, arg0); |
|
|
|
|
float sleep_sec = sexp_flonum_value(arg0); |
|
|
|
|
ts.tv_sec = sleep_sec; |
|
|
|
|
ts.tv_nsec = (sleep_sec - ts.tv_sec) * 1e9; |
|
|
|
|
nanosleep(&ts, NULL); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -579,7 +585,7 @@ static int register_sleep(sexp ctx)
@@ -579,7 +585,7 @@ static int register_sleep(sexp ctx)
|
|
|
|
|
if (sexp_opcodep(op)) |
|
|
|
|
{ |
|
|
|
|
sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_NULL); |
|
|
|
|
sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_NUMBER); |
|
|
|
|
sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_FLONUM); |
|
|
|
|
} |
|
|
|
|
sexp_gc_release1(ctx); |
|
|
|
|
|
|
|
|
|
@ -719,7 +725,7 @@ int main(int argc, char **argv)
@@ -719,7 +725,7 @@ int main(int argc, char **argv)
|
|
|
|
|
char filename[NAME_MAX] = {}; |
|
|
|
|
bool execute_script = false; |
|
|
|
|
bool show_symbols_in_file = false; |
|
|
|
|
while ((opt = getopt(argc, argv, "vhs:e:m:")) != -1) |
|
|
|
|
while ((opt = getopt(argc, argv, "vhs:e:m:l:")) != -1) |
|
|
|
|
{ |
|
|
|
|
switch (opt) |
|
|
|
|
{ |
|
|
|
|
@ -750,6 +756,16 @@ int main(int argc, char **argv)
@@ -750,6 +756,16 @@ int main(int argc, char **argv)
|
|
|
|
|
g_max_lines = atoi(optarg); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'w': |
|
|
|
|
{ |
|
|
|
|
char *end = NULL; |
|
|
|
|
const double wait_sec = strtod(optarg, &end); |
|
|
|
|
if (end != optarg) |
|
|
|
|
{ |
|
|
|
|
g_wait_sec = wait_sec; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'm': |
|
|
|
|
{ |
|
|
|
|
struct ftt_mapping *const mapping = parse_mapping(optarg); |
|
|
|
|
|