1
0
mirror of https://github.com/janet-lang/janet synced 2025-02-03 18:59:09 +00:00

Remove REPL-within-form thread-local bool

This commit is contained in:
LouisJackman 2020-05-21 18:31:21 +01:00
parent 164ed0b325
commit f0572c4d5f
No known key found for this signature in database
GPG Key ID: C83A456999EEBC34
3 changed files with 2 additions and 32 deletions

View File

@ -33,12 +33,6 @@
extern const unsigned char *janet_gen_boot; extern const unsigned char *janet_gen_boot;
extern int32_t janet_gen_boot_size; extern int32_t janet_gen_boot_size;
static Janet janet_set_repl_within_form(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
(void) argv;
return janet_wrap_nil();
}
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
/* Init janet */ /* Init janet */
@ -59,8 +53,6 @@ int main(int argc, const char **argv) {
env = janet_core_env(NULL); env = janet_core_env(NULL);
janet_def(env, "set-repl-within-form", janet_wrap_cfunction(janet_set_repl_within_form), "");
/* Create args tuple */ /* Create args tuple */
JanetArray *args = janet_array(argc); JanetArray *args = janet_array(argc);
for (int i = 0; i < argc; i++) for (int i = 0; i < argc; i++)

View File

@ -2020,8 +2020,7 @@
(if (nil? (chunks buf p)) (if (nil? (chunks buf p))
(do (do
# Nil chunks represents a cancelled form in the REPL, so reset. # Nil chunks represents a cancelled form in the REPL, so reset.
(set-repl-within-form false) (parser/flush p)
(set p (parser/new))
(buffer/clear buf)) (buffer/clear buf))
(do (do
(var pindex 0) (var pindex 0)
@ -2030,11 +2029,7 @@
(when (= len 0) (when (= len 0)
(parser/eof p) (parser/eof p)
(set going false)) (set going false))
(if (= len 1)
(set-repl-within-form false)
(set-repl-within-form true))
(while (> len pindex) (while (> len pindex)
(set-repl-within-form true)
(+= pindex (parser/consume p buf pindex)) (+= pindex (parser/consume p buf pindex))
(while (parser/has-more p) (while (parser/has-more p)
(eval1 (parser/produce p))) (eval1 (parser/produce p)))

View File

@ -40,10 +40,8 @@ void janet_line_deinit();
void janet_line_get(const char *p, JanetBuffer *buffer); void janet_line_get(const char *p, JanetBuffer *buffer);
Janet janet_line_getter(int32_t argc, Janet *argv); Janet janet_line_getter(int32_t argc, Janet *argv);
static Janet janet_set_repl_within_form(int32_t argc, Janet *argv);
static JANET_THREAD_LOCAL bool gbl_cancel_current_repl_form = false; static JANET_THREAD_LOCAL bool gbl_cancel_current_repl_form = false;
static JANET_THREAD_LOCAL bool gbl_repl_within_form = false;
/* /*
* Line Editing * Line Editing
@ -86,12 +84,6 @@ static void simpleline(JanetBuffer *buffer) {
} }
} }
static Janet janet_set_repl_within_form(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
gbl_repl_within_form = janet_unwrap_boolean(argv[0]) != 0;
return janet_wrap_nil();
}
/* Windows */ /* Windows */
#ifdef JANET_WINDOWS #ifdef JANET_WINDOWS
@ -767,15 +759,7 @@ static int line() {
kleft(); kleft();
break; break;
case 3: /* ctrl-c */ case 3: /* ctrl-c */
if ( gbl_cancel_current_repl_form = true;
(gbl_len == 0)
&& !gbl_repl_within_form
) { /* quit on empty line */
errno = EAGAIN;
gbl_sigint_flag = 1;
} else { /* interrupt expression on non-empty line */
gbl_cancel_current_repl_form = true;
}
clearlines(); clearlines();
return -1; return -1;
case 4: /* ctrl-d, eof */ case 4: /* ctrl-d, eof */
@ -1023,7 +1007,6 @@ int main(int argc, char **argv) {
/* Replace original getline with new line getter */ /* Replace original getline with new line getter */
JanetTable *replacements = janet_table(0); JanetTable *replacements = janet_table(0);
janet_table_put(replacements, janet_csymbolv("getline"), janet_wrap_cfunction(janet_line_getter)); janet_table_put(replacements, janet_csymbolv("getline"), janet_wrap_cfunction(janet_line_getter));
janet_table_put(replacements, janet_csymbolv("set-repl-within-form"), janet_wrap_cfunction(janet_set_repl_within_form));
janet_line_init(); janet_line_init();
/* Get core env */ /* Get core env */