URI: 
       Add local asprintf in case not available on target system - sacc - sacc(omys), simple console gopher client
  HTML git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR LICENSE
       ---
   DIR commit 7147f4745a6d08c9986e26df265d59db174663f8
   DIR parent 551de298348c406d14ab8f2787cfeabbeb89bd6e
  HTML Author: Quentin Rameau <quinq@fifth.space>
       Date:   Sat, 24 Feb 2018 13:24:26 +0100
       
       Add local asprintf in case not available on target system
       
       Diffstat:
         M common.h                            |       3 +++
         M sacc.c                              |      29 ++++++++++++++++++++++++++---
       
       2 files changed, 29 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/common.h b/common.h
       @@ -22,6 +22,9 @@ struct dir {
                size_t curline;
        };
        
       +#ifndef asprintf
       +int asprintf(char **s, const char *fmt, ...);
       +#endif /* asprintf */
        void die(const char *fmt, ...);
        size_t mbsprint(const char *s, size_t len);
        const char *typedisplay(char t);
   DIR diff --git a/sacc.c b/sacc.c
       @@ -1,6 +1,7 @@
        /* See LICENSE file for copyright and license details. */
        #include <errno.h>
        #include <fcntl.h>
       +#include <limits.h>
        #include <locale.h>
        #include <netdb.h>
        #include <netinet/in.h>
       @@ -39,6 +40,28 @@ die(const char *fmt, ...)
                exit(1);
        }
        
       +#ifndef asprintf
       +int
       +asprintf(char **s, const char *fmt, ...)
       +{
       +        va_list ap;
       +        int n;
       +
       +        va_start(ap, fmt);
       +        n = vsnprintf(NULL, 0, fmt, ap);
       +        va_end(ap);
       +
       +        if (n == INT_MAX || !(*s = malloc(++n)))
       +                return -1;
       +
       +        va_start(ap, fmt);
       +        vsnprintf(*s, n, fmt, ap);
       +        va_end(ap);
       +
       +        return n;
       +}
       +#endif /* asprintf */
       +
        /* print `len' columns of characters. */
        size_t
        mbsprint(const char *s, size_t len)
       @@ -558,9 +581,9 @@ plumbitem(Item *item)
                if (!path[0]) {
                        clear(&path);
                        if (!tag) {
       -                        n = snprintf(NULL, 0, "%s/%s", tmpdir, file);
       -                        path = xmalloc(++n);
       -                        snprintf(path, n, "%s/%s", tmpdir, file);
       +                        if (asprintf(&path, "%s/%s", tmpdir, file) < 0)
       +                                die("Can't generate tmpdir path: ",
       +                                    strerror(errno));
                        }
                }