Move peg debug output to stderr in line with other internal debug tools.

Also allow disabling color in the debug output.
This commit is contained in:
Calvin Rose
2026-02-04 18:52:20 -06:00
parent 855d1f2940
commit b2bf70eace
3 changed files with 29 additions and 17 deletions
+1 -1
View File
@@ -460,7 +460,7 @@ Janet janet_dyn(const char *name) {
return janet_table_get(janet_vm.top_dyns, janet_ckeywordv(name));
}
if (janet_vm.fiber->env) {
return janet_table_get(janet_vm.fiber->env, janet_ckeywordv(name));
return janet_table_get_keyword(janet_vm.fiber->env, name);
} else {
return janet_wrap_nil();
}
+8 -2
View File
@@ -198,10 +198,16 @@ tail:
char buffer[32] = {0};
size_t len = (size_t)(s->outer_text_end - text);
memcpy(buffer, text, (len > 31 ? 31 : len));
janet_printf("\n?? at [%s]\nstack [%d]:\n", buffer, s->captures->count);
janet_eprintf("\n?? at [%s]\nstack [%d]:\n", buffer, s->captures->count);
int has_color = janet_truthy(janet_dyn("err-color"));
for (int32_t i = 0; i < s->captures->count; i++) {
janet_printf(" [%d]: %M\n", i, s->captures->data[i]);
if (has_color) {
janet_eprintf(" [%d]: %M\n", i, s->captures->data[i]);
} else {
janet_eprintf(" [%d]: %m\n", i, s->captures->data[i]);
}
}
janet_eprintf("\n");
return text;
}