This commit is contained in:
Andrew Kelley 2020-08-04 23:04:20 -07:00
parent f23fb3087b
commit d159ba9295
6 changed files with 14 additions and 15 deletions

View File

@ -1742,7 +1742,7 @@ test "parse into tagged union" {
A: struct { x: u32 },
B: struct { y: u32 },
};
testing.expectEqual(T{ .B = .{.y = 42} }, try parse(T, &TokenStream.init("{\"y\":42}"), ParseOptions{}));
testing.expectEqual(T{ .B = .{ .y = 42 } }, try parse(T, &TokenStream.init("{\"y\":42}"), ParseOptions{}));
}
}

View File

@ -2038,7 +2038,7 @@ pub fn replace(comptime T: type, input: []const T, needle: []const T, replacemen
var replacements: usize = 0;
while (slide < input.len) {
if (mem.indexOf(T, input[slide..], needle) == @as(usize, 0)) {
mem.copy(T, output[i..i + replacement.len], replacement);
mem.copy(T, output[i .. i + replacement.len], replacement);
i += replacement.len;
slide += needle.len;
replacements += 1;

View File

@ -77,23 +77,23 @@ pub const Address = extern union {
}
pub fn parseIp6(buf: []const u8, port: u16) !Address {
return Address{.in6 = try Ip6Address.parse(buf, port) };
return Address{ .in6 = try Ip6Address.parse(buf, port) };
}
pub fn resolveIp6(buf: []const u8, port: u16) !Address {
return Address{.in6 = try Ip6Address.resolve(buf, port) };
return Address{ .in6 = try Ip6Address.resolve(buf, port) };
}
pub fn parseIp4(buf: []const u8, port: u16) !Address {
return Address {.in = try Ip4Address.parse(buf, port) };
return Address{ .in = try Ip4Address.parse(buf, port) };
}
pub fn initIp4(addr: [4]u8, port: u16) Address {
return Address{.in = Ip4Address.init(addr, port) };
return Address{ .in = Ip4Address.init(addr, port) };
}
pub fn initIp6(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Address {
return Address{.in6 = Ip6Address.init(addr, port, flowinfo, scope_id) };
return Address{ .in6 = Ip6Address.init(addr, port, flowinfo, scope_id) };
}
pub fn initUnix(path: []const u8) !Address {
@ -136,8 +136,8 @@ pub const Address = extern union {
/// on the address family.
pub fn initPosix(addr: *align(4) const os.sockaddr) Address {
switch (addr.family) {
os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).*} },
os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).*} },
os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).* } },
os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).* } },
else => unreachable,
}
}
@ -193,7 +193,7 @@ pub const Ip4Address = extern struct {
.sa = .{
.port = mem.nativeToBig(u16, port),
.addr = undefined,
}
},
};
const out_ptr = mem.sliceAsBytes(@as(*[1]u32, &result.sa.addr)[0..]);
@ -240,7 +240,7 @@ pub const Ip4Address = extern struct {
}
pub fn init(addr: [4]u8, port: u16) Ip4Address {
return Ip4Address {
return Ip4Address{
.sa = os.sockaddr_in{
.port = mem.nativeToBig(u16, port),
.addr = @ptrCast(*align(1) const u32, &addr).*,
@ -598,7 +598,6 @@ pub const Ip6Address = extern struct {
}
};
pub fn connectUnixSocket(path: []const u8) !fs.File {
const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
const sockfd = try os.socket(

View File

@ -261,4 +261,4 @@ pub const O_LARGEFILE = 0;
pub const O_NOATIME = 0o1000000;
pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20200000;
pub const O_NDELAY = O_NONBLOCK;
pub const O_NDELAY = O_NONBLOCK;

View File

@ -51,7 +51,7 @@ pub const OpenFileOptions = struct {
open_dir: bool = false,
/// If false, tries to open path as a reparse point without dereferencing it.
/// Defaults to true.
follow_symlinks: bool = true,
follow_symlinks: bool = true,
};
/// TODO when share_access_nonblocking is false, this implementation uses

View File

@ -18,7 +18,7 @@ pub fn __floatditf(arg: i64) callconv(.C) f128 {
var aAbs = @bitCast(u64, arg);
if (arg < 0) {
sign = 1 << 127;
aAbs = ~@bitCast(u64, arg)+ 1;
aAbs = ~@bitCast(u64, arg) + 1;
}
// Exponent of (fp_t)a is the width of abs(a).