From d910ed8b9f2442db3453b59b490c7c528483b21a Mon Sep 17 00:00:00 2001
From: Yorhel <git@yorhel.nl>
Date: Mon, 7 Jun 2021 11:21:53 +0200
Subject: [PATCH] Add workaround for Zig bug on FreeBSD

The good news is: apart from this little thing, everything seems to just
work(tm) on FreeBSD. Think I had more trouble with C because of minor
header file differences.
---
 src/ncurses_refs.c | 3 +++
 src/ui.zig         | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ncurses_refs.c b/src/ncurses_refs.c
index ed1a4c3..bcaeb3d 100644
--- a/src/ncurses_refs.c
+++ b/src/ncurses_refs.c
@@ -21,3 +21,6 @@ chtype ncdu_acs_urcorner() { return ACS_URCORNER; }
 chtype ncdu_acs_lrcorner() { return ACS_LRCORNER; }
 chtype ncdu_acs_hline()    { return ACS_VLINE   ; }
 chtype ncdu_acs_vline()    { return ACS_HLINE   ; }
+
+/* https://github.com/ziglang/zig/issues/8947 */
+void ncdu_init_pair(short a,b,c) { init_pair(a,b,c); }
diff --git a/src/ui.zig b/src/ui.zig
index 3f3129f..3c7e0ab 100644
--- a/src/ui.zig
+++ b/src/ui.zig
@@ -184,6 +184,7 @@ extern fn ncdu_acs_urcorner() c.chtype;
 extern fn ncdu_acs_lrcorner() c.chtype;
 extern fn ncdu_acs_hline()    c.chtype;
 extern fn ncdu_acs_vline()    c.chtype;
+extern fn ncdu_init_pair(idx: c_short, fg: c_short, bg: c_short) void;
 
 const StyleAttr = struct { fg: i16, bg: i16, attr: u32 };
 const StyleDef = struct {
@@ -334,7 +335,7 @@ pub fn init() void {
 
     _ = c.start_color();
     _ = c.use_default_colors();
-    for (styles) |s, i| _ = c.init_pair(@intCast(i16, i+1), s.style().fg, s.style().bg);
+    for (styles) |s, i| _ = ncdu_init_pair(@intCast(i16, i+1), s.style().fg, s.style().bg);
 
     inited = true;
 }
-- 
GitLab