mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Fix fmt.odin %#v fancy printing
This commit is contained in:
+5
-7
@@ -497,7 +497,7 @@ _fmt_int :: proc(fi: ^Fmt_Info, u: u128, base: int, is_signed: bool, bit_size: i
|
|||||||
switch base {
|
switch base {
|
||||||
case 2: c = 'b';
|
case 2: c = 'b';
|
||||||
case 8: c = 'o';
|
case 8: c = 'o';
|
||||||
case 10: c = 'd';
|
// case 10: c = 'd';
|
||||||
case 12: c = 'z';
|
case 12: c = 'z';
|
||||||
case 16: c = 'x';
|
case 16: c = 'x';
|
||||||
}
|
}
|
||||||
@@ -755,7 +755,6 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
|||||||
}
|
}
|
||||||
write_string(fi.buf, info.name);
|
write_string(fi.buf, info.name);
|
||||||
write_byte(fi.buf, '{');
|
write_byte(fi.buf, '{');
|
||||||
defer write_byte(fi.buf, '}');
|
|
||||||
|
|
||||||
hash := fi.hash; defer fi.hash = hash;
|
hash := fi.hash; defer fi.hash = hash;
|
||||||
indent := fi.indent; defer fi.indent -= 1;
|
indent := fi.indent; defer fi.indent -= 1;
|
||||||
@@ -767,11 +766,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
|||||||
|
|
||||||
for _, i in b.names {
|
for _, i in b.names {
|
||||||
if !hash && i > 0 do write_string(fi.buf, ", ");
|
if !hash && i > 0 do write_string(fi.buf, ", ");
|
||||||
if hash {
|
if hash do for in 0..fi.indent do write_byte(fi.buf, '\t');
|
||||||
for in 0..fi.indent {
|
|
||||||
write_byte(fi.buf, '\t');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
write_string(fi.buf, b.names[i]);
|
write_string(fi.buf, b.names[i]);
|
||||||
write_string(fi.buf, " = ");
|
write_string(fi.buf, " = ");
|
||||||
@@ -786,6 +781,9 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
|||||||
if hash do write_string(fi.buf, ",\n");
|
if hash do write_string(fi.buf, ",\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hash do for in 0..fi.indent do write_byte(fi.buf, '\t');
|
||||||
|
write_byte(fi.buf, '}');
|
||||||
|
|
||||||
case:
|
case:
|
||||||
fmt_value(fi, any{v.data, info.base}, verb);
|
fmt_value(fi, any{v.data, info.base}, verb);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -559,7 +559,7 @@ threading_example :: proc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
when false {
|
when true {
|
||||||
fmt.println("\n# general_stuff"); general_stuff();
|
fmt.println("\n# general_stuff"); general_stuff();
|
||||||
fmt.println("\n# default_struct_values"); default_struct_values();
|
fmt.println("\n# default_struct_values"); default_struct_values();
|
||||||
fmt.println("\n# union_type"); union_type();
|
fmt.println("\n# union_type"); union_type();
|
||||||
|
|||||||
Reference in New Issue
Block a user