aboutsummaryrefslogtreecommitdiff
path: root/core/fmt.odin
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-01-27 17:43:42 +0000
committerGinger Bill <bill@gingerbill.org>2017-01-27 17:43:42 +0000
commit92453369c5558feaaaa116fbc54968b087e1aeab (patch)
treea00501fdc52f69c7dd7c415e103b9b13d51e6ad5 /core/fmt.odin
parent832009f33acc573d44dd9dfb470ad8fef72216ff (diff)
Remove while loop and readd c-style for loops i.e. all loops are just `for`
Diffstat (limited to 'core/fmt.odin')
-rw-r--r--core/fmt.odin13
1 files changed, 6 insertions, 7 deletions
diff --git a/core/fmt.odin b/core/fmt.odin
index f7c11015e..bd11d05e0 100644
--- a/core/fmt.odin
+++ b/core/fmt.odin
@@ -460,7 +460,7 @@ fmt_integer :: proc(fi: ^Fmt_Info, u: u64, base: int, signed: bool, digits: stri
panic("fmt_integer: unknown base, whoops");
}
- while b := cast(u64)base; u >= b {
+ for b := cast(u64)base; u >= b; {
i -= 1;
next := u / b;
buf[i] = digits[u%b];
@@ -468,7 +468,7 @@ fmt_integer :: proc(fi: ^Fmt_Info, u: u64, base: int, signed: bool, digits: stri
}
i -= 1;
buf[i] = digits[u];
- while i > 0 && prec > buf.count-i {
+ for i > 0 && prec > buf.count-i {
i -= 1;
buf[i] = '0';
}
@@ -598,7 +598,7 @@ fmt_float :: proc(fi: ^Fmt_Info, v: f64, bit_size: int, verb: rune) {
case fi.space: fill = ' ';
}
- while width > 0 {
+ for width > 0 {
width -= 1;
buffer_write_byte(fi.buf, fill);
}
@@ -885,11 +885,11 @@ bprintf :: proc(b: ^Buffer, fmt: string, args: ..any) -> int {
end := fmt.count;
arg_index := 0;
was_prev_index := false;
- while i := 0; i < end {
+ for i := 0; i < end; {
fi = Fmt_Info{buf = b, good_arg_index = true};
prev_i := i;
- while i < end && fmt[i] != '%' {
+ for i < end && fmt[i] != '%' {
i += 1;
}
if i > prev_i {
@@ -903,7 +903,7 @@ bprintf :: proc(b: ^Buffer, fmt: string, args: ..any) -> int {
i += 1;
- while i < end {
+ for ; i < end; i += 1 {
skip_loop := false;
c := fmt[i];
match c {
@@ -925,7 +925,6 @@ bprintf :: proc(b: ^Buffer, fmt: string, args: ..any) -> int {
if skip_loop {
break;
}
- i += 1;
}
arg_index, i, was_prev_index = arg_number(^fi, arg_index, fmt, i, args.count);