From 059175de3bfab925085808989aadd909932b5c1d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 19 Apr 2024 13:32:55 +0100 Subject: [PATCH] Do not print column of a runtime.Source_Code_Location if the `column == 0` --- base/runtime/print.odin | 12 ++++++++---- core/fmt/fmt.odin | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/base/runtime/print.odin b/base/runtime/print.odin index 4e2ffaf80..ed5893e15 100644 --- a/base/runtime/print.odin +++ b/base/runtime/print.odin @@ -228,14 +228,18 @@ print_caller_location :: #force_no_inline proc "contextless" (loc: Source_Code_L when ODIN_ERROR_POS_STYLE == .Default { print_byte('(') print_u64(u64(loc.line)) - print_byte(':') - print_u64(u64(loc.column)) + if loc.column != 0 { + print_byte(':') + print_u64(u64(loc.column)) + } print_byte(')') } else when ODIN_ERROR_POS_STYLE == .Unix { print_byte(':') print_u64(u64(loc.line)) - print_byte(':') - print_u64(u64(loc.column)) + if loc.column != 0 { + print_byte(':') + print_u64(u64(loc.column)) + } print_byte(':') } else { #panic("unhandled ODIN_ERROR_POS_STYLE") diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index d3b9d7d69..547d59ce0 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -2156,14 +2156,18 @@ fmt_named :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Named) when ODIN_ERROR_POS_STYLE == .Default { io.write_byte(fi.writer, '(', &fi.n) io.write_int(fi.writer, int(a.line), 10, &fi.n) - io.write_byte(fi.writer, ':', &fi.n) - io.write_int(fi.writer, int(a.column), 10, &fi.n) + if a.column != 0 { + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.column), 10, &fi.n) + } io.write_byte(fi.writer, ')', &fi.n) } else when ODIN_ERROR_POS_STYLE == .Unix { io.write_byte(fi.writer, ':', &fi.n) io.write_int(fi.writer, int(a.line), 10, &fi.n) - io.write_byte(fi.writer, ':', &fi.n) - io.write_int(fi.writer, int(a.column), 10, &fi.n) + if a.column != 0 { + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.column), 10, &fi.n) + } io.write_byte(fi.writer, ':', &fi.n) } else { #panic("Unhandled ODIN_ERROR_POS_STYLE")