diff options
author | Koichi Sasada <ko1@atdot.net> | 2023-04-26 17:05:32 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-04-26 17:57:32 +0900 |
commit | 06b68db7cfd194de2c7c0bd45e18692f6f8a7b87 (patch) | |
tree | abb738cba3297e31f5d1362871bac65d549b20da /debug.c | |
parent | 457824e2d3ddebef6435d43e0a4b22f738f9fae4 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7761
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -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 |