1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-04 15:56:17 +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; sig = JANET_SIGNAL_USER0 + s;
} else { } else {
JanetKeyword kw = janet_getkeyword(argv, 0); JanetKeyword kw = janet_getkeyword(argv, 0);
if (!janet_cstrcmp(kw, "yield")) sig = JANET_SIGNAL_YIELD; if (!janet_cstrcmp(kw, "yield")) {
if (!janet_cstrcmp(kw, "error")) sig = JANET_SIGNAL_ERROR; sig = JANET_SIGNAL_YIELD;
if (!janet_cstrcmp(kw, "debug")) sig = JANET_SIGNAL_DEBUG; } else if (!janet_cstrcmp(kw, "error")) {
janet_panicf("unknown signal, expected :yield, :error, or :debug, got %v", argv[0]); 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 payload = argc == 2 ? argv[1] : janet_wrap_nil();
janet_signalv(sig, payload); janet_signalv(sig, payload);