zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 64c5cc80471ccd167af2403741dc2037824e0c8c (tree)
parent fe671e7ba9138250e3435e40ac36460d89c0f67b
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Wed, 24 Jun 2026 17:19:47 -0700

resinator: Sync with upstream

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

Diffstat:
Mlib/compiler/resinator/cli.zig | 2+-
Mlib/compiler/resinator/compile.zig | 4++--
Mlib/compiler/resinator/source_mapping.zig | 6+++++-
3 files changed, 8 insertions(+), 4 deletions(-)

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