[Reproducible-commits] [libxslt] 01/02: Make generate-id() return identifiers in a deterministic way

Jérémy Bobbio lunar at moszumanska.debian.org
Mon Jan 5 11:06:14 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository libxslt.

commit 09fa8d917111e259848395fa528238aed1a97978
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Mon Jan 5 11:26:01 2015 +0100

    Make generate-id() return identifiers in a deterministic way
---
 .../0009-Make-generate-id-deterministic.patch      | 65 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 66 insertions(+)

diff --git a/debian/patches/0009-Make-generate-id-deterministic.patch b/debian/patches/0009-Make-generate-id-deterministic.patch
new file mode 100644
index 0000000..08722a9
--- /dev/null
+++ b/debian/patches/0009-Make-generate-id-deterministic.patch
@@ -0,0 +1,65 @@
+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 at debian.org>
+
+--- libxslt-1.1.28.orig/libxslt/functions.c
++++ libxslt-1.1.28/libxslt/functions.c
+@@ -660,12 +660,11 @@ 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];
+-    xmlDocPtr doc;
+ 
+     if (nargs == 0) {
+ 	cur = ctxt->context->node;
+@@ -698,31 +697,20 @@ xsltGenerateIdFunction(xmlXPathParserCon
+ 	ctxt->error = XPATH_INVALID_ARITY;
+ 	return;
+     }
+-    /*
+-     * Okay this is ugly but should work, use the NodePtr address
+-     * to forge the ID
+-     */
+-    if (cur->type != XML_NAMESPACE_DECL)
+-        doc = cur->doc;
+-    else {
+-        xmlNsPtr ns = (xmlNsPtr) cur;
+-
+-        if (ns->context != NULL)
+-            doc = ns->context;
+-        else
+-            doc = ctxt->context->doc;
+-
+-    }
+ 
+     if (obj)
+         xmlXPathFreeObject(obj);
+ 
+-    val = (long)((char *)cur - (char *)&base_address);
+-    if (val >= 0) {
+-      sprintf((char *)str, "idp%ld", val);
+-    } else {
+-      sprintf((char *)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));
+ }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index c1f70be..c098fb0 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@
 0006-Initialize-pseudo-random-number-generator-with-curre.patch
 0007-EXSLT-function-str-replace-is-broken-as-is.patch
 0008-Fix-quoting-of-xlocale-test-program-in-configure.in.patch
+0009-Make-generate-id-deterministic.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/libxslt.git



More information about the Reproducible-commits mailing list