authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-01 23:43:20+02:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-01 23:43:20+02:00
logc854c6577a0720fc538f55d9e2a65621172035eb
tree2cc2c336924fc7dfab788852ab1a22c13819d26e
parent9ef236bc114fa859768d0837abe4e7e573ad22c8
parentf6366f65bcff9405e11aeb6b876211f33c0076a4

Merge pull request 'Two tiny fmt simplifications' (#36361) from whatisaphone/zig:tiny-fmt-fixes into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36361

2 files changed, 4 insertions(+), 5 deletions(-)

lib/std/ascii.zig+3-3
...@@ -511,11 +511,11 @@ pub const HexEscape = struct {...@@ -511,11 +511,11 @@ pub const HexEscape = struct {
511};511};
512512
513/// Replaces non-ASCII bytes with hex escapes.513/// Replaces non-ASCII bytes with hex escapes.
514pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) std.fmt.Alt(HexEscape, HexEscape.format) {514pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) HexEscape {
515 return .{ .data = .{ .bytes = bytes, .charset = switch (case) {515 return .{ .bytes = bytes, .charset = switch (case) {
516 .lower => HexEscape.lower_charset,516 .lower => HexEscape.lower_charset,
517 .upper => HexEscape.upper_charset,517 .upper => HexEscape.upper_charset,
518 } } };518 } };
519}519}
520520
521test hexEscape {521test hexEscape {
lib/std/zig.zig+1-2
...@@ -545,8 +545,7 @@ pub fn stringEscape(bytes: []const u8, w: *Writer) Writer.Error!void {...@@ -545,8 +545,7 @@ pub fn stringEscape(bytes: []const u8, w: *Writer) Writer.Error!void {
545 '\t' => try w.writeAll("\\t"),545 '\t' => try w.writeAll("\\t"),
546 '\\' => try w.writeAll("\\\\"),546 '\\' => try w.writeAll("\\\\"),
547 '"' => try w.writeAll("\\\""),547 '"' => try w.writeAll("\\\""),
548 '\'' => try w.writeByte('\''),548 ' ', '!', '#'...'[', ']'...'~' => try w.writeByte(byte),
549 ' ', '!', '#'...'&', '('...'[', ']'...'~' => try w.writeByte(byte),
550 else => {549 else => {
551 try w.writeAll("\\x");550 try w.writeAll("\\x");
552 try w.printInt(byte, 16, .lower, .{ .width = 2, .fill = '0' });551 try w.printInt(byte, 16, .lower, .{ .width = 2, .fill = '0' });