| author | |
| committer | |
| log | bf00eb3006a358bbb1da694fb6d725eb6a8eeaaa |
| tree | 083cc624f6cd2ad07ab4912ec7df12d2518813d3 |
| parent | 09af68de80da4319d552a9eefc3f3e86a4c64caf |
6 files changed, 28 insertions(+), 68 deletions(-)
lib/std/crypto/tls/Client.zig+3-2| ... | ... | @@ -125,9 +125,10 @@ pub const Options = struct { |
| 125 | 125 | /// Verify that the server certificate is authorized by a given ca bundle. |
| 126 | 126 | bundle: Certificate.Bundle, |
| 127 | 127 | }, |
| 128 | /// If non-null, ssl secrets are logged to this stream. Creating such a log file allows | |
| 128 | /// If non-null, ssl secrets are logged to this file. Creating such a log file allows | |
| 129 | 129 | /// other programs with access to that file to decrypt all traffic over this connection. |
| 130 | ssl_key_log_file: ?*std.io.BufferedWriter = null, | |
| 130 | /// TODO `std.crypto` should have no dependencies on `std.fs`. | |
| 131 | ssl_key_log_file: ?std.fs.File = null, | |
| 131 | 132 | }; |
| 132 | 133 | |
| 133 | 134 | pub fn InitError(comptime Stream: type) type { |
lib/std/io.zig+4-46| ... | ... | @@ -123,59 +123,17 @@ pub fn GenericReader( |
| 123 | 123 | return @errorCast(self.any().readAllAlloc(allocator, max_size)); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | pub inline fn readUntilDelimiterAlloc( | |
| 127 | self: Self, | |
| 128 | allocator: Allocator, | |
| 129 | delimiter: u8, | |
| 130 | max_size: usize, | |
| 131 | ) (NoEofError || Allocator.Error || error{StreamTooLong})![]u8 { | |
| 132 | return @errorCast(self.any().readUntilDelimiterAlloc( | |
| 133 | allocator, | |
| 134 | delimiter, | |
| 135 | max_size, | |
| 136 | )); | |
| 137 | } | |
| 138 | ||
| 139 | pub inline fn readUntilDelimiter( | |
| 140 | self: Self, | |
| 141 | buf: []u8, | |
| 142 | delimiter: u8, | |
| 143 | ) (NoEofError || error{StreamTooLong})![]u8 { | |
| 144 | return @errorCast(self.any().readUntilDelimiter(buf, delimiter)); | |
| 145 | } | |
| 146 | ||
| 147 | pub inline fn readUntilDelimiterOrEofAlloc( | |
| 148 | self: Self, | |
| 149 | allocator: Allocator, | |
| 150 | delimiter: u8, | |
| 151 | max_size: usize, | |
| 152 | ) (Error || Allocator.Error || error{StreamTooLong})!?[]u8 { | |
| 153 | return @errorCast(self.any().readUntilDelimiterOrEofAlloc( | |
| 154 | allocator, | |
| 155 | delimiter, | |
| 156 | max_size, | |
| 157 | )); | |
| 158 | } | |
| 159 | ||
| 160 | pub inline fn readUntilDelimiterOrEof( | |
| 161 | self: Self, | |
| 162 | buf: []u8, | |
| 163 | delimiter: u8, | |
| 164 | ) (Error || error{StreamTooLong})!?[]u8 { | |
| 165 | return @errorCast(self.any().readUntilDelimiterOrEof(buf, delimiter)); | |
| 166 | } | |
| 167 | ||
| 168 | 126 | pub inline fn streamUntilDelimiter( |
| 169 | 127 | self: Self, |
| 170 | writer: anytype, | |
| 128 | writer: *std.io.BufferedWriter, | |
| 171 | 129 | delimiter: u8, |
| 172 | 130 | optional_max_size: ?usize, |
| 173 | ) (NoEofError || error{StreamTooLong} || @TypeOf(writer).Error)!void { | |
| 174 | return @errorCast(self.any().streamUntilDelimiter( | |
| 131 | ) anyerror!void { | |
| 132 | return self.any().streamUntilDelimiter( | |
| 175 | 133 | writer, |
| 176 | 134 | delimiter, |
| 177 | 135 | optional_max_size, |
| 178 | )); | |
| 136 | ); | |
| 179 | 137 | } |
| 180 | 138 | |
| 181 | 139 | pub inline fn skipUntilDelimiterOrEof(self: Self, delimiter: u8) Error!void { |
lib/std/io/BufferedWriter.zig+2-5| ... | ... | @@ -663,7 +663,7 @@ pub fn printValue( |
| 663 | 663 | } |
| 664 | 664 | }, |
| 665 | 665 | .error_set => { |
| 666 | if (actual_fmt.len > 0 and actual_fmt.len[0] == 's') { | |
| 666 | if (actual_fmt.len > 0 and actual_fmt[0] == 's') { | |
| 667 | 667 | return bw.writeAll(@errorName(value)); |
| 668 | 668 | } else if (actual_fmt.len != 0) { |
| 669 | 669 | invalidFmtError(fmt, value); |
| ... | ... | @@ -1147,13 +1147,11 @@ pub fn printByteSize( |
| 1147 | 1147 | const magnitude = switch (units) { |
| 1148 | 1148 | .decimal => @min(log2 / comptime std.math.log2(1000), mags_si.len - 1), |
| 1149 | 1149 | .binary => @min(log2 / 10, mags_iec.len - 1), |
| 1150 | else => unreachable, | |
| 1151 | 1150 | }; |
| 1152 | 1151 | const new_value = std.math.lossyCast(f64, value) / std.math.pow(f64, std.math.lossyCast(f64, base), std.math.lossyCast(f64, magnitude)); |
| 1153 | 1152 | const suffix = switch (units) { |
| 1154 | 1153 | .decimal => mags_si[magnitude], |
| 1155 | 1154 | .binary => mags_iec[magnitude], |
| 1156 | else => unreachable, | |
| 1157 | 1155 | }; |
| 1158 | 1156 | |
| 1159 | 1157 | const s = switch (magnitude) { |
| ... | ... | @@ -1176,10 +1174,9 @@ pub fn printByteSize( |
| 1176 | 1174 | buf[i..][0..3].* = [_]u8{ suffix, 'i', 'B' }; |
| 1177 | 1175 | i += 3; |
| 1178 | 1176 | }, |
| 1179 | else => unreachable, | |
| 1180 | 1177 | } |
| 1181 | 1178 | |
| 1182 | return alignBufferOptions(buf[0..i], options, bw); | |
| 1179 | return alignBufferOptions(bw, buf[0..i], options); | |
| 1183 | 1180 | } |
| 1184 | 1181 | |
| 1185 | 1182 | // This ANY const is a workaround for: https://github.com/ziglang/zig/issues/7948 |
src/Compilation.zig+1-2| ... | ... | @@ -1880,9 +1880,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1880 | 1880 | |
| 1881 | 1881 | if (options.verbose_llvm_cpu_features) { |
| 1882 | 1882 | if (options.root_mod.resolved_target.llvm_cpu_features) |cf| print: { |
| 1883 | std.debug.lockStdErr(); | |
| 1883 | var stderr = std.debug.lockStdErr2(); | |
| 1884 | 1884 | defer std.debug.unlockStdErr(); |
| 1885 | const stderr = std.io.getStdErr().writer(); | |
| 1886 | 1885 | nosuspend { |
| 1887 | 1886 | stderr.print("compilation: {s}\n", .{options.root_name}) catch break :print; |
| 1888 | 1887 | stderr.print(" target: {s}\n", .{try target.zigTriple(arena)}) catch break :print; |
src/Package/Fetch.zig+17-12| ... | ... | @@ -184,7 +184,7 @@ pub const JobQueue = struct { |
| 184 | 184 | |
| 185 | 185 | const hash_slice = hash.toSlice(); |
| 186 | 186 | |
| 187 | try buf.writer().print( | |
| 187 | try buf.print( | |
| 188 | 188 | \\ pub const {} = struct {{ |
| 189 | 189 | \\ |
| 190 | 190 | , .{std.zig.fmtId(hash_slice)}); |
| ... | ... | @@ -210,13 +210,13 @@ pub const JobQueue = struct { |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | try buf.writer().print( | |
| 213 | try buf.print( | |
| 214 | 214 | \\ pub const build_root = "{q}"; |
| 215 | 215 | \\ |
| 216 | 216 | , .{fetch.package_root}); |
| 217 | 217 | |
| 218 | 218 | if (fetch.has_build_zig) { |
| 219 | try buf.writer().print( | |
| 219 | try buf.print( | |
| 220 | 220 | \\ pub const build_zig = @import("{}"); |
| 221 | 221 | \\ |
| 222 | 222 | , .{std.zig.fmtEscapes(hash_slice)}); |
| ... | ... | @@ -229,7 +229,7 @@ pub const JobQueue = struct { |
| 229 | 229 | ); |
| 230 | 230 | for (manifest.dependencies.keys(), manifest.dependencies.values()) |name, dep| { |
| 231 | 231 | const h = depDigest(fetch.package_root, jq.global_cache, dep) orelse continue; |
| 232 | try buf.writer().print( | |
| 232 | try buf.print( | |
| 233 | 233 | " .{{ \"{}\", \"{}\" }},\n", |
| 234 | 234 | .{ std.zig.fmtEscapes(name), std.zig.fmtEscapes(h.toSlice()) }, |
| 235 | 235 | ); |
| ... | ... | @@ -261,7 +261,7 @@ pub const JobQueue = struct { |
| 261 | 261 | |
| 262 | 262 | for (root_manifest.dependencies.keys(), root_manifest.dependencies.values()) |name, dep| { |
| 263 | 263 | const h = depDigest(root_fetch.package_root, jq.global_cache, dep) orelse continue; |
| 264 | try buf.writer().print( | |
| 264 | try buf.print( | |
| 265 | 265 | " .{{ \"{}\", \"{}\" }},\n", |
| 266 | 266 | .{ std.zig.fmtEscapes(name), std.zig.fmtEscapes(h.toSlice()) }, |
| 267 | 267 | ); |
| ... | ... | @@ -1366,8 +1366,12 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource.Git) anyerror!U |
| 1366 | 1366 | { |
| 1367 | 1367 | const index_prog_node = f.prog_node.start("Index pack", 0); |
| 1368 | 1368 | defer index_prog_node.end(); |
| 1369 | var index_buffered_writer = std.io.bufferedWriter(index_file.writer()); | |
| 1370 | try git.indexPack(gpa, object_format, pack_file, index_buffered_writer.writer()); | |
| 1369 | var buffer: [4096]u8 = undefined; | |
| 1370 | var index_buffered_writer: std.io.BufferedWriter = .{ | |
| 1371 | .unbuffered_writer = index_file.writer(), | |
| 1372 | .buffer = &buffer, | |
| 1373 | }; | |
| 1374 | try git.indexPack(gpa, object_format, pack_file, &index_buffered_writer); | |
| 1371 | 1375 | try index_buffered_writer.flush(); |
| 1372 | 1376 | try index_file.sync(); |
| 1373 | 1377 | } |
| ... | ... | @@ -1638,12 +1642,13 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1638 | 1642 | } |
| 1639 | 1643 | |
| 1640 | 1644 | fn dumpHashInfo(all_files: []const *const HashedFile) !void { |
| 1641 | const stdout = std.io.getStdOut(); | |
| 1642 | var bw = std.io.bufferedWriter(stdout.writer()); | |
| 1643 | const w = bw.writer(); | |
| 1644 | ||
| 1645 | var buffer: [4096]u8 = undefined; | |
| 1646 | var bw: std.io.BufferedWriter = .{ | |
| 1647 | .unbuffered_writer = std.io.getStdOut().writer(), | |
| 1648 | .buffer = &buffer, | |
| 1649 | }; | |
| 1645 | 1650 | for (all_files) |hashed_file| { |
| 1646 | try w.print("{s}: {x}: {s}\n", .{ | |
| 1651 | try bw.print("{s}: {x}: {s}\n", .{ | |
| 1647 | 1652 | @tagName(hashed_file.kind), &hashed_file.hash, hashed_file.normalized_path, |
| 1648 | 1653 | }); |
| 1649 | 1654 | } |
src/print_env.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ pub fn cmdEnv(arena: Allocator, args: []const []const u8) !void { |
| 26 | 26 | .buffer = &buffer, |
| 27 | 27 | .unbuffered_writer = std.io.getStdOut().writer(), |
| 28 | 28 | }; |
| 29 | var jws = std.json.writeStream(bw, .{ .whitespace = .indent_1 }); | |
| 29 | var jws: std.json.Stringify = .{ .writer = &bw, .options = .{ .whitespace = .indent_1 } }; | |
| 30 | 30 | |
| 31 | 31 | try jws.beginObject(); |
| 32 | 32 |