Named return value act as variables; Code reorganization

This commit is contained in:
gingerBill
2018-01-17 19:07:38 +00:00
parent 5558b55e9f
commit 419ab6f00c
15 changed files with 1130 additions and 1135 deletions
+12 -10
View File
@@ -309,26 +309,26 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
}
_parse_int :: proc(s: string, offset: int) -> (result: int, offset: int, ok: bool) {
_parse_int :: proc(s: string, offset: int) -> (result: int, new_offset: int, ok: bool) {
is_digit :: inline proc(r: rune) -> bool{
return '0' <= r && r <= '9';
}
result := 0;
i := 0;
for i < len(s[offset..]) {
c := rune(s[offset+i]);
new_offset = offset;
n := len(s[new_offset..]);
for new_offset < n {
c := rune(s[new_offset]);
if !is_digit(c) do break;
i += 1;
new_offset += 1;
result *= 10;
result += int(c)-'0';
}
return result, offset+i, i != 0;
ok = new_offset > offset;
return;
}
_arg_number :: proc(fi: ^Fmt_Info, arg_index: int, format: string, offset, arg_count: int) -> (index, offset: int, ok: bool) {
_arg_number :: proc(fi: ^Fmt_Info, arg_index: int, format: string, offset, arg_count: int) -> (index, new_offset: int, ok: bool) {
parse_arg_number :: proc(format: string) -> (int, int, bool) {
if len(format) < 3 do return 0, 1, false;
@@ -350,7 +350,9 @@ _arg_number :: proc(fi: ^Fmt_Info, arg_index: int, format: string, offset, arg_c
return arg_index, offset, false;
}
fi.reordered = true;
index, width, ok := parse_arg_number(format[offset..]);
width: int;
index, width, ok = parse_arg_number(format[offset..]);
if ok && 0 <= index && index < arg_count {
return index, offset+width, true;
}
+1 -1
View File
@@ -25,7 +25,7 @@ read_entire_file :: proc(name: string) -> (data: []byte, success: bool) {
return nil, true;
}
data := make([]byte, int(length));
data = make([]byte, int(length));
if data == nil {
return nil, false;
}
+1 -2
View File
@@ -14,7 +14,7 @@ parse_bool :: proc(s: string) -> (result: bool = false, ok: bool) {
case "0", "f", "F", "false", "FALSE", "False":
return false, true;
}
return ok = false;
return;
}
_digit_value :: proc(r: rune) -> int {
@@ -428,7 +428,6 @@ digits := "0123456789abcdefghijklmnopqrstuvwxyz";
is_integer_negative :: proc(u: u64, is_signed: bool, bit_size: int) -> (unsigned: u64, neg: bool) {
neg := false;
if is_signed {
switch bit_size {
case 8: