+Wed Dec 1 22:37:55 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+ * libxslt/extensions.c, libxslt/functions.c, libxslt/numbers.c,
+ libxslt/pattern.c, libxslt/transform.c, libxslt/xslt.c,
+ libxslt/xsltInternals.h: minor changes to get rid of gcc
+ warnings, especially on 64-bit system. Implemented
+ XML_CAST_FPTR macro to cast between function pointer <->
+ object pointer while avoiding gcc warnings (a hack).
+ No change to the logic.
+
Wed Dec 1 10:47:15 CET 2004 Daniel Veillard <daniel@veillard.com>
* libxslt/security.c xsltproc/xsltproc.c: applied patch from
ctxt->extFunctions = xmlHashCreate(10);
if (ctxt->extFunctions == NULL)
return(-1);
- return(xmlHashAddEntry2(ctxt->extFunctions, name, URI, (void *) function));
+ return(xmlHashAddEntry2(ctxt->extFunctions, name, URI, XML_CAST_FPTR(function)));
}
/**
ctxt->extElements = xmlHashCreate(10);
if (ctxt->extElements == NULL)
return(-1);
- return(xmlHashAddEntry2(ctxt->extElements, name, URI, (void *) function));
+ return(xmlHashAddEntry2(ctxt->extElements, name, URI, XML_CAST_FPTR(function)));
}
/**
return(-1);
xmlHashUpdateEntry2(xsltFunctionsHash, name, URI,
- (void *) function, NULL);
+ XML_CAST_FPTR(function), NULL);
return(0);
}
*/
xmlXPathFunction
xsltExtModuleFunctionLookup (const xmlChar *name, const xmlChar *URI) {
+ xmlXPathFunction ret;
if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
return(NULL);
- return (xmlXPathFunction) xmlHashLookup2(xsltFunctionsHash, name, URI);
+ XML_CAST_FPTR(ret) = xmlHashLookup2(xsltFunctionsHash, name, URI);
+ return ret;
}
/**
return(NULL);
if ((ctxt != NULL) && (ctxt->extElements != NULL)) {
- ret = (xsltTransformFunction)
- xmlHashLookup2(ctxt->extElements, name, URI);
+ XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->extElements, name, URI);
if (ret != NULL)
return(ret);
}
return(-1);
xmlHashUpdateEntry2(xsltTopLevelsHash, name, URI,
- (void *) function, NULL);
+ XML_CAST_FPTR(function), NULL);
return(0);
}
*/
xsltTopLevelFunction
xsltExtModuleTopLevelLookup (const xmlChar *name, const xmlChar *URI) {
+ xsltTopLevelFunction ret;
if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
return(NULL);
- return((xsltTopLevelFunction)
- xmlHashLookup2(xsltTopLevelsHash, name, URI));
+ XML_CAST_FPTR(ret) = xmlHashLookup2(xsltTopLevelsHash, name, URI);
+ return(ret);
}
/**
#endif
/* give priority to context-level functions */
+ /*
ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
+ */
+ XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
if (ret == NULL)
ret = xsltExtModuleFunctionLookup(name, ns_uri);
}
else {
/* Skip over pattern separator (accounting for UTF8) */
- the_format = xmlUTF8Strpos(format, j + 1);
+ the_format = (xmlChar *)xmlUTF8Strpos(format, j + 1);
/*
* Flag changes interpretation of percent/permille
* in -ve pattern
int nocache = 0;
prevdoc = (xmlDocPtr)
- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra);
- ix = (int)
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra);
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+ ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
list = (xmlXPathObjectPtr)
XSLT_RUNTIME_EXTRA_LST(ctxt, sel->lenExtra);
XSLT_RUNTIME_EXTRA_LST(ctxt, sel->lenExtra) =
(void *) list;
- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra) =
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
(void *) doc;
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra) =
+ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
0;
XSLT_RUNTIME_EXTRA_FREE(ctxt, sel->lenExtra) =
(xmlFreeFunc) xmlXPathFreeObject;
int ix, nocache = 0;
previous = (xmlNodePtr)
- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra);
- ix = (int)
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra);
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+ ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
if ((previous != NULL) &&
(previous->parent == node->parent)) {
/*
* (bugs 153137 and 158840)
*/
if (node->doc != NULL) {
- len = (int)
- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra);
+ len = XSLT_RUNTIME_EXTRA(ctxt,
+ sel->lenExtra, ival);
if (!isRVT) {
XSLT_RUNTIME_EXTRA(ctxt,
- sel->previousExtra) = node;
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra) =
- (void *) pos;
+ sel->previousExtra, ptr) = node;
+ XSLT_RUNTIME_EXTRA(ctxt,
+ sel->indexExtra, ival) = pos;
}
}
ix = pos;
*/
if ((!isRVT) && (node->doc != NULL) &&
(nocache == 0)) {
- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra) =
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
node;
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra) =
- (void *) pos;
- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra) =
- (void *) len;
+ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
+ pos;
+ XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) =
+ len;
}
}
} else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) &&
int ix, nocache = 0;
previous = (xmlNodePtr)
- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra);
- ix = (int)
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra);
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+ ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
if ((previous != NULL) &&
(previous->parent == node->parent)) {
/*
* cache it !
*/
if ((node->doc != NULL) && !isRVT) {
- len = (int)
- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra);
+ len = XSLT_RUNTIME_EXTRA(ctxt,
+ sel->lenExtra, ival);
+ XSLT_RUNTIME_EXTRA(ctxt,
+ sel->previousExtra, ptr) = node;
XSLT_RUNTIME_EXTRA(ctxt,
- sel->previousExtra) = node;
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra) =
- (void *) pos;
+ sel->indexExtra, ival) = pos;
}
} else
pos = 0;
* cache it !
*/
if ((node->doc != NULL) && (nocache == 0) && !isRVT) {
- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra) =
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
node;
- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra) =
- (void *) pos;
- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra) =
- (void *) len;
+ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
+ pos;
+ XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) =
+ len;
}
}
}
for (i = 0;i < cur->extrasMax;i++) {
cur->extras[i].info = NULL;
cur->extras[i].deallocate = NULL;
- cur->extras[i].val = NULL;
+ cur->extras[i].val.ptr = NULL;
}
} else {
cur->extras = NULL;
for (i = 0;i < ctxt->extrasMax;i++) {
ctxt->extras[i].info = NULL;
ctxt->extras[i].deallocate = NULL;
- ctxt->extras[i].val = NULL;
+ ctxt->extras[i].val.ptr = NULL;
}
} else {
for (i = ctxt->extrasNr;i < ctxt->extrasMax;i++) {
ctxt->extras[i].info = NULL;
ctxt->extras[i].deallocate = NULL;
- ctxt->extras[i].val = NULL;
+ ctxt->extras[i].val.ptr = NULL;
}
}
}
struct _xsltRuntimeExtra {
void *info; /* pointer to the extra data */
xmlFreeFunc deallocate; /* pointer to the deallocation routine */
- void *val; /* data not needing deallocation */
+ union { /* dual-purpose field */
+ void *ptr; /* data not needing deallocation */
+ int ival; /* integer value storage */
+ } val;
};
/**
*
* Macro used to define extra information stored in the context
*/
-#define XSLT_RUNTIME_EXTRA(ctxt, nr) (ctxt)->extras[(nr)].val
+#define XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
/**
* xsltTemplate:
#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
/*
+ * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
+ * possible incompatibilities between function pointers and object
+ * pointers. It is defined in libxml/hash.h within recent versions
+ * of libxml2, but is put here for compatibility.
+ */
+#ifndef XML_CAST_FPTR
+/**
+ * XML_CAST_FPTR:
+ * @fptr: pointer to a function
+ *
+ * Macro to do a casting from an object pointer to a
+ * function pointer without encountering a warning from
+ * gcc
+ */
+#define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
+#endif
+/*
* Functions associated to the internal types
xsltDecimalFormatPtr xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
xmlChar *name);