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(
303303 var line_index: u32 = 0;
304304 var line_it = std.mem.splitScalar(u8, contents, '\n');
305305 while (line_it.next()) |raw_line| : (line_index += 1) {
306 // if we reached the end of the buffer there is nothing worth doing anymore
307 if (line_it.index == line_it.buffer.len) {
308 continue;
309 }
306 const last_line = line_it.index == line_it.buffer.len;
310307
311308 const first_pass = replace_variables(allocator, raw_line, values, "@", "@") catch @panic("Failed to substitute");
312309 const line = replace_variables(allocator, first_pass, values, "${", "}") catch @panic("Failed to substitute");
......@@ -316,7 +313,9 @@ fn render_cmake(
316313
317314 if (!std.mem.startsWith(u8, line, "#")) {
318315 try output.appendSlice(line);
319 try output.appendSlice("\n");
316 if (!last_line) {
317 try output.appendSlice("\n");
318 }
320319 continue;
321320 }
322321 var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");
......@@ -325,7 +324,9 @@ fn render_cmake(
325324 !std.mem.eql(u8, cmakedefine, "cmakedefine01"))
326325 {
327326 try output.appendSlice(line);
328 try output.appendSlice("\n");
327 if (!last_line) {
328 try output.appendSlice("\n");
329 }
329330 continue;
330331 }
331332