From 629006fd8d59e4a27c9d49c25810438d78dc2492 Mon Sep 17 00:00:00 2001 From: sjmulder Date: Mon, 15 Jul 2024 22:44:54 +0000 Subject: [PATCH] sysutils/nnn: Improved dprintf() polyfill for Solaris This the improved version submitted to upstream: https://github.com/jarun/nnn/pull/1911 --- sysutils/nnn/distinfo | 4 ++-- sysutils/nnn/patches/patch-src_nnn.c | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sysutils/nnn/distinfo b/sysutils/nnn/distinfo index bc37e85d9de5..f660ac5af075 100644 --- a/sysutils/nnn/distinfo +++ b/sysutils/nnn/distinfo @@ -1,6 +1,6 @@ -$NetBSD: distinfo,v 1.31 2024/07/15 22:36:52 sjmulder Exp $ +$NetBSD: distinfo,v 1.32 2024/07/15 22:44:54 sjmulder Exp $ BLAKE2s (nnn-4.9.tar.gz) = 55ebf293e0ed886798eb9ce90969b45c3cfadc88714d74e16c01fa05872b7150 SHA512 (nnn-4.9.tar.gz) = 3c16ed1cbc5466b05306e38c6f5d8eb7ade9cf5ad766f9ff3bf7d20d5bfb9bdf1564527e27191e2cd85542c25245f338e1236630de3d1c8e5fbd10d54d628a14 Size (nnn-4.9.tar.gz) = 255144 bytes -SHA1 (patch-src_nnn.c) = a61aa482a61cbffa4b3fcfcc1c1778c7b67716b9 +SHA1 (patch-src_nnn.c) = 649a46faa103b6bc15f45be6fca5759440e93f78 diff --git a/sysutils/nnn/patches/patch-src_nnn.c b/sysutils/nnn/patches/patch-src_nnn.c index 84197533732b..5db237fe8abb 100644 --- a/sysutils/nnn/patches/patch-src_nnn.c +++ b/sysutils/nnn/patches/patch-src_nnn.c @@ -1,6 +1,7 @@ -$NetBSD: patch-src_nnn.c,v 1.6 2024/07/15 22:36:52 sjmulder Exp $ +$NetBSD: patch-src_nnn.c,v 1.7 2024/07/15 22:44:54 sjmulder Exp $ - dprintf() polyfill for Solaris. + https://github.com/jarun/nnn/pull/1911 - Disable large file support on old glibc where unsupported in fts.h. https://github.com/jarun/nnn/pull/1910 @@ -29,33 +30,35 @@ #define alloca(size) __builtin_alloca(size) #endif -+#ifdef __sun /* for Illumos. Solaris 11 has it. */ ++#ifdef __sun +#define NEED_DPRINTF +#endif + #include "nnn.h" #include "dbg.h" -@@ -854,6 +861,25 @@ static void notify_fifo(bool force); +@@ -854,6 +861,27 @@ static void notify_fifo(bool force); /* Functions */ +#ifdef NEED_DPRINTF -+int dprintf(int fd, const char *format, ...) ++static int dprintf(int fd, const char *format, ...) +{ + va_list ap; + char *s; ++ int len, nwritten; + + va_start(ap, format); -+ if (vasprintf(&s, format, ap) == -1) -+ { va_end(ap); return -1; } ++ len = vasprintf(&s, format, ap); + va_end(ap); + -+ if (write(fd, s, strlen(s)) == -1) -+ { free(s); return -1; } ++ if (len == -1) ++ return -1; + ++ nwritten = write(fd, s, len); + free(s); -+ return 0; ++ ++ return nwritten; +} +#endif +