summaryrefslogtreecommitdiff
path: root/relaxng.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2017-10-09 13:37:42 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2017-10-09 13:47:49 +0200
commitd422b954be178afca1abeded9054ee6e39272904 (patch)
tree77bd0a2732bbdb9fe7939ed4767165b200db1c99 /relaxng.c
parent41c0a13fe7455bbdd3aa785a67ded91058f81333 (diff)
downloadlibxml2-d422b954be178afca1abeded9054ee6e39272904.tar.gz
Fix pointer/int cast warnings on 64-bit Windows
On 64-bit Windows, `long` is 32 bits wide and can't hold a pointer. Switch to ptrdiff_t instead which should be the same size as a pointer on every somewhat sane platform without requiring C99 types like intptr_t. Fixes bug 788312. Thanks to J. Peter Mugaas for the report and initial patch.
Diffstat (limited to 'relaxng.c')
-rw-r--r--relaxng.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/relaxng.c b/relaxng.c
index 3d3e69c0..be731949 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -20,6 +20,7 @@
#include <string.h>
#include <stdio.h>
+#include <stddef.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
@@ -4404,7 +4405,7 @@ xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def,
if ((*tmp)->type == XML_RELAXNG_TEXT) {
res = xmlHashAddEntry2(partitions->triage,
BAD_CAST "#text", NULL,
- (void *) (long) (i + 1));
+ (void *) (ptrdiff_t) (i + 1));
if (res != 0)
is_determinist = -1;
} else if (((*tmp)->type == XML_RELAXNG_ELEMENT) &&
@@ -4412,22 +4413,22 @@ xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def,
if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0))
res = xmlHashAddEntry2(partitions->triage,
(*tmp)->name, NULL,
- (void *) (long) (i + 1));
+ (void *) (ptrdiff_t) (i + 1));
else
res = xmlHashAddEntry2(partitions->triage,
(*tmp)->name, (*tmp)->ns,
- (void *) (long) (i + 1));
+ (void *) (ptrdiff_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 *) (ptrdiff_t) (i + 1));
else
res = xmlHashAddEntry2(partitions->triage,
BAD_CAST "#any", (*tmp)->ns,
- (void *) (long) (i + 1));
+ (void *) (ptrdiff_t) (i + 1));
if ((*tmp)->nameClass != NULL)
is_determinist = 2;
if (res != 0)
@@ -9387,7 +9388,7 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
if (tmp == NULL) {
i = nbgroups;
} else {
- i = ((long) tmp) - 1;
+ i = ((ptrdiff_t) tmp) - 1;
if (partitions->flags & IS_NEEDCHECK) {
group = partitions->groups[i];
if (!xmlRelaxNGNodeMatchesList(cur, group->defs))