From fc7b822ffe63685f0378a8f2f0e3149b04374547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Fri, 11 Apr 2025 18:37:09 -0300 Subject: [PATCH 1/5] Post check individual XML files for know issues --- configure.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/configure.php b/configure.php index f74c1708b..0e305b97e 100755 --- a/configure.php +++ b/configure.php @@ -720,9 +720,28 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string { echo "failed.\n"; print_xml_errors(); + individual_xml_broken_check(); errors_are_bad(1); } +function individual_xml_broken_check() +{ + $cmd = array(); + $cmd[] = $GLOBALS['ac']['PHP']; + $cmd[] = __DIR__ . "/scripts/broken.php"; + $cmd[] = $GLOBALS['ac']['LANG']; + foreach ( $cmd as & $part ) + $part = escapeshellarg( $part ); + $ret = 0; + $cmd = implode( ' ' , $cmd ); + passthru( $cmd , $ret ); + if ( $ret != 0 ) + { + echo "doc-base/scripts/broken.php FAILED.\n"; + exit( 1 ); + } +} + echo "Running XInclude/XPointer... "; $total = xinclude_run_byid( $dom ); @@ -1171,8 +1190,5 @@ function phd_version() CAT; -if (function_exists('proc_nice') && !is_windows()) { - echo " (Run `nice php $_SERVER[SCRIPT_NAME]` next time!)\n"; -} - -exit(0); // Tell the shell that this script finished successfully. +individual_xml_broken_check(); +exit(0); // Finished successfully. From 051611a1d8adcf378e07d59ef0c6bf4f210d6a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 14 Apr 2025 11:54:47 -0300 Subject: [PATCH 2/5] Autofix option for simple encoding issues --- scripts/broken.php | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/scripts/broken.php b/scripts/broken.php index d52c86608..6ece7dd7c 100644 --- a/scripts/broken.php +++ b/scripts/broken.php @@ -28,8 +28,19 @@ if ( count( $argv ) < 2 ) print_usage_exit( $argv[0] ); - array_shift( $argv ); + +$dos2unix = false; +foreach( $argv as & $arg ) +{ + if ( $arg == "--dos2unix" ) + { + $dos2unix = true; + $arg = null; + } +} +$argv = array_filter( $argv ); + foreach( $argv as $arg ) { if ( file_exists( $arg ) ) @@ -46,7 +57,7 @@ function print_usage_exit( $cmd ) { fwrite( STDERR , " Wrong paramater count. Usage:\n" ); - fwrite( STDERR , " {$cmd} path:\n" ); + fwrite( STDERR , " {$cmd} [--dos2unix] path\n" ); exit; } @@ -83,17 +94,21 @@ function testFile( string $filename , bool $fragment = false ) if ( str_starts_with( $contents , b"\xEF\xBB\xBF" ) ) { echo "Wrong XML file:\n"; + echo " Issue: XML file with BOM. Several tools may misbehave.\n"; echo " Path: $filename\n"; - echo " Error: XML file with BOM. Several tools may misbehave.\n"; + echo " Hint: You can try autofix this with --dos2unix option.\n"; echo "\n"; + autofix_dos2unix( $filename ); } if ( PHP_EOL == "\n" && str_contains( $contents , "\r") ) { echo "Wrong XML file:\n"; + echo " Issue: XML file contains \\r. Several tools may misbehave.\n"; echo " Path: $filename\n"; - echo " Error: XML file contains \\r. Several tools may misbehave.\n"; + echo " Hint: You can try autofix this with --dos2unix option.\n"; echo "\n"; + autofix_dos2unix( $filename ); } static $prefix = "", $suffix = "", $extra = ""; @@ -128,10 +143,10 @@ function testFile( string $filename , bool $fragment = false ) $lin = $error->line; $col = $error->column; echo "Broken XML file:\n"; + echo " Issue: $message\n"; echo " Path: $filename [$lin,$col]\n"; - echo " Error: $message\n"; if ( $hintFragDir ) - echo " Hint: Dir is marked with .xmlfragmentdir on doc-en? If not, check entity references.\n"; + echo " Hint: See source comments about '.xmlfragmentdir', or check entity references outside enclosing tags.\n"; echo "\n"; return; } @@ -169,3 +184,14 @@ function testDir( string $dir ) foreach( $subdirs as $dir ) testDir( $dir ); } + +function autofix_dos2unix( string $filename ) +{ + if ( $GLOBALS['dos2unix'] ) + { + $cmd = "dos2unix -r " . escapeshellarg( $filename ); + echo $cmd; + system( $cmd ); + echo "\n"; + } +} From a1ff2371d20659c6859540a6a0e6cacd552a379f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 14 Apr 2025 16:34:12 -0300 Subject: [PATCH 3/5] Remove debug output --- scripts/broken.php | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/broken.php b/scripts/broken.php index 6ece7dd7c..a7e3c26db 100644 --- a/scripts/broken.php +++ b/scripts/broken.php @@ -190,7 +190,6 @@ function autofix_dos2unix( string $filename ) if ( $GLOBALS['dos2unix'] ) { $cmd = "dos2unix -r " . escapeshellarg( $filename ); - echo $cmd; system( $cmd ); echo "\n"; } From b1f0518f022b87c6f48ea8a4c764baaa5c2ceb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Wed, 16 Apr 2025 13:13:35 -0300 Subject: [PATCH 4/5] Hint the complete script path --- scripts/broken.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/broken.php b/scripts/broken.php index a7e3c26db..ad41cb617 100644 --- a/scripts/broken.php +++ b/scripts/broken.php @@ -96,7 +96,7 @@ function testFile( string $filename , bool $fragment = false ) echo "Wrong XML file:\n"; echo " Issue: XML file with BOM. Several tools may misbehave.\n"; echo " Path: $filename\n"; - echo " Hint: You can try autofix this with --dos2unix option.\n"; + echo " Hint: You can try autofix this with 'doc-base/scripts/broken.php --dos2unix langdir'.\n"; echo "\n"; autofix_dos2unix( $filename ); } @@ -106,7 +106,7 @@ function testFile( string $filename , bool $fragment = false ) echo "Wrong XML file:\n"; echo " Issue: XML file contains \\r. Several tools may misbehave.\n"; echo " Path: $filename\n"; - echo " Hint: You can try autofix this with --dos2unix option.\n"; + echo " Hint: You can try autofix this with 'doc-base/scripts/broken.php --dos2unix langdir'.\n"; echo "\n"; autofix_dos2unix( $filename ); } From 72c894a7ee902eb8967c820f355854a1c06d5a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Thu, 17 Apr 2025 10:52:48 -0300 Subject: [PATCH 5/5] Hint the effect of failed XInclude --- configure.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.php b/configure.php index 0e305b97e..620ae1c0d 100755 --- a/configure.php +++ b/configure.php @@ -850,8 +850,11 @@ function xinclude_residual_fixup( DOMDocument $dom ) foreach( $nodes as $node ) { if ( $count === 0 ) - echo "\nFailed XInclude, inspect {$debugFile} for context:\n"; - echo " {$node->getAttribute("xpointer")}\n"; + { + echo "\nFailed XIncludes, manual parts will be missing."; + echo " Inspect {$debugFile} for context. Failed targets are:\n"; + } + echo "- {$node->getAttribute("xpointer")}\n"; $count++; $fixup = null;