mirror of
https://github.com/janet-lang/janet
synced 2024-12-23 15:00:27 +00:00
Address #1337 (leet!).
Changes a few scheduling details and adds a 0 byte explicitly to symbols created via gensym.
This commit is contained in:
parent
a0cb7514f1
commit
a10b4f61d8
@ -2031,33 +2031,35 @@ void janet_ev_default_threaded_callback(JanetEVGenericMessage return_value) {
|
||||
if (return_value.fiber == NULL) {
|
||||
return;
|
||||
}
|
||||
switch (return_value.tag) {
|
||||
default:
|
||||
case JANET_EV_TCTAG_NIL:
|
||||
janet_schedule(return_value.fiber, janet_wrap_nil());
|
||||
break;
|
||||
case JANET_EV_TCTAG_INTEGER:
|
||||
janet_schedule(return_value.fiber, janet_wrap_integer(return_value.argi));
|
||||
break;
|
||||
case JANET_EV_TCTAG_STRING:
|
||||
case JANET_EV_TCTAG_STRINGF:
|
||||
janet_schedule(return_value.fiber, janet_cstringv((const char *) return_value.argp));
|
||||
if (return_value.tag == JANET_EV_TCTAG_STRINGF) janet_free(return_value.argp);
|
||||
break;
|
||||
case JANET_EV_TCTAG_KEYWORD:
|
||||
janet_schedule(return_value.fiber, janet_ckeywordv((const char *) return_value.argp));
|
||||
break;
|
||||
case JANET_EV_TCTAG_ERR_STRING:
|
||||
case JANET_EV_TCTAG_ERR_STRINGF:
|
||||
janet_cancel(return_value.fiber, janet_cstringv((const char *) return_value.argp));
|
||||
if (return_value.tag == JANET_EV_TCTAG_STRINGF) janet_free(return_value.argp);
|
||||
break;
|
||||
case JANET_EV_TCTAG_ERR_KEYWORD:
|
||||
janet_cancel(return_value.fiber, janet_ckeywordv((const char *) return_value.argp));
|
||||
break;
|
||||
case JANET_EV_TCTAG_BOOLEAN:
|
||||
janet_schedule(return_value.fiber, janet_wrap_boolean(return_value.argi));
|
||||
break;
|
||||
if (janet_fiber_can_resume(return_value.fiber)) {
|
||||
switch (return_value.tag) {
|
||||
default:
|
||||
case JANET_EV_TCTAG_NIL:
|
||||
janet_schedule(return_value.fiber, janet_wrap_nil());
|
||||
break;
|
||||
case JANET_EV_TCTAG_INTEGER:
|
||||
janet_schedule(return_value.fiber, janet_wrap_integer(return_value.argi));
|
||||
break;
|
||||
case JANET_EV_TCTAG_STRING:
|
||||
case JANET_EV_TCTAG_STRINGF:
|
||||
janet_schedule(return_value.fiber, janet_cstringv((const char *) return_value.argp));
|
||||
if (return_value.tag == JANET_EV_TCTAG_STRINGF) janet_free(return_value.argp);
|
||||
break;
|
||||
case JANET_EV_TCTAG_KEYWORD:
|
||||
janet_schedule(return_value.fiber, janet_ckeywordv((const char *) return_value.argp));
|
||||
break;
|
||||
case JANET_EV_TCTAG_ERR_STRING:
|
||||
case JANET_EV_TCTAG_ERR_STRINGF:
|
||||
janet_cancel(return_value.fiber, janet_cstringv((const char *) return_value.argp));
|
||||
if (return_value.tag == JANET_EV_TCTAG_STRINGF) janet_free(return_value.argp);
|
||||
break;
|
||||
case JANET_EV_TCTAG_ERR_KEYWORD:
|
||||
janet_cancel(return_value.fiber, janet_ckeywordv((const char *) return_value.argp));
|
||||
break;
|
||||
case JANET_EV_TCTAG_BOOLEAN:
|
||||
janet_schedule(return_value.fiber, janet_wrap_boolean(return_value.argi));
|
||||
break;
|
||||
}
|
||||
}
|
||||
janet_gcunroot(janet_wrap_fiber(return_value.fiber));
|
||||
}
|
||||
|
@ -529,7 +529,9 @@ static void janet_proc_wait_cb(JanetEVGenericMessage args) {
|
||||
JanetString s = janet_formatc("command failed with non-zero exit code %d", status);
|
||||
janet_cancel(args.fiber, janet_wrap_string(s));
|
||||
} else {
|
||||
janet_schedule(args.fiber, janet_wrap_integer(status));
|
||||
if (janet_fiber_can_resume(args.fiber)) {
|
||||
janet_schedule(args.fiber, janet_wrap_integer(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,6 +233,7 @@ const uint8_t *janet_symbol_gen(void) {
|
||||
head->length = sizeof(janet_vm.gensym_counter) - 1;
|
||||
head->hash = hash;
|
||||
sym = (uint8_t *)(head->data);
|
||||
sym[head->length] = 0;
|
||||
memcpy(sym, janet_vm.gensym_counter, sizeof(janet_vm.gensym_counter));
|
||||
janet_symcache_put((const uint8_t *)sym, bucket);
|
||||
return (const uint8_t *)sym;
|
||||
|
Loading…
Reference in New Issue
Block a user