correct newly found vets

This commit is contained in:
Laytan Laats
2024-04-03 00:52:58 +02:00
parent 21fcf7c874
commit 3a0df80066
18 changed files with 56 additions and 62 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ read :: proc(data: []byte, filename := "<input>", print_error := false, allocato
}
defer file.nodes = file.nodes[:node_count]
for node_idx in 0..<header.internal_node_count {
for _ in 0..<header.internal_node_count {
node := &file.nodes[node_count]
type := read_value(r, Node_Type) or_return
if type > max(Node_Type) {
+10 -11
View File
@@ -246,7 +246,6 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
opt_write_end(w, opt, ']') or_return
case runtime.Type_Info_Enumerated_Array:
index := runtime.type_info_base(info.index).variant.(runtime.Type_Info_Enum)
opt_write_start(w, opt, '[') or_return
for i in 0..<info.count {
opt_write_iteration(w, opt, i) or_return
@@ -299,14 +298,14 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
// check for string type
{
v := any{key, info.key.id}
ti := runtime.type_info_base(type_info_of(v.id))
a := any{v.data, ti.id}
kv := any{key, info.key.id}
kti := runtime.type_info_base(type_info_of(kv.id))
ka := any{kv.data, kti.id}
name: string
#partial switch info in ti.variant {
#partial switch info in kti.variant {
case runtime.Type_Info_String:
switch s in a {
switch s in ka {
case string: name = s
case cstring: name = string(s)
}
@@ -336,13 +335,13 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
// check for string type
{
v := any{key, info.key.id}
ti := runtime.type_info_base(type_info_of(v.id))
a := any{v.data, ti.id}
kv := any{key, info.key.id}
kti := runtime.type_info_base(type_info_of(kv.id))
ka := any{kv.data, kti.id}
#partial switch info in ti.variant {
#partial switch info in kti.variant {
case runtime.Type_Info_String:
switch s in a {
switch s in ka {
case string: name = s
case cstring: name = string(s)
}
+2 -2
View File
@@ -483,9 +483,9 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
mem.zero_slice(elem_backing)
if err := unmarshal_value(p, map_backing_value); err != nil {
if uerr := unmarshal_value(p, map_backing_value); uerr != nil {
delete(key, p.allocator)
return err
return uerr
}
key_ptr := rawptr(&key)
+6 -6
View File
@@ -199,8 +199,8 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context
for x in 0 ..< img.width {
i := y * img.width + x
for c in 0 ..< img.channels {
i := i * img.channels + c
fmt.sbprintf(&data, "%i ", pixels[i])
j := i * img.channels + c
fmt.sbprintf(&data, "%i ", pixels[j])
}
fmt.sbprint(&data, "\n")
}
@@ -213,8 +213,8 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context
for x in 0 ..< img.width {
i := y * img.width + x
for c in 0 ..< img.channels {
i := i * img.channels + c
fmt.sbprintf(&data, "%i ", pixels[i])
j := i * img.channels + c
fmt.sbprintf(&data, "%i ", pixels[j])
}
fmt.sbprint(&data, "\n")
}
@@ -283,7 +283,7 @@ _parse_header_pnm :: proc(data: []byte) -> (header: Header, length: int, err: Er
current_field := 0
current_value := header_fields[0]
parse_loop: for d, i in data[SIG_LENGTH:] {
parse_loop: for d in data[SIG_LENGTH:] {
length += 1
// handle comments
@@ -728,4 +728,4 @@ _register :: proc() {
_ = destroy(img)
}
image.register(.NetPBM, loader, destroyer)
}
}
+2 -2
View File
@@ -119,9 +119,9 @@ aton :: proc(address_and_maybe_port: string, family: Address_Family, allow_decim
}
a: [4]u8 = ---
for v, i in buf {
for v, j in buf {
if v > 255 { return {}, false }
a[i] = u8(v)
a[j] = u8(v)
}
return IP4_Address(a), true
-1
View File
@@ -816,7 +816,6 @@ parse_response :: proc(response: []u8, filter: DNS_Record_Type = nil, allocator
dq_sz :: 4
hn_sz := skip_hostname(response, cur_idx) or_return
dns_query := mem.slice_data_cast([]u16be, response[cur_idx+hn_sz:cur_idx+hn_sz+dq_sz])
cur_idx += hn_sz + dq_sz
}
+2 -5
View File
@@ -85,11 +85,9 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator :
append(&recs, record)
case .CNAME:
hostname := strings.clone(string(r.Data.CNAME))
record := DNS_Record_CNAME{
base = base_record,
host_name = hostname,
host_name = strings.clone(string(r.Data.CNAME)),
}
append(&recs, record)
@@ -107,10 +105,9 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator :
}
case .NS:
hostname := strings.clone(string(r.Data.NS))
record := DNS_Record_NS{
base = base_record,
host_name = hostname,
host_name = strings.clone(string(r.Data.NS)),
}
append(&recs, record)
+3 -4
View File
@@ -161,11 +161,10 @@ recv_any :: proc(socket: Any_Socket, buf: []byte) -> (
) {
switch socktype in socket {
case TCP_Socket:
bytes_read, err := recv_tcp(socktype, buf)
return bytes_read, nil, err
bytes_read, err = recv_tcp(socktype, buf)
return
case UDP_Socket:
bytes_read, endpoint, err := recv_udp(socktype, buf)
return bytes_read, endpoint, err
return recv_udp(socktype, buf)
case: panic("Not supported")
}
}
+3 -3
View File
@@ -643,7 +643,7 @@ align_switch_stmt :: proc(p: ^Printer, index: int) {
format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator)
//find all the switch cases that are one lined
for line, line_index in p.lines[brace_line + 1:] {
for line in p.lines[brace_line + 1:] {
case_found := false
colon_found := false
@@ -716,7 +716,7 @@ align_enum :: proc(p: ^Printer, index: int) {
format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator)
for line, line_index in p.lines[brace_line + 1:] {
for line in p.lines[brace_line + 1:] {
length := 0
for format_token, i in line.format_tokens {
@@ -880,7 +880,7 @@ align_comments :: proc(p: ^Printer) {
length := 0
for format_token, i in line.format_tokens {
for format_token in line.format_tokens {
if format_token.kind == .Comment {
current_info.length = max(current_info.length, length)
current_info.end = line_index
+2 -2
View File
@@ -1462,9 +1462,9 @@ visit_binary_expr :: proc(p: ^Printer, binary: ^ast.Binary_Expr) {
}
either_implicit_selector := false
if _, ok := binary.left.derived.(^ast.Implicit_Selector_Expr); ok {
if _, lok := binary.left.derived.(^ast.Implicit_Selector_Expr); lok {
either_implicit_selector = true
} else if _, ok := binary.right.derived.(^ast.Implicit_Selector_Expr); ok {
} else if _, rok := binary.right.derived.(^ast.Implicit_Selector_Expr); rok {
either_implicit_selector = true
}
+1 -1
View File
@@ -878,7 +878,7 @@ parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) {
s = s[1:]
fallthrough
case 'i', 'I':
n := common_prefix_len_ignore_case(s, "infinity")
n = common_prefix_len_ignore_case(s, "infinity")
if 3 < n && n < 8 { // "inf" or "infinity"
n = 3
}
+1 -1
View File
@@ -809,7 +809,7 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato
n = l
}
res := make([]string, n, allocator, loc) or_return
res = make([]string, n, allocator, loc) or_return
for i := 0; i < n-1; i += 1 {
_, w := utf8.decode_rune_in_string(s)
res[i] = s[:w]
+2 -2
View File
@@ -18,8 +18,8 @@ init_os_version :: proc () {
fd, errno := linux.open("/etc/os-release", {.RDONLY}, {})
assert(errno == .NONE, "Failed to read /etc/os-release")
defer {
errno := linux.close(fd)
assert(errno == .NONE, "Failed to close the file descriptor")
cerrno := linux.close(fd)
assert(cerrno == .NONE, "Failed to close the file descriptor")
}
os_release_buf: [2048]u8
n, read_errno := linux.read(fd, os_release_buf[:])
+1 -1
View File
@@ -128,7 +128,7 @@ parse_qt_linguist_from_bytes :: proc(data: []byte, options := DEFAULT_PARSE_OPTI
num_plurals: int
for {
numerus_id := xml.find_child_by_ident(ts, translation_id, "numerusform", num_plurals) or_break
xml.find_child_by_ident(ts, translation_id, "numerusform", num_plurals) or_break
num_plurals += 1
}