diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index c8afb7f388..5a68cc5fae 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -1209,7 +1209,7 @@ fn (mut re RE) impl_compile(in_txt string) (int,int) { } // init the state stack - re.state_stack = [StateDotObj{}].repeat(tmp_count+1) + re.state_stack = []StateDotObj{len: tmp_count+1, init: StateDotObj{}} // OR branch // a|b|cd diff --git a/vlib/v/tests/string_interpolation_test.v b/vlib/v/tests/string_interpolation_test.v index e15e73f9fc..bed3a1954d 100644 --- a/vlib/v/tests/string_interpolation_test.v +++ b/vlib/v/tests/string_interpolation_test.v @@ -94,7 +94,13 @@ fn test_inttypes_string_interpolation() { i := -1622999040 ui := u32(3421958087) vp := voidptr(ui) - bp := byteptr(15541149836) + mut bp := byteptr(0) + $if x64 { + bp = byteptr(15541149836) + } + $else { + bp = byteptr(3541149836) + } l := i64(-7694555558525237396) ul := u64(17234006112912956370) assert '$s $us' == '-23456 54321' @@ -109,10 +115,17 @@ fn test_inttypes_string_interpolation() { assert '${l:x}:${ul:X}' == '9537727cad98876c:EF2B7D4001165BD2' // default pointer format is platform dependent, so try a few eprintln("platform pointer format: '${vp:p}:$bp'") - assert '${vp:p}:$bp' == '0xcbf6efc7:0x39e53208c' || - '${vp:p}:$bp' == 'CBF6EFC7:39E53208C' || - '${vp:p}:$bp' == 'cbf6efc7:39e53208c' || - '${vp:p}:$bp' == '00000000CBF6EFC7:000000039E53208C' + $if x64 { + assert '${vp:p}:$bp' == '0xcbf6efc7:0x39e53208c' || + '${vp:p}:$bp' == 'CBF6EFC7:39E53208C' || + '${vp:p}:$bp' == 'cbf6efc7:39e53208c' || + '${vp:p}:$bp' == '00000000CBF6EFC7:000000039E53208C' + } + $else { + assert '${vp:p}:$bp' == 'CBF6EFC7:D311A88C' || + '${vp:p}:$bp' == 'cbf6efc7:d311a88c' || + '${vp:p}:$bp' == '0xcbf6efc7:0xd311a88c' + } } fn test_utf8_string_interpolation() { diff --git a/vlib/x/net/aasocket.c.v b/vlib/x/net/aasocket.c.v index b1d9702bbd..66fe86122b 100644 --- a/vlib/x/net/aasocket.c.v +++ b/vlib/x/net/aasocket.c.v @@ -77,6 +77,8 @@ fn C.ntohs() int fn C.inet_ntop() int +fn C.WSAStringToAddress() int + fn C.getsockname() int // defined in builtin diff --git a/vlib/x/net/address.v b/vlib/x/net/address.v index 3ca3248559..752b51b93b 100644 --- a/vlib/x/net/address.v +++ b/vlib/x/net/address.v @@ -23,7 +23,7 @@ fn new_addr(addr C.sockaddr, _saddr string, _port int) ?Addr { // Convert to string representation buf := []byte{ len: max_ipv4_addr_len, init: 0 } $if windows { - res := C.inet_ntop(SocketFamily.inet, &addr, buf.data, buf.len) + res := C.WSAStringToAddress(&addr, SocketFamily.inet, C.NULL, &buf.data, &buf.len) if res == 0 { socket_error(-1)? }