Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / patches / docbook-xsl-nonrecursive-string-subst.patch
1 Use a non-recursive replace function when the parser supports it.
2
3 https://bugs.gnu.org/29782
4 https://bugzilla.samba.org/show_bug.cgi?id=9515
5 https://bugzilla.gnome.org/show_bug.cgi?id=736077 (for xsltproc)
6
7 Patch copied from Debian:
8 https://anonscm.debian.org/cgit/collab-maint/docbook-xsl.git/tree/debian/patches/765567_non-recursive_string_subst.patch
9
10 Description: use EXSLT "replace" function when available
11 A recursive implementation of string.subst is problematic,
12 long strings with many matches will cause stack overflows.
13 Author: Peter De Wachter <pdewacht@gmail.com>
14 Bug-Debian: https://bugs.debian.org/750593
15
16 --- a/lib/lib.xsl
17 +++ b/lib/lib.xsl
18 @@ -10,7 +10,10 @@
19 This module implements DTD-independent functions
20
21 ******************************************************************** -->
22 -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
23 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
24 + xmlns:str="http://exslt.org/strings"
25 + exclude-result-prefixes="str"
26 + version="1.0">
27
28 <xsl:template name="dot.count">
29 <!-- Returns the number of "." characters in a string -->
30 @@ -56,6 +59,9 @@
31 <xsl:param name="replacement"/>
32
33 <xsl:choose>
34 + <xsl:when test="function-available('str:replace')">
35 + <xsl:value-of select="str:replace($string, string($target), string($replacement))"/>
36 + </xsl:when>
37 <xsl:when test="contains($string, $target)">
38 <xsl:variable name="rest">
39 <xsl:call-template name="string.subst">