RPM Community Forums

Mailing List Message of <popt-devel>

popt windows build and vsnprintf

From: Alex Kashchenko <akashche@redhat.com>
Date: Thu 20 Oct 2016 - 16:48:02 CEST
Message-ID: <5808D922.4090303@redhat.com>
Hi,

I was building popt-1.13 for windows, it does not work out of the box, 
but fixes are straightforward except the following one:

diff --git a/src/poptint.c b/src/poptint.c
index e99d28b..1b5fd9f 100644
--- a/src/poptint.c
+++ b/src/poptint.c
@@ -102,7 +102,11 @@ strdup_vprintf (const char *format, va_list ap)
      va_copy(apc, ap);  /* XXX linux amd64/ppc needs a copy. */
  /*@=noeffectuncon =unrecog @*/

+#ifdef _WIN32
+    buffer = calloc(sizeof(*buffer), _vscprintf (format, ap) + 1);
+#elif // !_WIN32
      buffer = calloc(sizeof(*buffer), vsnprintf (&c, 1, format, ap) + 1);
+#endif // _WIN32

vsnprintf has non-standard behaviour on windows (does not return the 
required size), details [1].

I understand that windows is not a supported platform for popt (though 
found some previous porting efforts [2]), so sharing just for the record.


[1] http://stackoverflow.com/a/8490708/314015
[2] http://rpm5.org/community/popt-devel/0122.html

-- 
-Alex
Received on Thu Oct 20 16:54:02 2016
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.