commit 6043fbb2b7f263c0bab308f46f4ef393fec4a678 (tree)
parent be18e17ce528f5e4a0cda5f694c8ad13a6b38662
Author: fardragon <michaldrozd@protonmail.ch>
Date: Thu, 4 Jun 2026 18:54:43 +0000
Fix unexpected trailing newline for autconf_undef
Diffstat:
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/compiler/Maker/Step/ConfigHeader.zig b/lib/compiler/Maker/Step/ConfigHeader.zig
@@ -177,16 +177,18 @@ fn renderAutoConfUndef(
var line_index: u32 = 0;
var line_it = std.mem.splitScalar(u8, contents, '\n');
while (line_it.next()) |line| : (line_index += 1) {
+ const last_line = line_it.index == line_it.buffer.len;
+
if (!std.mem.startsWith(u8, line, "#")) {
try w.writeAll(line);
- try w.writeByte('\n');
+ if (!last_line) try w.writeByte('\n');
continue;
}
var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");
const undef = it.next().?;
if (!std.mem.eql(u8, undef, "undef")) {
try w.writeAll(line);
- try w.writeByte('\n');
+ if (!last_line) try w.writeByte('\n');
continue;
}
const name = it.next().?;
diff --git a/test/standalone/config_header/autoconf_undef/config.h b/test/standalone/config_header/autoconf_undef/config.h
@@ -30,5 +30,3 @@ int foo();
// non-#undef # lines pass through unchanged
#define KEPT_DEFINE value
#include <kept.h>
-// TODO: unexpected newline is being added here
-
diff --git a/test/standalone/config_header/autoconf_undef/config.h.in b/test/standalone/config_header/autoconf_undef/config.h.in
@@ -29,4 +29,3 @@ int foo();
// non-#undef # lines pass through unchanged
#define KEPT_DEFINE value
#include <kept.h>
-// TODO: unexpected newline is being added here