authorgravatar for aidenhaledev@gmail.comMrDmitry <aidenhaledev@gmail.com> 2024-01-21 03:16:09-05:00
committergravatar for aidenhaledev@gmail.comMrDmitry <aidenhaledev@gmail.com> 2024-01-21 03:16:09-05:00
log2dfec13ef08e0b47f0d80d599fb8552438e9e37a
tree69438f4663bc7bd86d39a68f5b8a59feea36a459
parent2e7d28dd0d27d94945ac5f131d7f7b4e03bc0024

Fix last_index after variable substitution

Iterative passes should start at the end of the previous substitution

1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/Build/Step/ConfigHeader.zig+4-4
...@@ -537,7 +537,7 @@ fn replace_variables(...@@ -537,7 +537,7 @@ fn replace_variables(
537 switch (value) {537 switch (value) {
538 .boolean => |b| {538 .boolean => |b| {
539 const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, @intFromBool(b), endline });539 const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, @intFromBool(b), endline });
540 last_index = start_index + 1;540 last_index = prefix_index + 1;
541541
542 allocator.free(content_buf);542 allocator.free(content_buf);
543 content_buf = buf;543 content_buf = buf;
...@@ -546,14 +546,14 @@ fn replace_variables(...@@ -546,14 +546,14 @@ fn replace_variables(
546 const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, i, endline });546 const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, i, endline });
547 const isNegative = i < 0;547 const isNegative = i < 0;
548 const digits = (if (0 < i) std.math.log10(@abs(i)) else 0) + 1;548 const digits = (if (0 < i) std.math.log10(@abs(i)) else 0) + 1;
549 last_index = start_index + @intFromBool(isNegative) + digits + 1;549 last_index = prefix_index + @intFromBool(isNegative) + digits;
550550
551 allocator.free(content_buf);551 allocator.free(content_buf);
552 content_buf = buf;552 content_buf = buf;
553 },553 },
554 .string, .ident => |x| {554 .string, .ident => |x| {
555 const buf = try std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ beginline, x, endline });555 const buf = try std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ beginline, x, endline });
556 last_index = start_index + x.len + 1;556 last_index = prefix_index + x.len;
557557
558 allocator.free(content_buf);558 allocator.free(content_buf);
559 content_buf = buf;559 content_buf = buf;
...@@ -561,7 +561,7 @@ fn replace_variables(...@@ -561,7 +561,7 @@ fn replace_variables(
561561
562 else => {562 else => {
563 const buf = try std.fmt.allocPrint(allocator, "{s}{s}", .{ beginline, endline });563 const buf = try std.fmt.allocPrint(allocator, "{s}{s}", .{ beginline, endline });
564 last_index = start_index + 1;564 last_index = prefix_index;
565565
566 allocator.free(content_buf);566 allocator.free(content_buf);
567 content_buf = buf;567 content_buf = buf;