libxslt/0009-Make-generate-id-deterministic.patch
Ismail Dönmez e31bbdf665 Accepting request 401284 from home:scarabeus_iv:branches:devel:libraries:c_c++
- Version update to 1.1.29 to match libxslt main package
- Sort out with spec-cleaner
- BuildIgnore python to avoid cycles
- Run tests and do not install them as docs

- Update to 1.1.29:
  * new release after 4 years with few bugfies all around
- Refresh patch 0009-Make-generate-id-deterministic.patch to apply
- Remove cve patch that was integrated upstream:
  libxslt-1.1.28-type_confusion_preprocess_attr.patch
- Unpack the manpage as the compression is set by buildbot not always gz

OBS-URL: https://build.opensuse.org/request/show/401284
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libxslt?expand=0&rev=51
2016-06-12 07:01:53 +00:00

47 lines
1.7 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
===================================================================
--- libxslt-1.1.29.orig/libxslt/functions.c
+++ libxslt-1.1.29/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));
}