aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2023-04-26 17:05:32 +0900
committerKoichi Sasada <ko1@atdot.net>2023-04-26 17:57:32 +0900
commit06b68db7cfd194de2c7c0bd45e18692f6f8a7b87 (patch)
treeabb738cba3297e31f5d1362871bac65d549b20da /debug.c
parent457824e2d3ddebef6435d43e0a4b22f738f9fae4 (diff)
downloadruby-06b68db7cfd194de2c7c0bd45e18692f6f8a7b87.tar.gz
show a separator even if `ec` is NULL.
`RUBY_DEBUG_LOG()` doesn't show anything if `GET_EC()` returns NULL, but print a separator "\t" to make consistent TSV.
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/debug.c b/debug.c
index ed670a86b8..64cfa94f6a 100644
--- a/debug.c
+++ b/debug.c
@@ -540,20 +540,19 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
rb_execution_context_t *ec = rb_current_execution_context(false);
- if (ec) {
- // Ruby location
- int ruby_line;
- const char *ruby_file = rb_source_location_cstr(&ruby_line);
- if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- if (ruby_file) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
- }
- else {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
- }
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
- len += r;
+ // Ruby location
+ int ruby_line;
+ const char *ruby_file = ec ? rb_source_location_cstr(&ruby_line) : NULL;
+
+ if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ if (ruby_file) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
+ }
+ else {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
}
+ if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ len += r;
}
#ifdef RUBY_NT_SERIAL