mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
do keyword for inline statements instead of blocks
This commit is contained in:
+30
-49
@@ -118,7 +118,7 @@ __argc__: i32;
|
||||
|
||||
|
||||
type_info_base :: proc(info: ^TypeInfo) -> ^TypeInfo {
|
||||
if info == nil -> return nil;
|
||||
if info == nil do return nil;
|
||||
|
||||
base := info;
|
||||
match i in base {
|
||||
@@ -130,7 +130,7 @@ type_info_base :: proc(info: ^TypeInfo) -> ^TypeInfo {
|
||||
|
||||
|
||||
type_info_base_without_enum :: proc(info: ^TypeInfo) -> ^TypeInfo {
|
||||
if info == nil -> return nil;
|
||||
if info == nil do return nil;
|
||||
|
||||
base := info;
|
||||
match i in base {
|
||||
@@ -195,7 +195,7 @@ make_source_code_location :: proc(file: string, line, column: i64, procedure: st
|
||||
DEFAULT_ALIGNMENT :: align_of([vector 4]f32);
|
||||
|
||||
__init_context_from_ptr :: proc(c: ^Context, other: ^Context) #cc_contextless {
|
||||
if c == nil -> return;
|
||||
if c == nil do return;
|
||||
c^ = other^;
|
||||
|
||||
if c.allocator.procedure == nil {
|
||||
@@ -207,7 +207,7 @@ __init_context_from_ptr :: proc(c: ^Context, other: ^Context) #cc_contextless {
|
||||
}
|
||||
|
||||
__init_context :: proc(c: ^Context) #cc_contextless {
|
||||
if c == nil -> return;
|
||||
if c == nil do return;
|
||||
|
||||
if c.allocator.procedure == nil {
|
||||
c.allocator = default_allocator();
|
||||
@@ -259,30 +259,22 @@ resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_AL
|
||||
}
|
||||
|
||||
|
||||
new :: proc(T: type) -> ^T #inline {
|
||||
return ^T(alloc(size_of(T), align_of(T)));
|
||||
}
|
||||
new :: proc(T: type) -> ^T #inline do return ^T(alloc(size_of(T), align_of(T)));
|
||||
|
||||
|
||||
|
||||
default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment: int) -> rawptr {
|
||||
if old_memory == nil {
|
||||
return alloc(new_size, alignment);
|
||||
}
|
||||
if old_memory == nil do return alloc(new_size, alignment);
|
||||
|
||||
if new_size == 0 {
|
||||
free(old_memory);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if new_size == old_size {
|
||||
return old_memory;
|
||||
}
|
||||
if new_size == old_size do return old_memory;
|
||||
|
||||
new_memory := alloc(new_size, alignment);
|
||||
if new_memory == nil {
|
||||
return nil;
|
||||
}
|
||||
if new_memory == nil do return nil;
|
||||
|
||||
__mem_copy(new_memory, old_memory, min(old_size, new_size));;
|
||||
free(old_memory);
|
||||
@@ -326,9 +318,9 @@ default_allocator :: proc() -> Allocator {
|
||||
assert :: proc(condition: bool, message := "", using location := #caller_location) -> bool #cc_contextless {
|
||||
if !condition {
|
||||
if len(message) > 0 {
|
||||
fmt.printf("%s(%d:%d) Runtime assertion: %s\n", fully_pathed_filename, line, column, message);
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Runtime assertion: %s\n", fully_pathed_filename, line, column, message);
|
||||
} else {
|
||||
fmt.printf("%s(%d:%d) Runtime assertion\n", fully_pathed_filename, line, column);
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Runtime assertion\n", fully_pathed_filename, line, column);
|
||||
}
|
||||
__debug_trap();
|
||||
}
|
||||
@@ -337,9 +329,9 @@ assert :: proc(condition: bool, message := "", using location := #caller_locatio
|
||||
|
||||
panic :: proc(message := "", using location := #caller_location) #cc_contextless {
|
||||
if len(message) > 0 {
|
||||
fmt.printf("%s(%d:%d) Panic: %s\n", fully_pathed_filename, line, column, message);
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Panic: %s\n", fully_pathed_filename, line, column, message);
|
||||
} else {
|
||||
fmt.printf("%s(%d:%d) Panic\n", fully_pathed_filename, line, column);
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Panic\n", fully_pathed_filename, line, column);
|
||||
}
|
||||
__debug_trap();
|
||||
}
|
||||
@@ -348,14 +340,10 @@ panic :: proc(message := "", using location := #caller_location) #cc_contextless
|
||||
|
||||
|
||||
__string_eq :: proc(a, b: string) -> bool #cc_contextless {
|
||||
if len(a) != len(b) {
|
||||
return false;
|
||||
}
|
||||
if len(a) == 0 {
|
||||
return true;
|
||||
}
|
||||
if &a[0] == &b[0] {
|
||||
return true;
|
||||
match {
|
||||
case len(a) != len(b): return false;
|
||||
case len(a) == 0: return true;
|
||||
case &a[0] == &b[0]: return true;
|
||||
}
|
||||
return __string_cmp(a, b) == 0;
|
||||
}
|
||||
@@ -379,37 +367,30 @@ __complex128_ne :: proc(a, b: complex128) -> bool #cc_contextless #inline { retu
|
||||
|
||||
|
||||
__bounds_check_error :: proc(file: string, line, column: int, index, count: int) #cc_contextless {
|
||||
if 0 <= index && index < count {
|
||||
return;
|
||||
}
|
||||
if 0 <= index && index < count do return;
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Index %d is out of bounds range 0..<%d\n",
|
||||
file, line, column, index, count);
|
||||
__debug_trap();
|
||||
}
|
||||
|
||||
__slice_expr_error :: proc(file: string, line, column: int, low, high, max: int) #cc_contextless {
|
||||
if 0 <= low && low <= high && high <= max {
|
||||
return;
|
||||
}
|
||||
if 0 <= low && low <= high && high <= max do return;
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Invalid slice indices: [%d..<%d..<%d]\n",
|
||||
file, line, column, low, high, max);
|
||||
__debug_trap();
|
||||
}
|
||||
|
||||
__substring_expr_error :: proc(file: string, line, column: int, low, high: int) #cc_contextless {
|
||||
if 0 <= low && low <= high {
|
||||
return;
|
||||
}
|
||||
if 0 <= low && low <= high do return;
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Invalid substring indices: [%d..<%d]\n",
|
||||
file, line, column, low, high);
|
||||
__debug_trap();
|
||||
}
|
||||
__type_assertion_check :: proc(ok: bool, file: string, line, column: int, from, to: ^TypeInfo) #cc_contextless {
|
||||
if !ok {
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Invalid type_assertion from %T to %T\n",
|
||||
file, line, column, from, to);
|
||||
__debug_trap();
|
||||
}
|
||||
if ok do return;
|
||||
fmt.fprintf(os.stderr, "%s(%d:%d) Invalid type_assertion from %T to %T\n",
|
||||
file, line, column, from, to);
|
||||
__debug_trap();
|
||||
}
|
||||
|
||||
__string_decode_rune :: proc(s: string) -> (rune, int) #cc_contextless #inline {
|
||||
@@ -499,7 +480,7 @@ __dynamic_array_make :: proc(array_: rawptr, elem_size, elem_align: int, len, ca
|
||||
__dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap: int) -> bool {
|
||||
array := ^raw.DynamicArray(array_);
|
||||
|
||||
if cap <= array.cap -> return true;
|
||||
if cap <= array.cap do return true;
|
||||
|
||||
// __check_context();
|
||||
if array.allocator.procedure == nil {
|
||||
@@ -512,7 +493,7 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap:
|
||||
allocator := array.allocator;
|
||||
|
||||
new_data := allocator.procedure(allocator.data, AllocatorMode.Resize, new_size, elem_align, array.data, old_size, 0);
|
||||
if new_data == nil -> return false;
|
||||
if new_data == nil do return false;
|
||||
|
||||
array.data = new_data;
|
||||
array.cap = cap;
|
||||
@@ -523,7 +504,7 @@ __dynamic_array_resize :: proc(array_: rawptr, elem_size, elem_align: int, len:
|
||||
array := ^raw.DynamicArray(array_);
|
||||
|
||||
ok := __dynamic_array_reserve(array_, elem_size, elem_align, len);
|
||||
if ok -> array.len = len;
|
||||
if ok do array.len = len;
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -543,7 +524,7 @@ __dynamic_array_append :: proc(array_: rawptr, elem_size, elem_align: int,
|
||||
ok = __dynamic_array_reserve(array, elem_size, elem_align, cap);
|
||||
}
|
||||
// TODO(bill): Better error handling for failed reservation
|
||||
if !ok -> return array.len;
|
||||
if !ok do return array.len;
|
||||
|
||||
data := ^u8(array.data);
|
||||
assert(data != nil);
|
||||
@@ -561,7 +542,7 @@ __dynamic_array_append_nothing :: proc(array_: rawptr, elem_size, elem_align: in
|
||||
ok = __dynamic_array_reserve(array, elem_size, elem_align, cap);
|
||||
}
|
||||
// TODO(bill): Better error handling for failed reservation
|
||||
if !ok -> return array.len;
|
||||
if !ok do return array.len;
|
||||
|
||||
data := ^u8(array.data);
|
||||
assert(data != nil);
|
||||
@@ -650,7 +631,7 @@ __dynamic_map_rehash :: proc(using header: __MapHeader, new_count: int) {
|
||||
|
||||
__dynamic_array_resize(nm_hashes, size_of(int), align_of(int), new_count);
|
||||
__dynamic_array_reserve(&nm.entries, entry_size, entry_align, m.entries.len);
|
||||
for i in 0..<new_count -> nm.hashes[i] = -1;
|
||||
for i in 0..<new_count do nm.hashes[i] = -1;
|
||||
|
||||
for i := 0; i < m.entries.len; i++ {
|
||||
if len(nm.hashes) == 0 {
|
||||
@@ -740,7 +721,7 @@ __dynamic_map_full :: proc(using h: __MapHeader) -> bool {
|
||||
|
||||
__dynamic_map_hash_equal :: proc(h: __MapHeader, a, b: __MapKey) -> bool {
|
||||
if a.hash == b.hash {
|
||||
if h.is_key_string -> return a.str == b.str;
|
||||
if h.is_key_string do return a.str == b.str;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -98,7 +98,7 @@ __u128_quo_mod :: proc(a, b: u128, rem: ^u128) -> (quo: u128) #cc_c #link_name "
|
||||
d >>= 1;
|
||||
}
|
||||
|
||||
if rem != nil { rem^ = r; }
|
||||
if rem != nil do rem^ = r;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ Decimal :: struct {
|
||||
|
||||
decimal_to_string :: proc(buf: []u8, a: ^Decimal) -> string {
|
||||
digit_zero :: proc(buf: []u8) -> int {
|
||||
for _, i in buf -> buf[i] = '0';
|
||||
for _, i in buf do buf[i] = '0';
|
||||
return len(buf);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ shift :: proc(a: ^Decimal, k: int) {
|
||||
can_round_up :: proc(a: ^Decimal, nd: int) -> bool {
|
||||
if nd < 0 || nd >= a.count { return false ; }
|
||||
if a.digits[nd] == '5' && nd+1 == a.count {
|
||||
if a.trunc -> return true;
|
||||
if a.trunc do return true;
|
||||
return nd > 0 && (a.digits[nd-1]-'0')%2 != 0;
|
||||
}
|
||||
|
||||
|
||||
+33
-33
@@ -189,7 +189,7 @@ fprint_type :: proc(fd: os.Handle, info: ^TypeInfo) {
|
||||
}
|
||||
|
||||
write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
if ti == nil -> return;
|
||||
if ti == nil do return;
|
||||
|
||||
using TypeInfo;
|
||||
match info in ti {
|
||||
@@ -240,7 +240,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
t := info.params.(^Tuple);
|
||||
write_string(buf, "(");
|
||||
for t, i in t.types {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
write_type(buf, t);
|
||||
}
|
||||
write_string(buf, ")");
|
||||
@@ -251,9 +251,9 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
}
|
||||
case Tuple:
|
||||
count := len(info.names);
|
||||
if count != 1 -> write_string(buf, "(");
|
||||
if count != 1 do write_string(buf, "(");
|
||||
for name, i in info.names {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
|
||||
t := info.types[i];
|
||||
|
||||
@@ -263,7 +263,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
}
|
||||
write_type(buf, t);
|
||||
}
|
||||
if count != 1 -> write_string(buf, ")");
|
||||
if count != 1 do write_string(buf, ")");
|
||||
|
||||
case Array:
|
||||
write_string(buf, "[");
|
||||
@@ -291,8 +291,8 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
|
||||
case Struct:
|
||||
write_string(buf, "struct ");
|
||||
if info.packed -> write_string(buf, "#packed ");
|
||||
if info.ordered -> write_string(buf, "#ordered ");
|
||||
if info.packed do write_string(buf, "#packed ");
|
||||
if info.ordered do write_string(buf, "#ordered ");
|
||||
if info.custom_align {
|
||||
write_string(buf, "#align ");
|
||||
write_int(buf, i64(info.align), 10);
|
||||
@@ -300,7 +300,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
}
|
||||
write_byte(buf, '{');
|
||||
for name, i in info.names {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
write_string(buf, name);
|
||||
write_string(buf, ": ");
|
||||
write_type(buf, info.types[i]);
|
||||
@@ -312,14 +312,14 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
cf := info.common_fields;
|
||||
total_count := 0;
|
||||
for name, i in cf.names {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
write_string(buf, name);
|
||||
write_string(buf, ": ");
|
||||
write_type(buf, cf.types[i]);
|
||||
total_count++;
|
||||
}
|
||||
for name, i in info.variant_names {
|
||||
if total_count > 0 || i > 0 -> write_string(buf, ", ");
|
||||
if total_count > 0 || i > 0 do write_string(buf, ", ");
|
||||
write_string(buf, name);
|
||||
write_byte(buf, '{');
|
||||
defer write_byte(buf, '}');
|
||||
@@ -329,7 +329,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
|
||||
vc := len(variant.names)-len(cf.names);
|
||||
for j in 0..<vc {
|
||||
if j > 0 -> write_string(buf, ", ");
|
||||
if j > 0 do write_string(buf, ", ");
|
||||
index := j + len(cf.names);
|
||||
write_string(buf, variant.names[index]);
|
||||
write_string(buf, ": ");
|
||||
@@ -341,7 +341,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
case RawUnion:
|
||||
write_string(buf, "raw_union {");
|
||||
for name, i in info.names {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
write_string(buf, name);
|
||||
write_string(buf, ": ");
|
||||
write_type(buf, info.types[i]);
|
||||
@@ -353,7 +353,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
write_type(buf, info.base);
|
||||
write_string(buf, " {");
|
||||
for name, i in info.names {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
write_string(buf, name);
|
||||
}
|
||||
write_string(buf, "}");
|
||||
@@ -366,7 +366,7 @@ write_type :: proc(buf: ^StringBuffer, ti: ^TypeInfo) {
|
||||
}
|
||||
write_string(buf, " {");
|
||||
for name, i in info.names {
|
||||
if i > 0 -> write_string(buf, ", ");
|
||||
if i > 0 do write_string(buf, ", ");
|
||||
write_string(buf, name);
|
||||
write_string(buf, ": ");
|
||||
write_int(buf, i64(info.bits[i]), 10);
|
||||
@@ -388,7 +388,7 @@ _parse_int :: proc(s: string, offset: int) -> (result: int, offset: int, ok: boo
|
||||
i := 0;
|
||||
for i < len(s[offset..]) {
|
||||
c := rune(s[offset+i]);
|
||||
if !is_digit(c) -> break;
|
||||
if !is_digit(c) do break;
|
||||
i++;
|
||||
|
||||
result *= 10;
|
||||
@@ -482,13 +482,13 @@ fmt_bool :: proc(using fi: ^FmtInfo, b: bool, verb: rune) {
|
||||
|
||||
|
||||
fmt_write_padding :: proc(fi: ^FmtInfo, width: int) {
|
||||
if width <= 0 -> return;
|
||||
if width <= 0 do return;
|
||||
|
||||
pad_byte: u8 = fi.space ? ' ' : '0';
|
||||
|
||||
data := string_buffer_data(fi.buf^);
|
||||
count := min(width, cap(data)-len(data));
|
||||
for _ in 0..<count -> write_byte(fi.buf, pad_byte);
|
||||
for _ in 0..<count do write_byte(fi.buf, pad_byte);
|
||||
}
|
||||
|
||||
_fmt_int :: proc(fi: ^FmtInfo, u: u128, base: int, is_signed: bool, bit_size: int, digits: string) {
|
||||
@@ -533,9 +533,9 @@ _fmt_int :: proc(fi: ^FmtInfo, u: u128, base: int, is_signed: bool, bit_size: in
|
||||
|
||||
|
||||
flags: strconv.IntFlag;
|
||||
if fi.hash && !fi.zero -> flags |= strconv.IntFlag.Prefix;
|
||||
if fi.plus -> flags |= strconv.IntFlag.Plus;
|
||||
if fi.space -> flags |= strconv.IntFlag.Space;
|
||||
if fi.hash && !fi.zero do flags |= strconv.IntFlag.Prefix;
|
||||
if fi.plus do flags |= strconv.IntFlag.Plus;
|
||||
if fi.space do flags |= strconv.IntFlag.Space;
|
||||
s := strconv.append_bits(buf[start..<start], u128(u), base, is_signed, bit_size, digits, flags);
|
||||
|
||||
if fi.hash && fi.zero {
|
||||
@@ -664,7 +664,7 @@ fmt_string :: proc(fi: ^FmtInfo, s: string, verb: rune) {
|
||||
defer fi.space = space;
|
||||
|
||||
for i in 0..<len(s) {
|
||||
if i > 0 && space -> write_byte(fi.buf, ' ');
|
||||
if i > 0 && space do write_byte(fi.buf, ' ');
|
||||
_fmt_int(fi, u128(s[i]), 16, false, 8, verb == 'x' ? __DIGITS_LOWER : __DIGITS_UPPER);
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
write_string(fi.buf, info.name);
|
||||
write_byte(fi.buf, '{');
|
||||
for _, i in b.names {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
write_string(fi.buf, b.names[i]);
|
||||
write_string(fi.buf, " = ");
|
||||
|
||||
@@ -811,7 +811,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
write_byte(fi.buf, '[');
|
||||
defer write_byte(fi.buf, ']');
|
||||
for i in 0..<info.count {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
data := ^u8(v.data) + i*info.elem_size;
|
||||
fmt_arg(fi, any{rawptr(data), info.elem}, verb);
|
||||
@@ -822,7 +822,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
defer write_byte(fi.buf, ']');
|
||||
array := ^raw.DynamicArray(v.data);
|
||||
for i in 0..<array.len {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
data := ^u8(array.data) + i*info.elem_size;
|
||||
fmt_arg(fi, any{rawptr(data), info.elem}, verb);
|
||||
@@ -833,7 +833,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
defer write_byte(fi.buf, ']');
|
||||
slice := ^[]u8(v.data);
|
||||
for _, i in slice {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
data := &slice[0] + i*info.elem_size;
|
||||
fmt_arg(fi, any{rawptr(data), info.elem}, verb);
|
||||
@@ -844,7 +844,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
defer write_byte(fi.buf, '>');
|
||||
|
||||
for i in 0..<info.count {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
data := ^u8(v.data) + i*info.elem_size;
|
||||
fmt_value(fi, any{rawptr(data), info.elem}, verb);
|
||||
@@ -866,7 +866,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
entry_size := ed.elem_size;
|
||||
|
||||
for i in 0..<entries.len {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
data := ^u8(entries.data) + i*entry_size;
|
||||
header := ^__MapEntryHeader(data);
|
||||
@@ -891,7 +891,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
defer write_byte(fi.buf, '}');
|
||||
|
||||
for _, i in info.names {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
write_string(fi.buf, info.names[i]);
|
||||
write_string(fi.buf, " = ");
|
||||
@@ -905,7 +905,7 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
|
||||
cf := info.common_fields;
|
||||
for _, i in cf.names {
|
||||
if i > 0 -> write_string(fi.buf, ", ");
|
||||
if i > 0 do write_string(fi.buf, ", ");
|
||||
|
||||
write_string(fi.buf, cf.names[i]);
|
||||
write_string(fi.buf, " = ");
|
||||
@@ -1028,7 +1028,7 @@ sbprintln :: proc(buf: ^StringBuffer, args: ..any) -> string {
|
||||
fi.buf = buf;
|
||||
|
||||
for arg, i in args {
|
||||
if i > 0 -> write_byte(buf, ' ');
|
||||
if i > 0 do write_byte(buf, ' ');
|
||||
|
||||
fmt_value(&fi, args[i], 'v');
|
||||
}
|
||||
@@ -1155,10 +1155,10 @@ sbprintf :: proc(b: ^StringBuffer, fmt: string, args: ..any) -> string {
|
||||
if !fi.reordered && arg_index < len(args) {
|
||||
write_string(b, "%!(EXTRA ");
|
||||
for arg, index in args[arg_index..] {
|
||||
if index > 0 -> write_string(b, ", ");
|
||||
if index > 0 do write_string(b, ", ");
|
||||
|
||||
if arg == nil -> write_string(b, "<nil>");
|
||||
else -> fmt_arg(&fi, args[index], 'v');
|
||||
if arg == nil do write_string(b, "<nil>");
|
||||
else do fmt_arg(&fi, args[index], 'v');
|
||||
}
|
||||
write_string(b, ")");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user