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(
537537 switch (value) {
538538 .boolean => |b| {
539539 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
542542 allocator.free(content_buf);
543543 content_buf = buf;
......@@ -546,14 +546,14 @@ fn replace_variables(
546546 const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, i, endline });
547547 const isNegative = i < 0;
548548 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
551551 allocator.free(content_buf);
552552 content_buf = buf;
553553 },
554554 .string, .ident => |x| {
555555 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
558558 allocator.free(content_buf);
559559 content_buf = buf;
......@@ -561,7 +561,7 @@ fn replace_variables(
561561
562562 else => {
563563 const buf = try std.fmt.allocPrint(allocator, "{s}{s}", .{ beginline, endline });
564 last_index = start_index + 1;
564 last_index = prefix_index;
565565
566566 allocator.free(content_buf);
567567 content_buf = buf;