--- libxml2-2.9.5/parser.c.orig	2017-08-31 04:48:54.000000000 -0400
+++ libxml2-2.9.5/parser.c	2017-09-25 23:42:47.956868800 -0400
@@ -1335,7 +1335,7 @@ xmlAddSpecialAttr(xmlParserCtxtPtr ctxt,
         return;
 
     xmlHashAddEntry2(ctxt->attsSpecial, fullname, fullattr,
-                     (void *) (long) type);
+                     (void *) ( intptr_t ) type);
     return;
 
 mem_error:
@@ -1354,7 +1354,7 @@ xmlCleanSpecialAttrCallback(void *payloa
                             const xmlChar *unused ATTRIBUTE_UNUSED) {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) data;
 
-    if (((long) payload) == XML_ATTRIBUTE_CDATA) {
+    if (((intptr_t) payload) == XML_ATTRIBUTE_CDATA) {
         xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL);
     }
 }
@@ -1866,7 +1866,7 @@ nameNsPush(xmlParserCtxtPtr ctxt, const
     ctxt->name = value;
     ctxt->pushTab[ctxt->nameNr * 3] = (void *) prefix;
     ctxt->pushTab[ctxt->nameNr * 3 + 1] = (void *) URI;
-    ctxt->pushTab[ctxt->nameNr * 3 + 2] = (void *) (long) nsNr;
+    ctxt->pushTab[ctxt->nameNr * 3 + 2] = (void *) (intptr_t) nsNr;
     return (ctxt->nameNr++);
 mem_error:
     xmlErrMemory(ctxt, NULL);
@@ -9074,7 +9074,7 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt
     if (ctxt->attsSpecial != NULL) {
         int type;
 
-        type = (int) (long) xmlHashQLookup2(ctxt->attsSpecial,
+        type = (intptr_t) xmlHashQLookup2(ctxt->attsSpecial,
                                             pref, elem, *prefix, name);
         if (type != 0)
             normalize = 1;
@@ -11538,7 +11538,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctx
 		    xmlParseEndTag2(ctxt,
 		           (void *) ctxt->pushTab[ctxt->nameNr * 3 - 3],
 		           (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0,
-		       (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1], 0);
+		       (intptr_t) ctxt->pushTab[ctxt->nameNr * 3 - 1], 0);
 		    nameNsPop(ctxt);
 		}
 #ifdef LIBXML_SAX1_ENABLED
--- libxml2-2.9.5/relaxng.c.orig	2017-09-25 22:20:38.696860200 -0400
+++ libxml2-2.9.5/relaxng.c	2017-09-25 22:24:27.206050500 -0400
@@ -4404,7 +4404,7 @@ xmlRelaxNGComputeInterleaves(xmlRelaxNGD
                 if ((*tmp)->type == XML_RELAXNG_TEXT) {
                     res = xmlHashAddEntry2(partitions->triage,
                                            BAD_CAST "#text", NULL,
-                                           (void *) (long) (i + 1));
+                                           (void *) (intptr_t) (i + 1));
                     if (res != 0)
                         is_determinist = -1;
                 } else if (((*tmp)->type == XML_RELAXNG_ELEMENT) &&
@@ -4412,22 +4412,22 @@ xmlRelaxNGComputeInterleaves(xmlRelaxNGD
                     if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0))
                         res = xmlHashAddEntry2(partitions->triage,
                                                (*tmp)->name, NULL,
-                                               (void *) (long) (i + 1));
+                                               (void *) (intptr_t) (i + 1));
                     else
                         res = xmlHashAddEntry2(partitions->triage,
                                                (*tmp)->name, (*tmp)->ns,
-                                               (void *) (long) (i + 1));
+                                               (void *) (intptr_t) (i + 1));
                     if (res != 0)
                         is_determinist = -1;
                 } else if ((*tmp)->type == XML_RELAXNG_ELEMENT) {
                     if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0))
                         res = xmlHashAddEntry2(partitions->triage,
                                                BAD_CAST "#any", NULL,
-                                               (void *) (long) (i + 1));
+                                               (void *) (intptr_t) (i + 1));
                     else
                         res = xmlHashAddEntry2(partitions->triage,
                                                BAD_CAST "#any", (*tmp)->ns,
-                                               (void *) (long) (i + 1));
+                                               (void *) (intptr_t) (i + 1));
                     if ((*tmp)->nameClass != NULL)
                         is_determinist = 2;
                     if (res != 0)
@@ -9387,7 +9387,7 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGV
             if (tmp == NULL) {
                 i = nbgroups;
             } else {
-                i = ((long) tmp) - 1;
+                i = ((intptr_t) tmp) - 1;
                 if (partitions->flags & IS_NEEDCHECK) {
                     group = partitions->groups[i];
                     if (!xmlRelaxNGNodeMatchesList(cur, group->defs))
--- libxml2-2.9.5/threads.c.orig	2017-09-26 00:44:34.507026700 -0400
+++ libxml2-2.9.5/threads.c	2017-09-26 00:51:11.490526600 -0400
@@ -438,7 +438,7 @@ __xmlGlobalInitMutexLock(void)
 
         /* Swap it into the global_init_lock */
 #ifdef InterlockedCompareExchangePointer
-        InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
+        InterlockedCompareExchangePointer((void **) &global_init_lock, cs, NULL);
 #else /* Use older void* version */
         InterlockedCompareExchange((void **) &global_init_lock,
                                    (void *) cs, NULL);
--- libxml2-2.9.5/tree.c.orig	2017-09-26 00:59:52.254930000 -0400
+++ libxml2-2.9.5/tree.c	2017-09-26 01:04:21.947654500 -0400
@@ -4605,7 +4605,7 @@ xmlGetLineNoInternal(const xmlNode *node
 	(node->type == XML_PI_NODE)) {
 	if (node->line == 65535) {
 	    if ((node->type == XML_TEXT_NODE) && (node->psvi != NULL))
-	        result = (long) node->psvi;
+	        result = (intptr_t) node->psvi;
 	    else if ((node->type == XML_ELEMENT_NODE) &&
 	             (node->children != NULL))
 	        result = xmlGetLineNoInternal(node->children, depth + 1);
--- libxml2-2.9.5/xmlmemory.c.orig	2017-09-25 22:45:17.523292500 -0400
+++ libxml2-2.9.5/xmlmemory.c	2017-09-25 22:57:31.306998000 -0400
@@ -43,6 +43,10 @@
 #endif
 #endif
 
+#ifdef __MINGW32__
+#include <stdint.h> /* minght be a good idea for other platforms */
+#endif
+
 #include <libxml/globals.h>	/* must come before xmlmemory.h */
 #include <libxml/xmlmemory.h>
 #include <libxml/xmlerror.h>
@@ -487,7 +491,21 @@ xmlMemFree(void *ptr)
 
 error:
     xmlGenericError(xmlGenericErrorContext,
-	    "xmlMemFree(%lX) error\n", (unsigned long) ptr);
+	    "xmlMemFree(%"
+#ifdef __MINGW32__
+/* This is not ISO standard C, but for compatiability with old msvcrt. llX is not recognized 
+and I noticed that the PRI macros in inttypes now return those values for compliance from the
+_mingw_print_pop.h file.
+*/
+    #ifdef _WIN64
+    "I64X"
+    #else
+    "X"
+    #endif
+    ") error\n", (uintptr_t) ptr);
+#else
+    "lX) error\n", (unsigned long) ptr);
+#endif
     xmlMallocBreakpoint();
     return;
 }
--- libxml2-2.9.5/xpath.c.orig	2017-08-28 14:18:51.000000000 -0400
+++ libxml2-2.9.5/xpath.c	2017-09-25 23:31:14.321740700 -0400
@@ -159,7 +159,7 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xm
     int misc = 0, precedence1 = 0, precedence2 = 0;
     xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;
     xmlNodePtr cur, root;
-    long l1, l2;
+    intptr_t l1, l2;
 
     if ((node1 == NULL) || (node2 == NULL))
 	return(-2);
@@ -173,12 +173,12 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xm
     switch (node1->type) {
 	case XML_ELEMENT_NODE:
 	    if (node2->type == XML_ELEMENT_NODE) {
-		if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */
-		    (0 > (long) node2->content) &&
+		if ((0 > (intptr_t) node1->content) && /* TODO: Would a != 0 suffice here? */
+		    (0 > (intptr_t) node2->content) &&
 		    (node1->doc == node2->doc))
 		{
-		    l1 = -((long) node1->content);
-		    l2 = -((long) node2->content);
+		    l1 = -((intptr_t) node1->content);
+		    l2 = -((intptr_t) node2->content);
 		    if (l1 < l2)
 			return(1);
 		    if (l1 > l2)
@@ -223,7 +223,7 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xm
 		node1 = node1->parent;
 	    }
 	    if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE) ||
-		(0 <= (long) node1->content)) {
+		(0 <= (intptr_t) node1->content)) {
 		/*
 		* Fallback for whatever case.
 		*/
@@ -273,7 +273,7 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xm
 		node2 = node2->parent;
 	    }
 	    if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) ||
-		(0 <= (long) node2->content))
+		(0 <= (intptr_t) node2->content))
 	    {
 		node2 = miscNode2;
 		precedence2 = 0;
@@ -346,12 +346,12 @@ xmlXPathCmpNodesExt(xmlNodePtr node1, xm
      */
     if ((node1->type == XML_ELEMENT_NODE) &&
 	(node2->type == XML_ELEMENT_NODE) &&
-	(0 > (long) node1->content) &&
-	(0 > (long) node2->content) &&
+	(0 > (intptr_t) node1->content) &&
+	(0 > (intptr_t) node2->content) &&
 	(node1->doc == node2->doc)) {
 
-	l1 = -((long) node1->content);
-	l2 = -((long) node2->content);
+	l1 = -((intptr_t) node1->content);
+	l2 = -((intptr_t) node2->content);
 	if (l1 < l2)
 	    return(1);
 	if (l1 > l2)
@@ -414,12 +414,12 @@ turtle_comparison:
      */
     if ((node1->type == XML_ELEMENT_NODE) &&
 	(node2->type == XML_ELEMENT_NODE) &&
-	(0 > (long) node1->content) &&
-	(0 > (long) node2->content) &&
+	(0 > (intptr_t) node1->content) &&
+	(0 > (intptr_t) node2->content) &&
 	(node1->doc == node2->doc)) {
 
-	l1 = -((long) node1->content);
-	l2 = -((long) node2->content);
+	l1 = -((intptr_t) node1->content);
+	l2 = -((intptr_t) node2->content);
 	if (l1 < l2)
 	    return(1);
 	if (l1 > l2)
@@ -3232,7 +3232,7 @@ xmlXPathFormatNumber(double number, char
  */
 long
 xmlXPathOrderDocElems(xmlDocPtr doc) {
-    long count = 0;
+    intptr_t count = 0;
     xmlNodePtr cur;
 
     if (doc == NULL)
@@ -3332,13 +3332,13 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNo
      */
     if ((node1->type == XML_ELEMENT_NODE) &&
 	(node2->type == XML_ELEMENT_NODE) &&
-	(0 > (long) node1->content) &&
-	(0 > (long) node2->content) &&
+	(0 > (intptr_t) node1->content) &&
+	(0 > (intptr_t) node2->content) &&
 	(node1->doc == node2->doc)) {
-	long l1, l2;
+	intptr_t l1, l2;
 
-	l1 = -((long) node1->content);
-	l2 = -((long) node2->content);
+	l1 = -((intptr_t) node1->content);
+	l2 = -((intptr_t) node2->content);
 	if (l1 < l2)
 	    return(1);
 	if (l1 > l2)
@@ -3395,13 +3395,13 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNo
      */
     if ((node1->type == XML_ELEMENT_NODE) &&
 	(node2->type == XML_ELEMENT_NODE) &&
-	(0 > (long) node1->content) &&
-	(0 > (long) node2->content) &&
+	(0 > (intptr_t) node1->content) &&
+	(0 > (intptr_t) node2->content) &&
 	(node1->doc == node2->doc)) {
-	long l1, l2;
+	intptr_t l1, l2;
 
-	l1 = -((long) node1->content);
-	l2 = -((long) node2->content);
+	l1 = -((intptr_t) node1->content);
+	l2 = -((intptr_t) node2->content);
 	if (l1 < l2)
 	    return(1);
 	if (l1 > l2)
--- libxml2-2.9.5/xmlIO.c.orig	2017-09-26 00:11:34.277899500 -0400
+++ libxml2-2.9.5/xmlIO.c	2017-09-26 00:15:07.930010200 -0400
@@ -833,7 +833,7 @@ static int
 xmlFdRead (void * context, char * buffer, int len) {
     int ret;
 
-    ret = read((int) (long) context, &buffer[0], len);
+    ret = read((intptr_t) context, &buffer[0], len);
     if (ret < 0) xmlIOErr(0, "read()");
     return(ret);
 }
@@ -854,7 +854,7 @@ xmlFdWrite (void * context, const char *
     int ret = 0;
 
     if (len > 0) {
-	ret = write((int) (long) context, &buffer[0], len);
+	ret = write((intptr_t) context, &buffer[0], len);
 	if (ret < 0) xmlIOErr(0, "write()");
     }
     return(ret);
@@ -872,7 +872,7 @@ xmlFdWrite (void * context, const char *
 static int
 xmlFdClose (void * context) {
     int ret;
-    ret = close((int) (long) context);
+    ret = close((intptr_t) context);
     if (ret < 0) xmlIOErr(0, "close()");
     return(ret);
 }
@@ -3015,7 +3015,7 @@ xmlParserInputBufferCreateFd(int fd, xml
 
     ret = xmlAllocParserInputBuffer(enc);
     if (ret != NULL) {
-        ret->context = (void *) (long) fd;
+        ret->context = (void *) (intptr_t) fd;
 	ret->readcallback = xmlFdRead;
 	ret->closecallback = xmlFdClose;
     }
@@ -3121,7 +3121,7 @@ xmlOutputBufferCreateFd(int fd, xmlCharE
 
     ret = xmlAllocOutputBufferInternal(encoder);
     if (ret != NULL) {
-        ret->context = (void *) (long) fd;
+        ret->context = (void *) (intptr_t) fd;
 	ret->writecallback = xmlFdWrite;
 	ret->closecallback = NULL;
     }
--- libxml2-2.9.5/timsort.h.orig	2017-09-26 00:19:41.192760300 -0400
+++ libxml2-2.9.5/timsort.h	2017-09-26 00:26:28.440138000 -0400
@@ -402,7 +402,7 @@ static int TIM_SORT_COLLAPSE(SORT_TYPE *
     }
 
     /* if this is the last merge, just do it */
-    if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) {
+    if ((stack_curr == 2) && ((size_t)(stack[0].length + stack[1].length) == size)) {
       TIM_SORT_MERGE(dst, stack, stack_curr, store);
       stack[0].length += stack[1].length;
       stack_curr--;
--- libxml2-2.9.5/SAX2.c.orig	2017-09-28 02:21:05.501180300 -0400
+++ libxml2-2.9.5/SAX2.c	2017-09-28 02:22:58.066705500 -0400
@@ -1908,7 +1908,7 @@ skip:
 	    else {
 	        ret->line = 65535;
 		if (ctxt->options & XML_PARSE_BIG_LINES)
-		    ret->psvi = (void *) (long) ctxt->input->line;
+		    ret->psvi = (void *) (intptr_t) ctxt->input->line;
 	    }
 	}
     }
