Skip to content

Commit

Permalink
encoding.leb128: fix `v -cstrict -cc gcc-11 examples/wasm_codegen/bf_…
Browse files Browse the repository at this point in the history
…compiler.v`
  • Loading branch information
spytheman committed Oct 3, 2023
1 parent 7a49f24 commit 6b79b2a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vlib/encoding/leb128/leb128.v
Expand Up @@ -68,19 +68,19 @@ pub fn encode_u32(value u32) []u8 {

// decode_i32 decodes an i32 and returns the number of bytes used from the given leb128 encoded array `value`
pub fn decode_i32(value []u8) (i32, int) {
mut result := int(0)
mut result := u32(0)
mut shift := 0
for b in value {
result |= b & 0x7f << shift
result |= u32(b & 0x7f) << shift
shift += 7
if b & 0x80 == 0 {
if shift < 32 && b & 0x40 != 0 {
result |= ~0 << shift
result |= u32(~0) << shift
}
break
}
}
return result, shift / 7
return int(result), shift / 7
}

// decode_i64 decodes an i64 and returns the number of bytes used from the given leb128 encoded array `value`
Expand Down

0 comments on commit 6b79b2a

Please sign in to comment.