diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-07-20 22:12:06 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-07-20 22:12:06 +0200 |
| commit | c0260d39d555b9cd0c0abc1f9f61ece55b992b1e (patch) | |
| tree | 25b1b41adced552ae31f47f2debc13816ae6928a /lib/std/Build/Step/CheckObject.zig | |
| parent | 245f6553e6840b2221141f3e7724ae6a73294387 (diff) | |
| download | zig-c0260d39d555b9cd0c0abc1f9f61ece55b992b1e.tar.gz zig-c0260d39d555b9cd0c0abc1f9f61ece55b992b1e.zip | |
check-object: allow for multiple extractions within one check
Diffstat (limited to 'lib/std/Build/Step/CheckObject.zig')
| -rw-r--r-- | lib/std/Build/Step/CheckObject.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig index 3fe84658a2..5a816b4103 100644 --- a/lib/std/Build/Step/CheckObject.zig +++ b/lib/std/Build/Step/CheckObject.zig @@ -80,7 +80,7 @@ const Action = struct { const hay = mem.trim(u8, haystack, " "); const phrase = mem.trim(u8, act.phrase.resolve(b, step), " "); - var candidate_var: ?struct { name: []const u8, value: u64 } = null; + var candidate_vars = std.ArrayList(struct { name: []const u8, value: u64 }).init(b.allocator); var hay_it = mem.tokenizeScalar(u8, hay, ' '); var needle_it = mem.tokenizeScalar(u8, phrase, ' '); @@ -92,18 +92,21 @@ const Action = struct { const name = needle_tok[1..closing_brace]; if (name.len == 0) return error.MissingBraceValue; - const value = try std.fmt.parseInt(u64, hay_tok, 16); - candidate_var = .{ + const value = std.fmt.parseInt(u64, hay_tok, 16) catch return false; + try candidate_vars.append(.{ .name = name, .value = value, - }; + }); } else { if (!mem.eql(u8, hay_tok, needle_tok)) return false; } } - if (candidate_var) |v| try global_vars.putNoClobber(v.name, v.value); - return candidate_var != null; + if (candidate_vars.items.len == 0) return false; + + for (candidate_vars.items) |cv| try global_vars.putNoClobber(cv.name, cv.value); + + return true; } /// Returns true if the `phrase` is an exact match with the haystack. @@ -1253,7 +1256,7 @@ const ElfDumper = struct { } else if (sym.st_shndx == elf.SHN_UNDEF) { try writer.writeAll(" UND"); } else { - try writer.print(" {d}", .{sym.st_shndx}); + try writer.print(" {x}", .{sym.st_shndx}); } } |
