| author | |
| committer | |
| log | c11d1055b868add74cc58f3bf745e93110ae6071 |
| tree | 4af26a48d8fa267a0d99cd06792e423708dadd21 |
| parent | 7364e965f473147a86cc62ccf47feac4878a15de |
6 files changed, 27 insertions(+), 37 deletions(-)
lib/std/http/headers.zig+8-10| ... | ... | @@ -349,16 +349,14 @@ pub const Headers = struct { |
| 349 | 349 | pub fn format( |
| 350 | 350 | self: Self, |
| 351 | 351 | comptime fmt: []const u8, |
| 352 | options: std.fmt.FormatOptions, | |
| 353 | context: var, | |
| 354 | comptime Errors: type, | |
| 355 | output: fn (@TypeOf(context), []const u8) Errors!void, | |
| 356 | ) Errors!void { | |
| 352 | options: std.fmtstream.FormatOptions, | |
| 353 | out_stream: var, | |
| 354 | ) !void { | |
| 357 | 355 | for (self.toSlice()) |entry| { |
| 358 | try output(context, entry.name); | |
| 359 | try output(context, ": "); | |
| 360 | try output(context, entry.value); | |
| 361 | try output(context, "\n"); | |
| 356 | try out_stream.writeAll(entry.name); | |
| 357 | try out_stream.writeAll(": "); | |
| 358 | try out_stream.writeAll(entry.value); | |
| 359 | try out_stream.writeAll("\n"); | |
| 362 | 360 | } |
| 363 | 361 | } |
| 364 | 362 | }; |
| ... | ... | @@ -593,5 +591,5 @@ test "Headers.format" { |
| 593 | 591 | \\foo: bar |
| 594 | 592 | \\cookie: somevalue |
| 595 | 593 | \\ |
| 596 | , try std.fmt.bufPrint(buf[0..], "{}", .{h})); | |
| 594 | , try std.fmtstream.bufPrint(buf[0..], "{}", .{h})); | |
| 597 | 595 | } |
lib/std/io/out_stream.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ pub fn OutStream( |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | pub fn print(self: Self, comptime format: []const u8, args: var) Error!void { |
| 28 | return std.fmt.format(self, Error, writeAll, format, args); | |
| 28 | return std.fmtstream.format(self, format, args); | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | pub fn writeByte(self: Self, byte: u8) Error!void { |
lib/std/math/big/int.zig+3-5| ... | ... | @@ -518,17 +518,15 @@ pub const Int = struct { |
| 518 | 518 | pub fn format( |
| 519 | 519 | self: Int, |
| 520 | 520 | comptime fmt: []const u8, |
| 521 | options: std.fmt.FormatOptions, | |
| 522 | context: var, | |
| 523 | comptime FmtError: type, | |
| 524 | output: fn (@TypeOf(context), []const u8) FmtError!void, | |
| 521 | options: std.fmtstream.FormatOptions, | |
| 522 | out_stream: var, | |
| 525 | 523 | ) FmtError!void { |
| 526 | 524 | self.assertWritable(); |
| 527 | 525 | // TODO look at fmt and support other bases |
| 528 | 526 | // TODO support read-only fixed integers |
| 529 | 527 | const str = self.toString(self.allocator.?, 10) catch @panic("TODO make this non allocating"); |
| 530 | 528 | defer self.allocator.?.free(str); |
| 531 | return output(context, str); | |
| 529 | return out_stream.print(str); | |
| 532 | 530 | } |
| 533 | 531 | |
| 534 | 532 | /// Returns -1, 0, 1 if |a| < |b|, |a| == |b| or |a| > |b| respectively. |
lib/std/net.zig+10-12| ... | ... | @@ -268,16 +268,14 @@ pub const Address = extern union { |
| 268 | 268 | pub fn format( |
| 269 | 269 | self: Address, |
| 270 | 270 | comptime fmt: []const u8, |
| 271 | options: std.fmt.FormatOptions, | |
| 272 | context: var, | |
| 273 | comptime Errors: type, | |
| 274 | comptime output: fn (@TypeOf(context), []const u8) Errors!void, | |
| 271 | options: std.fmtstream.FormatOptions, | |
| 272 | out_stream: var, | |
| 275 | 273 | ) !void { |
| 276 | 274 | switch (self.any.family) { |
| 277 | 275 | os.AF_INET => { |
| 278 | 276 | const port = mem.bigToNative(u16, self.in.port); |
| 279 | 277 | const bytes = @ptrCast(*const [4]u8, &self.in.addr); |
| 280 | try std.fmt.format(context, Errors, output, "{}.{}.{}.{}:{}", .{ | |
| 278 | try std.fmtstream.format(out_stream, "{}.{}.{}.{}:{}", .{ | |
| 281 | 279 | bytes[0], |
| 282 | 280 | bytes[1], |
| 283 | 281 | bytes[2], |
| ... | ... | @@ -288,7 +286,7 @@ pub const Address = extern union { |
| 288 | 286 | os.AF_INET6 => { |
| 289 | 287 | const port = mem.bigToNative(u16, self.in6.port); |
| 290 | 288 | if (mem.eql(u8, self.in6.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { |
| 291 | try std.fmt.format(context, Errors, output, "[::ffff:{}.{}.{}.{}]:{}", .{ | |
| 289 | try std.fmtstream.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{ | |
| 292 | 290 | self.in6.addr[12], |
| 293 | 291 | self.in6.addr[13], |
| 294 | 292 | self.in6.addr[14], |
| ... | ... | @@ -308,30 +306,30 @@ pub const Address = extern union { |
| 308 | 306 | break :blk buf; |
| 309 | 307 | }, |
| 310 | 308 | }; |
| 311 | try output(context, "["); | |
| 309 | try out_stream.writeAll("["); | |
| 312 | 310 | var i: usize = 0; |
| 313 | 311 | var abbrv = false; |
| 314 | 312 | while (i < native_endian_parts.len) : (i += 1) { |
| 315 | 313 | if (native_endian_parts[i] == 0) { |
| 316 | 314 | if (!abbrv) { |
| 317 | try output(context, if (i == 0) "::" else ":"); | |
| 315 | try out_stream.writeAll(if (i == 0) "::" else ":"); | |
| 318 | 316 | abbrv = true; |
| 319 | 317 | } |
| 320 | 318 | continue; |
| 321 | 319 | } |
| 322 | try std.fmt.format(context, Errors, output, "{x}", .{native_endian_parts[i]}); | |
| 320 | try std.fmtstream.format(out_stream, "{x}", .{native_endian_parts[i]}); | |
| 323 | 321 | if (i != native_endian_parts.len - 1) { |
| 324 | try output(context, ":"); | |
| 322 | try out_stream.writeAll(":"); | |
| 325 | 323 | } |
| 326 | 324 | } |
| 327 | try std.fmt.format(context, Errors, output, "]:{}", .{port}); | |
| 325 | try std.fmtstream.format(out_stream, "]:{}", .{port}); | |
| 328 | 326 | }, |
| 329 | 327 | os.AF_UNIX => { |
| 330 | 328 | if (!has_unix_sockets) { |
| 331 | 329 | unreachable; |
| 332 | 330 | } |
| 333 | 331 | |
| 334 | try std.fmt.format(context, Errors, output, "{}", .{&self.un.path}); | |
| 332 | try std.fmtstream.format(out_stream, "{}", .{&self.un.path}); | |
| 335 | 333 | }, |
| 336 | 334 | else => unreachable, |
| 337 | 335 | } |
lib/std/net/test.zig+2-2| ... | ... | @@ -29,7 +29,7 @@ test "parse and render IPv6 addresses" { |
| 29 | 29 | }; |
| 30 | 30 | for (ips) |ip, i| { |
| 31 | 31 | var addr = net.Address.parseIp6(ip, 0) catch unreachable; |
| 32 | var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable; | |
| 32 | var newIp = std.fmtstream.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable; | |
| 33 | 33 | std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3])); |
| 34 | 34 | } |
| 35 | 35 | |
| ... | ... | @@ -51,7 +51,7 @@ test "parse and render IPv4 addresses" { |
| 51 | 51 | "127.0.0.1", |
| 52 | 52 | }) |ip| { |
| 53 | 53 | var addr = net.Address.parseIp4(ip, 0) catch unreachable; |
| 54 | var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable; | |
| 54 | var newIp = std.fmtstream.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable; | |
| 55 | 55 | std.testing.expect(std.mem.eql(u8, ip, newIp[0 .. newIp.len - 2])); |
| 56 | 56 | } |
| 57 | 57 |
lib/std/os/uefi.zig+3-7| ... | ... | @@ -5,8 +5,6 @@ pub const protocols = @import("uefi/protocols.zig"); |
| 5 | 5 | pub const status = @import("uefi/status.zig"); |
| 6 | 6 | pub const tables = @import("uefi/tables.zig"); |
| 7 | 7 | |
| 8 | const fmt = @import("std").fmt; | |
| 9 | ||
| 10 | 8 | /// The EFI image's handle that is passed to its entry point. |
| 11 | 9 | pub var handle: Handle = undefined; |
| 12 | 10 | |
| ... | ... | @@ -29,13 +27,11 @@ pub const Guid = extern struct { |
| 29 | 27 | pub fn format( |
| 30 | 28 | self: @This(), |
| 31 | 29 | comptime f: []const u8, |
| 32 | options: fmt.FormatOptions, | |
| 33 | context: var, | |
| 34 | comptime Errors: type, | |
| 35 | output: fn (@TypeOf(context), []const u8) Errors!void, | |
| 30 | options: std.fmtstream.FormatOptions, | |
| 31 | out_stream: var, | |
| 36 | 32 | ) Errors!void { |
| 37 | 33 | if (f.len == 0) { |
| 38 | return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ | |
| 34 | return std.fmtstream.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ | |
| 39 | 35 | self.time_low, |
| 40 | 36 | self.time_mid, |
| 41 | 37 | self.time_high_and_version, |