Skip to content

Commit

Permalink
sysutils/nnn: Improved dprintf() polyfill for Solaris
Browse files Browse the repository at this point in the history
This the improved version submitted to upstream:

jarun/nnn#1911
  • Loading branch information
sjmulder committed Jul 15, 2024
1 parent 6125ebb commit 629006f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions sysutils/nnn/distinfo
Original file line number Diff line number Diff line change
@@ -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
21 changes: 12 additions & 9 deletions sysutils/nnn/patches/patch-src_nnn.c
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
+
Expand Down

0 comments on commit 629006f

Please sign in to comment.