1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-20 15:44:49 +00:00

Merge pull request #349 from sogaiu/tweak-unknown-signal-handling

Tweak unknown signal handling
This commit is contained in:
Calvin Rose 2020-04-18 06:22:29 -05:00 committed by GitHub
commit 16fe0a301c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -500,10 +500,15 @@ static Janet janet_core_signal(int32_t argc, Janet *argv) {
sig = JANET_SIGNAL_USER0 + s;
} else {
JanetKeyword kw = janet_getkeyword(argv, 0);
if (!janet_cstrcmp(kw, "yield")) sig = JANET_SIGNAL_YIELD;
if (!janet_cstrcmp(kw, "error")) sig = JANET_SIGNAL_ERROR;
if (!janet_cstrcmp(kw, "debug")) sig = JANET_SIGNAL_DEBUG;
janet_panicf("unknown signal, expected :yield, :error, or :debug, got %v", argv[0]);
if (!janet_cstrcmp(kw, "yield")) {
sig = JANET_SIGNAL_YIELD;
} else if (!janet_cstrcmp(kw, "error")) {
sig = JANET_SIGNAL_ERROR;
} else if (!janet_cstrcmp(kw, "debug")) {
sig = JANET_SIGNAL_DEBUG;
} else {
janet_panicf("unknown signal, expected :yield, :error, or :debug, got %v", argv[0]);
}
}
Janet payload = argc == 2 ? argv[1] : janet_wrap_nil();
janet_signalv(sig, payload);