enable va_list fix only on mingw (this is the real release, as usual) v1.1 v1.1.1

Tue, 12 Dec 2017 17:41:01 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 12 Dec 2017 17:41:01 +0100
branch
v1.1
changeset 341
7954fdacdb5c
parent 340
9f37d0806200
child 342
0b03aa8fb838

enable va_list fix only on mingw (this is the real release, as usual)

libidav/davqlexec.c file | annotate | diff | comparison | revisions
libidav/davqlexec.h file | annotate | diff | comparison | revisions
--- a/libidav/davqlexec.c	Tue Dec 12 15:51:09 2017 +0100
+++ b/libidav/davqlexec.c	Tue Dec 12 17:41:01 2017 +0100
@@ -66,7 +66,7 @@
     return result;
 }
 
-sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, va_list *ap, davqlerror_t *error) {
+sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, dav_valist ap, davqlerror_t *error) {
     UcxBuffer *buf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND);
     
     int placeholder = 0;
@@ -81,17 +81,17 @@
                 int err = 0;
                 switch(c) {
                     case 's': {
-                        char *arg = va_arg(*ap, char*);
+                        char *arg = dav_vaarg(ap, char*);
                         ucx_buffer_puts(buf, arg);
                         break;
                     }
                     case 'd': {
-                        int arg = va_arg(*ap, int);
+                        int arg = dav_vaarg(ap, int);
                         ucx_bprintf(buf, "%d", arg);
                         break;
                     }
                     case 'u': {
-                        unsigned int arg = va_arg(*ap, unsigned int);
+                        unsigned int arg = dav_vaarg(ap, unsigned int);
                         ucx_bprintf(buf, "%u", arg);
                         break;
                     }
@@ -371,7 +371,7 @@
     
     // get path string
     davqlerror_t error;
-    sstr_t path = dav_format_string(mp->allocator, st->path, &ap, &error);
+    sstr_t path = dav_fmt_str(mp->allocator, st->path, ap, &error);
     if(error) {
         // TODO: cleanup
         ucx_mempool_destroy(mp);
@@ -640,7 +640,7 @@
         }
         case DAVQL_STRING: {
             cmd.type = DAVQL_CMD_STRING;
-            cmd.data.string = dav_format_string(a, src, &ap, &error);
+            cmd.data.string = dav_fmt_str(a, src, ap, &error);
             ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode);
             break;
         }
--- a/libidav/davqlexec.h	Tue Dec 12 15:51:09 2017 +0100
+++ b/libidav/davqlexec.h	Tue Dec 12 17:41:01 2017 +0100
@@ -38,6 +38,18 @@
 extern "C" {
 #endif
 
+#ifdef _WIN32
+/* va_list workaround for mingw */
+typedef va_list* dav_valist;
+#define dav_fmt_str(a, fstr, ap, error) dav_format_string(a, fstr, &ap, error)
+#define dav_vaarg(ap, type) va_arg(*ap, type)
+#else
+typedef va_list dav_valist;
+#define dav_fmt_str(a, fstr, ap, error) dav_format_string(a, fstr, ap, error)
+#define dav_vaarg(ap, type) va_arg(ap, type)
+#endif
+
+
 typedef struct DavQLCmd      DavQLCmd;
 typedef struct DavQLStackObj DavQLStackObj;
 typedef struct DavQLRes      DavQLRes;
@@ -138,7 +150,7 @@
 DavResult dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap);
 
 UcxBuffer* dav_path_string(sstr_t src, va_list ap, davqlerror_t *error);
-sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, va_list *ap, davqlerror_t *error);
+sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, dav_valist ap, davqlerror_t *error);
 
 DavResult dav_exec_select(DavSession *sn, DavQLStatement *st, va_list ap);
 

mercurial