aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-06-19 15:01:39 +0100
committergingerBill <bill@gingerbill.org>2020-06-19 15:01:39 +0100
commit3a4bbfcfae0084312edaabe8c408c40bc65d45e2 (patch)
tree4f308b594f5a297d6a988352e853c64f4e003331
parent01c84b32a67997206f97826087655c231f9f5ad9 (diff)
Change `fmt.*print` behaviour to match `fmt.*println` behaviour
-rw-r--r--core/fmt/fmt.odin24
1 files changed, 16 insertions, 8 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin
index 826840e37..c97f0f0cd 100644
--- a/core/fmt/fmt.odin
+++ b/core/fmt/fmt.odin
@@ -185,17 +185,25 @@ fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) {
sbprint :: proc(buf: ^strings.Builder, args: ..any) -> string {
fi: Info;
-
fi.buf = buf;
- prev_string := false;
- for arg, i in args {
- is_string := arg != nil && reflect.is_string(type_info_of(arg.id));
- if i > 0 && !is_string && !prev_string {
- strings.write_byte(buf, ' ');
- }
+ // NOTE(bill): Old approach
+ // prev_string := false;
+ // for arg, i in args {
+ // is_string := arg != nil && reflect.is_string(type_info_of(arg.id));
+ // if i > 0 && !is_string && !prev_string {
+ // strings.write_byte(buf, ' ');
+ // }
+ // fmt_value(&fi, args[i], 'v');
+ // prev_string = is_string;
+ // }
+ // NOTE(bill, 2020-06-19): I have found that the previous approach was not what people were expecting
+ // and were expecting `*print` to be the same `*println` except for the added newline
+ // so I am going to keep the same behaviour as `*println` for `*print`
+ for _, i in args {
+ if i > 0 do strings.write_byte(buf, ' ');
+
fmt_value(&fi, args[i], 'v');
- prev_string = is_string;
}
return strings.to_string(buf^);
}