0e66e14da3
Update to version 1.1.35. OBS-URL: https://build.opensuse.org/request/show/965151 OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libxslt?expand=0&rev=93
47 lines
1.6 KiB
Diff
47 lines
1.6 KiB
Diff
Description: Make generate-id() return identifiers in a deterministic way
|
|
generate-id() used to return identifiers based on the memory address of
|
|
the node object. This unfortunately prevents documentation to be built
|
|
reproducily. Instead, we now increment a static counter and store its
|
|
value in the node _private on the first invocation of generate-id().
|
|
Author: Jérémy Bobbio <lunar@debian.org>
|
|
|
|
Index: libxslt-1.1.29/libxslt/functions.c
|
|
===================================================================
|
|
--- a/libxslt/functions.c
|
|
+++ b/libxslt/functions.c
|
|
@@ -661,10 +661,10 @@ xsltFormatNumberFunction(xmlXPathParserC
|
|
*/
|
|
void
|
|
xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
|
- static char base_address;
|
|
+ static unsigned long next_id = 1;
|
|
xmlNodePtr cur = NULL;
|
|
xmlXPathObjectPtr obj = NULL;
|
|
- long val;
|
|
+ unsigned long val;
|
|
xmlChar str[30];
|
|
|
|
if (nargs == 0) {
|
|
@@ -702,12 +702,16 @@ xsltGenerateIdFunction(xmlXPathParserCon
|
|
if (obj)
|
|
xmlXPathFreeObject(obj);
|
|
|
|
- val = (long)((char *)cur - (char *)&base_address);
|
|
- if (val >= 0) {
|
|
- snprintf((char *)str, sizeof(str), "idp%ld", val);
|
|
- } else {
|
|
- snprintf((char *)str, sizeof(str), "idm%ld", -val);
|
|
+ if (cur->_private == NULL) {
|
|
+ cur->_private = xmlMalloc(sizeof (unsigned long));
|
|
+ if (cur->_private == NULL) {
|
|
+ xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
|
|
+ }
|
|
+ *((unsigned long *)cur->_private) = next_id++;
|
|
}
|
|
+ val = *((unsigned long *)cur->_private);
|
|
+
|
|
+ sprintf((char *)str, "id%lu", val);
|
|
valuePush(ctxt, xmlXPathNewString(str));
|
|
}
|
|
|