diff --git a/configure.php b/configure.php index 35b34eba4..fa26ad285 100755 --- a/configure.php +++ b/configure.php @@ -775,13 +775,28 @@ function getFileModificationHistory(): array { echo "done.\n"; echo "Running XInclude/XPointer... "; -$status = $dom->xinclude(); -if ($status === -1) { +$total = 0; +$maxrun = 10; //LIBXML_VERSION >= 21100 ? 1 : 10; +for( $run = 0 ; $run < $maxrun ; $run++ ) +{ + if ( $run > 0 ) + echo "$run "; + libxml_clear_errors(); + $status = (int) $dom->xinclude(); + if ( $status <= 0 ) + break; + $total += $status; + if ( $maxrun > 1 && $run + 1 >= $maxrun ) + { + echo "Recursive XInclude is too deep.\n"; + errors_are_bad(-1); + } +} + +if ($total == 0) { echo "failed.\n"; } else { - /* For some dumb reason when no substitution are made it returns false instead of 0... */ - $status = (int) $status; - echo "done. Performed $status XIncludes\n"; + echo "done. Performed $total XIncludes.\n"; } flush(); @@ -799,6 +814,38 @@ function getFileModificationHistory(): array { } } +{ # Automatic xi:include / xi:fallback fixups + + $xpath = new DOMXPath( $dom ); + $nodes = $xpath->query( "//*[local-name()='include']" ); + foreach( $nodes as $node ) + { + $fixup = null; + $parent = $node->parentNode; + $tagName = $parent->nodeName; + switch( $tagName ) + { + case "refentry": + $fixup = ""; + break; + case "refsect1": + $fixup = "