authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-24 17:19:47-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-25 15:13:00+02:00
log64c5cc80471ccd167af2403741dc2037824e0c8c
tree16d3dc0cd12af97dfdcacdbadc8e6ebf51db445e
parentfe671e7ba9138250e3435e40ac36460d89c0f67b

resinator: Sync with upstream

Fixes a bug where certain non-ASCII filenames would lead to errors

3 files changed, 8 insertions(+), 4 deletions(-)

lib/compiler/resinator/cli.zig+1-1
......@@ -15,7 +15,7 @@ pub const usage_string_after_command_name =
1515 \\ [options] [--] <INPUT> [<OUTPUT>]
1616 \\
1717 \\The sequence -- can be used to signify when to stop parsing options.
18 \\This is necessary when the input path begins with a forward slash.
18 \\This avoids ambiguity when the input path begins with a forward slash.
1919 \\
2020 \\Supported option prefixes are /, -, and --, so e.g. /h, -h, and --h all work.
2121 \\Drop-in compatible with the Microsoft Resource Compiler.
lib/compiler/resinator/compile.zig+2-2
......@@ -2746,7 +2746,7 @@ pub const Compiler = struct {
27462746 // 1. Any permutation that does not have PRELOAD in it just uses the
27472747 // default flags.
27482748 const initial_flags = flags.*;
2749 var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
2749 var flags_set: std.enums.EnumSet(rc.CommonResourceAttributes) = .empty;
27502750 for (tokens) |token| {
27512751 const attribute = rc.CommonResourceAttributes.map.get(token.slice(source)).?;
27522752 flags_set.insert(attribute);
......@@ -2769,7 +2769,7 @@ pub const Compiler = struct {
27692769 // 3. If none of DISCARDABLE, SHARED, or PURE is specified, then PRELOAD
27702770 // implies `flags &= ~SHARED` and LOADONCALL implies `flags |= SHARED`
27712771 const shared_set = comptime blk: {
2772 var set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
2772 var set: std.enums.EnumSet(rc.CommonResourceAttributes) = .empty;
27732773 set.insert(.discardable);
27742774 set.insert(.shared);
27752775 set.insert(.pure);
lib/compiler/resinator/source_mapping.zig+5-1
......@@ -636,6 +636,10 @@ fn parseFilename(allocator: Allocator, str: []const u8) error{ OutOfMemory, Inva
636636 if (escape_val != 0) escape_val = std.math.mul(u8, @as(u8, @intCast(escape_val)), 16) catch return error.InvalidString;
637637 escape_val = std.math.add(u8, @as(u8, @intCast(escape_val)), digit) catch return error.InvalidString;
638638 escape_len += 1;
639 if (escape_len == 2) {
640 filename.appendAssumeCapacity(@intCast(escape_val));
641 state = .string;
642 }
639643 },
640644 else => {
641645 if (escape_len == 0) return error.InvalidString;
......@@ -706,6 +710,7 @@ fn testParseFilename(expected: []const u8, input: []const u8) !void {
706710test parseFilename {
707711 try testParseFilename("'\"?\\\t\n\r\x11", "\\'\\\"\\?\\\\\\t\\n\\r\\x11");
708712 try testParseFilename("\xABz\x53", "\\xABz\\123");
713 try testParseFilename("\xABCDEF", "\\xABCDEF");
709714 try testParseFilename("⚡⚡", "\\u26A1\\U000026A1");
710715 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\""));
711716 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\\"));
......@@ -713,7 +718,6 @@ test parseFilename {
713718 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\\U"));
714719 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\\x"));
715720 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\\xZZ"));
716 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\\xABCDEF"));
717721 try std.testing.expectError(error.InvalidString, parseFilename(std.testing.allocator, "\\777"));
718722}
719723