Browse Source

Do not print column of a runtime.Source_Code_Location if the `column == 0`

gingerBill 1 year ago
parent
commit
059175de3b
2 changed files with 16 additions and 8 deletions
  1. 8 4
      base/runtime/print.odin
  2. 8 4
      core/fmt/fmt.odin

+ 8 - 4
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 {
 	when ODIN_ERROR_POS_STYLE == .Default {
 		print_byte('(')
 		print_byte('(')
 		print_u64(u64(loc.line))
 		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(')')
 		print_byte(')')
 	} else when ODIN_ERROR_POS_STYLE == .Unix {
 	} else when ODIN_ERROR_POS_STYLE == .Unix {
 		print_byte(':')
 		print_byte(':')
 		print_u64(u64(loc.line))
 		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(':')
 		print_byte(':')
 	} else {
 	} else {
 		#panic("unhandled ODIN_ERROR_POS_STYLE")
 		#panic("unhandled ODIN_ERROR_POS_STYLE")

+ 8 - 4
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 {
 			when ODIN_ERROR_POS_STYLE == .Default {
 				io.write_byte(fi.writer, '(', &fi.n)
 				io.write_byte(fi.writer, '(', &fi.n)
 				io.write_int(fi.writer, int(a.line), 10, &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)
 				io.write_byte(fi.writer, ')', &fi.n)
 			} else when ODIN_ERROR_POS_STYLE == .Unix {
 			} else when ODIN_ERROR_POS_STYLE == .Unix {
 				io.write_byte(fi.writer, ':', &fi.n)
 				io.write_byte(fi.writer, ':', &fi.n)
 				io.write_int(fi.writer, int(a.line), 10, &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)
 				io.write_byte(fi.writer, ':', &fi.n)
 			} else {
 			} else {
 				#panic("Unhandled ODIN_ERROR_POS_STYLE")
 				#panic("Unhandled ODIN_ERROR_POS_STYLE")