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 {...@@ -80,7 +80,7 @@ const Action = struct {
80 const hay = mem.trim(u8, haystack, " ");80 const hay = mem.trim(u8, haystack, " ");
81 const phrase = mem.trim(u8, act.phrase.resolve(b, step), " ");81 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);
84 var hay_it = mem.tokenizeScalar(u8, hay, ' ');84 var hay_it = mem.tokenizeScalar(u8, hay, ' ');
85 var needle_it = mem.tokenizeScalar(u8, phrase, ' ');85 var needle_it = mem.tokenizeScalar(u8, phrase, ' ');
8686
...@@ -92,18 +92,21 @@ const Action = struct {...@@ -92,18 +92,21 @@ const Action = struct {
9292
93 const name = needle_tok[1..closing_brace];93 const name = needle_tok[1..closing_brace];
94 if (name.len == 0) return error.MissingBraceValue;94 if (name.len == 0) return error.MissingBraceValue;
95 const value = try std.fmt.parseInt(u64, hay_tok, 16);95 const value = std.fmt.parseInt(u64, hay_tok, 16) catch return false;
96 candidate_var = .{96 try candidate_vars.append(.{
97 .name = name,97 .name = name,
98 .value = value,98 .value = value,
99 };99 });
100 } else {100 } else {
101 if (!mem.eql(u8, hay_tok, needle_tok)) return false;101 if (!mem.eql(u8, hay_tok, needle_tok)) return false;
102 }102 }
103 }103 }
104104
105 if (candidate_var) |v| try global_vars.putNoClobber(v.name, v.value);105 if (candidate_vars.items.len == 0) return false;
106 return candidate_var != null;106
107 for (candidate_vars.items) |cv| try global_vars.putNoClobber(cv.name, cv.value);
108
109 return true;
107 }110 }
108111
109 /// Returns true if the `phrase` is an exact match with the haystack.112 /// Returns true if the `phrase` is an exact match with the haystack.
...@@ -1253,7 +1256,7 @@ const ElfDumper = struct {...@@ -1253,7 +1256,7 @@ const ElfDumper = struct {
1253 } else if (sym.st_shndx == elf.SHN_UNDEF) {1256 } else if (sym.st_shndx == elf.SHN_UNDEF) {
1254 try writer.writeAll(" UND");1257 try writer.writeAll(" UND");
1255 } else {1258 } else {
1256 try writer.print(" {d}", .{sym.st_shndx});1259 try writer.print(" {x}", .{sym.st_shndx});
1257 }1260 }
1258 }1261 }
12591262