Skip to content

Commit

Permalink
dprintf() polyfill for Solaris
Browse files Browse the repository at this point in the history
  • Loading branch information
sjmulder committed Jul 15, 2024
1 parent 86d883e commit 2ccfafe
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
#define alloca(size) __builtin_alloca(size)
#endif

#ifdef __sun
#define NEED_DPRINTF
#endif

#include "nnn.h"
#include "dbg.h"

Expand Down Expand Up @@ -856,6 +860,27 @@ static void notify_fifo(bool force);

/* Functions */

#ifdef NEED_DPRINTF
static int dprintf(int fd, const char *format, ...)
{
va_list ap;
char *s;
int len, nwritten;

va_start(ap, format);
len = vasprintf(&s, format, ap);
va_end(ap);

if (len == -1)
return -1;

nwritten = write(fd, s, len);
free(s);

return nwritten;
}
#endif

static void sigint_handler(int sig)
{
(void) sig;
Expand Down

0 comments on commit 2ccfafe

Please sign in to comment.