authorgravatar for sentrycraft123@gmail.comJan200101 <sentrycraft123@gmail.com> 2023-06-26 08:23:05+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-26 04:25:14-07:00
log42ca3576049192754be02f6aac054cf95ba17d1b
treefa07aca6530cfc7fb18c2cb5861ba64bd8eda419
parentd5ebe3e3953eae7c3b62e01ec94d5e0ba19c48a8

std.Build: omit newline from last line


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

lib/std/Build/Step/ConfigHeader.zig+7-6
...@@ -303,10 +303,7 @@ fn render_cmake(...@@ -303,10 +303,7 @@ fn render_cmake(
303 var line_index: u32 = 0;303 var line_index: u32 = 0;
304 var line_it = std.mem.splitScalar(u8, contents, '\n');304 var line_it = std.mem.splitScalar(u8, contents, '\n');
305 while (line_it.next()) |raw_line| : (line_index += 1) {305 while (line_it.next()) |raw_line| : (line_index += 1) {
306 // if we reached the end of the buffer there is nothing worth doing anymore306 const last_line = line_it.index == line_it.buffer.len;
307 if (line_it.index == line_it.buffer.len) {
308 continue;
309 }
310307
311 const first_pass = replace_variables(allocator, raw_line, values, "@", "@") catch @panic("Failed to substitute");308 const first_pass = replace_variables(allocator, raw_line, values, "@", "@") catch @panic("Failed to substitute");
312 const line = replace_variables(allocator, first_pass, values, "${", "}") catch @panic("Failed to substitute");309 const line = replace_variables(allocator, first_pass, values, "${", "}") catch @panic("Failed to substitute");
...@@ -316,7 +313,9 @@ fn render_cmake(...@@ -316,7 +313,9 @@ fn render_cmake(
316313
317 if (!std.mem.startsWith(u8, line, "#")) {314 if (!std.mem.startsWith(u8, line, "#")) {
318 try output.appendSlice(line);315 try output.appendSlice(line);
319 try output.appendSlice("\n");316 if (!last_line) {
317 try output.appendSlice("\n");
318 }
320 continue;319 continue;
321 }320 }
322 var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");321 var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");
...@@ -325,7 +324,9 @@ fn render_cmake(...@@ -325,7 +324,9 @@ fn render_cmake(
325 !std.mem.eql(u8, cmakedefine, "cmakedefine01"))324 !std.mem.eql(u8, cmakedefine, "cmakedefine01"))
326 {325 {
327 try output.appendSlice(line);326 try output.appendSlice(line);
328 try output.appendSlice("\n");327 if (!last_line) {
328 try output.appendSlice("\n");
329 }
329 continue;330 continue;
330 }331 }
331332