authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-04 23:04:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-04 23:04:20-07:00
logd159ba9295b331663a62438673f3543c35fca136
tree87f19fb904d8706b6b8368b849be44f1ce0e26bd
parentf23fb3087befc041161498a086bac2a92acea6cb

zig fmt


6 files changed, 14 insertions(+), 15 deletions(-)

lib/std/json.zig+1-1
...@@ -1742,7 +1742,7 @@ test "parse into tagged union" {...@@ -1742,7 +1742,7 @@ test "parse into tagged union" {
1742 A: struct { x: u32 },1742 A: struct { x: u32 },
1743 B: struct { y: u32 },1743 B: struct { y: u32 },
1744 };1744 };
1745 testing.expectEqual(T{ .B = .{.y = 42} }, try parse(T, &TokenStream.init("{\"y\":42}"), ParseOptions{}));1745 testing.expectEqual(T{ .B = .{ .y = 42 } }, try parse(T, &TokenStream.init("{\"y\":42}"), ParseOptions{}));
1746 }1746 }
1747}1747}
17481748
lib/std/mem.zig+1-1
...@@ -2038,7 +2038,7 @@ pub fn replace(comptime T: type, input: []const T, needle: []const T, replacemen...@@ -2038,7 +2038,7 @@ pub fn replace(comptime T: type, input: []const T, needle: []const T, replacemen
2038 var replacements: usize = 0;2038 var replacements: usize = 0;
2039 while (slide < input.len) {2039 while (slide < input.len) {
2040 if (mem.indexOf(T, input[slide..], needle) == @as(usize, 0)) {2040 if (mem.indexOf(T, input[slide..], needle) == @as(usize, 0)) {
2041 mem.copy(T, output[i..i + replacement.len], replacement);2041 mem.copy(T, output[i .. i + replacement.len], replacement);
2042 i += replacement.len;2042 i += replacement.len;
2043 slide += needle.len;2043 slide += needle.len;
2044 replacements += 1;2044 replacements += 1;
lib/std/net.zig+9-10
...@@ -77,23 +77,23 @@ pub const Address = extern union {...@@ -77,23 +77,23 @@ pub const Address = extern union {
77 }77 }
7878
79 pub fn parseIp6(buf: []const u8, port: u16) !Address {79 pub fn parseIp6(buf: []const u8, port: u16) !Address {
80 return Address{.in6 = try Ip6Address.parse(buf, port) };80 return Address{ .in6 = try Ip6Address.parse(buf, port) };
81 }81 }
8282
83 pub fn resolveIp6(buf: []const u8, port: u16) !Address {83 pub fn resolveIp6(buf: []const u8, port: u16) !Address {
84 return Address{.in6 = try Ip6Address.resolve(buf, port) };84 return Address{ .in6 = try Ip6Address.resolve(buf, port) };
85 }85 }
8686
87 pub fn parseIp4(buf: []const u8, port: u16) !Address {87 pub fn parseIp4(buf: []const u8, port: u16) !Address {
88 return Address {.in = try Ip4Address.parse(buf, port) };88 return Address{ .in = try Ip4Address.parse(buf, port) };
89 }89 }
9090
91 pub fn initIp4(addr: [4]u8, port: u16) Address {91 pub fn initIp4(addr: [4]u8, port: u16) Address {
92 return Address{.in = Ip4Address.init(addr, port) };92 return Address{ .in = Ip4Address.init(addr, port) };
93 }93 }
9494
95 pub fn initIp6(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Address {95 pub fn initIp6(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Address {
96 return Address{.in6 = Ip6Address.init(addr, port, flowinfo, scope_id) };96 return Address{ .in6 = Ip6Address.init(addr, port, flowinfo, scope_id) };
97 }97 }
9898
99 pub fn initUnix(path: []const u8) !Address {99 pub fn initUnix(path: []const u8) !Address {
...@@ -136,8 +136,8 @@ pub const Address = extern union {...@@ -136,8 +136,8 @@ pub const Address = extern union {
136 /// on the address family.136 /// on the address family.
137 pub fn initPosix(addr: *align(4) const os.sockaddr) Address {137 pub fn initPosix(addr: *align(4) const os.sockaddr) Address {
138 switch (addr.family) {138 switch (addr.family) {
139 os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).*} },139 os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).* } },
140 os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).*} },140 os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).* } },
141 else => unreachable,141 else => unreachable,
142 }142 }
143 }143 }
...@@ -193,7 +193,7 @@ pub const Ip4Address = extern struct {...@@ -193,7 +193,7 @@ pub const Ip4Address = extern struct {
193 .sa = .{193 .sa = .{
194 .port = mem.nativeToBig(u16, port),194 .port = mem.nativeToBig(u16, port),
195 .addr = undefined,195 .addr = undefined,
196 }196 },
197 };197 };
198 const out_ptr = mem.sliceAsBytes(@as(*[1]u32, &result.sa.addr)[0..]);198 const out_ptr = mem.sliceAsBytes(@as(*[1]u32, &result.sa.addr)[0..]);
199199
...@@ -240,7 +240,7 @@ pub const Ip4Address = extern struct {...@@ -240,7 +240,7 @@ pub const Ip4Address = extern struct {
240 }240 }
241241
242 pub fn init(addr: [4]u8, port: u16) Ip4Address {242 pub fn init(addr: [4]u8, port: u16) Ip4Address {
243 return Ip4Address {243 return Ip4Address{
244 .sa = os.sockaddr_in{244 .sa = os.sockaddr_in{
245 .port = mem.nativeToBig(u16, port),245 .port = mem.nativeToBig(u16, port),
246 .addr = @ptrCast(*align(1) const u32, &addr).*,246 .addr = @ptrCast(*align(1) const u32, &addr).*,
...@@ -598,7 +598,6 @@ pub const Ip6Address = extern struct {...@@ -598,7 +598,6 @@ pub const Ip6Address = extern struct {
598 }598 }
599};599};
600600
601
602pub fn connectUnixSocket(path: []const u8) !fs.File {601pub fn connectUnixSocket(path: []const u8) !fs.File {
603 const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0;602 const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
604 const sockfd = try os.socket(603 const sockfd = try os.socket(
lib/std/os/bits/windows.zig+1-1
...@@ -261,4 +261,4 @@ pub const O_LARGEFILE = 0;...@@ -261,4 +261,4 @@ pub const O_LARGEFILE = 0;
261pub const O_NOATIME = 0o1000000;261pub const O_NOATIME = 0o1000000;
262pub const O_PATH = 0o10000000;262pub const O_PATH = 0o10000000;
263pub const O_TMPFILE = 0o20200000;263pub const O_TMPFILE = 0o20200000;
264pub const O_NDELAY = O_NONBLOCK;
\ No newline at end of file
264pub const O_NDELAY = O_NONBLOCK;
lib/std/os/windows.zig+1-1
...@@ -51,7 +51,7 @@ pub const OpenFileOptions = struct {...@@ -51,7 +51,7 @@ pub const OpenFileOptions = struct {
51 open_dir: bool = false,51 open_dir: bool = false,
52 /// If false, tries to open path as a reparse point without dereferencing it.52 /// If false, tries to open path as a reparse point without dereferencing it.
53 /// Defaults to true.53 /// Defaults to true.
54 follow_symlinks: bool = true, 54 follow_symlinks: bool = true,
55};55};
5656
57/// TODO when share_access_nonblocking is false, this implementation uses57/// TODO when share_access_nonblocking is false, this implementation uses
lib/std/special/compiler_rt/floatditf.zig+1-1
...@@ -18,7 +18,7 @@ pub fn __floatditf(arg: i64) callconv(.C) f128 {...@@ -18,7 +18,7 @@ pub fn __floatditf(arg: i64) callconv(.C) f128 {
18 var aAbs = @bitCast(u64, arg);18 var aAbs = @bitCast(u64, arg);
19 if (arg < 0) {19 if (arg < 0) {
20 sign = 1 << 127;20 sign = 1 << 127;
21 aAbs = ~@bitCast(u64, arg)+ 1;21 aAbs = ~@bitCast(u64, arg) + 1;
22 }22 }
2323
24 // Exponent of (fp_t)a is the width of abs(a).24 // Exponent of (fp_t)a is the width of abs(a).