From 5e3e6a6dcee39b172dbce3e94e2998f5874accb8 Mon Sep 17 00:00:00 2001
From: "m.milanovic@levi9.com" <m.milanovic@levi9.com>
Date: Tue, 2 Sep 2014 12:11:21 +0200
Subject: [PATCH] Fixed compile on MINGW so it is confirmed working on versions
 4.6.x till 4.9.x

---
 mongoose.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index cc373d042..f8fa05ea3 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -1152,7 +1152,12 @@ void ns_server_free(struct ns_server *s) {
 #define STR(x) STRX(x)
 #define __func__ __FILE__ ":" STR(__LINE__)
 #endif
-#define INT64_FMT  "I64d"
+/* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 till 4.8*/
+#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 && __GNUC_MINOR__ < 8))) || defined(_MSC_VER)
+#define INT64_FMT   "I64d"
+#else
+#define INT64_FMT   "lld"
+#endif
 #define stat(x, y) mg_stat((x), (y))
 #define fopen(x, y) mg_fopen((x), (y))
 #define open(x, y) mg_open((x), (y))
@@ -2086,7 +2091,7 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) {
   } while (fds[0] == INVALID_SOCKET);
 
   if (start_process(conn->server->config_options[CGI_INTERPRETER],
-                    prog, blk.buf, blk.vars, dir, fds[1]) > 0) {
+                    prog, blk.buf, blk.vars, dir, fds[1]) != 0) {
     conn->endpoint_type = EP_CGI;
     conn->endpoint.nc = ns_add_sock(&conn->server->ns_server, fds[0], conn);
     conn->endpoint.nc->flags |= MG_CGI_CONN;
-- 
GitLab