diff options
Diffstat (limited to 'src/lib.c')
-rw-r--r-- | src/lib.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,16 +1,18 @@ -int smprintf (char ** str, const char * format, ...) { /* allocates automaticalls (: */ - va_list ap, aq; +#ifndef _GNU_SOURCE /* glibc already provides asprintf, but some cucks tend not to use glibc */ +int asprintf (char ** str, const char * format, ...) { /* allocates automaticalls (: */ + va_list ap, aq; /* */ va_start(ap, format); va_copy(aq, ap); int len = vsnprintf(NULL, 0, format, ap); if (!(*str = realloc(*str, len+1))) fprintf(stderr, "[BUG] !!! realloc failed\n"); - if (len != vsprintf(*str, format, ap)) - fprintf(stderr, "[BUG] !!! len1 != len2\n"); + if (len != vsprintf(*str, format, aq /* we need to use a different va handler, because */)) + fprintf(stderr, "[BUG] !!! len1 != len2\n"); /* you can't rewind an existing one you can't rewind an existing one.. */ va_end(ap); va_end(aq); return len; } +#endif char * startswith (char * testiranec, char * začetek) { if (!strncmp(testiranec, začetek, strlen(začetek))) return testiranec+strlen(začetek); |