authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-07-20 22:12:06+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-07-20 22:12:06+02:00
logc0260d39d555b9cd0c0abc1f9f61ece55b992b1e
tree25b1b41adced552ae31f47f2debc13816ae6928a
parent245f6553e6840b2221141f3e7724ae6a73294387

check-object: allow for multiple extractions within one check


1 files changed, 10 insertions(+), 7 deletions(-)

lib/std/Build/Step/CheckObject.zig+10-7
......@@ -80,7 +80,7 @@ const Action = struct {
8080 const hay = mem.trim(u8, haystack, " ");
8181 const phrase = mem.trim(u8, act.phrase.resolve(b, step), " ");
8282
83 var candidate_var: ?struct { name: []const u8, value: u64 } = null;
83 var candidate_vars = std.ArrayList(struct { name: []const u8, value: u64 }).init(b.allocator);
8484 var hay_it = mem.tokenizeScalar(u8, hay, ' ');
8585 var needle_it = mem.tokenizeScalar(u8, phrase, ' ');
8686
......@@ -92,18 +92,21 @@ const Action = struct {
9292
9393 const name = needle_tok[1..closing_brace];
9494 if (name.len == 0) return error.MissingBraceValue;
95 const value = try std.fmt.parseInt(u64, hay_tok, 16);
96 candidate_var = .{
95 const value = std.fmt.parseInt(u64, hay_tok, 16) catch return false;
96 try candidate_vars.append(.{
9797 .name = name,
9898 .value = value,
99 };
99 });
100100 } else {
101101 if (!mem.eql(u8, hay_tok, needle_tok)) return false;
102102 }
103103 }
104104
105 if (candidate_var) |v| try global_vars.putNoClobber(v.name, v.value);
106 return candidate_var != null;
105 if (candidate_vars.items.len == 0) return false;
106
107 for (candidate_vars.items) |cv| try global_vars.putNoClobber(cv.name, cv.value);
108
109 return true;
107110 }
108111
109112 /// Returns true if the `phrase` is an exact match with the haystack.
......@@ -1253,7 +1256,7 @@ const ElfDumper = struct {
12531256 } else if (sym.st_shndx == elf.SHN_UNDEF) {
12541257 try writer.writeAll(" UND");
12551258 } else {
1256 try writer.print(" {d}", .{sym.st_shndx});
1259 try writer.print(" {x}", .{sym.st_shndx});
12571260 }
12581261 }
12591262