From 426b800cea0175173cab2767c3a8a73c7de03172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 20 Jul 2026 23:21:44 -0300 Subject: [PATCH 1/5] Rewrite DOCTYPE to depend on only one file load. --- configure.php | 84 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/configure.php b/configure.php index 1a07591639..efcb919415 100755 --- a/configure.php +++ b/configure.php @@ -290,7 +290,6 @@ function find_xml_files($path) // {{{ 'OUTPUT_FILENAME' => $srcdir . '/.manual.xml', 'GENERATE' => 'no', 'STDERR_TO_STDOUT' => 'no', - 'INPUT_FILENAME' => 'manual.xml', 'TRANSLATION_ONLY_INCL_BEGIN' => '', 'TRANSLATION_ONLY_INCL_END' => '', 'XPOINTER_REPORTING' => 'yes', @@ -530,6 +529,8 @@ function git_clean() function git_status() { global $ac; + if ( $ac['quiet'] == 'yes' ) + return; $repos = array(); $repos['doc-base'] = $ac['basedir']; @@ -559,32 +560,67 @@ function git_status() function dtd_conf_entities() { + function dtd_pe_body( string $filename = '' ) + { + if ( $filename == '' ) + return "''"; + $filename = realpain( $filename ); + return "SYSTEM '$filename'"; + } + global $ac; $lang = $ac["LANG"]; - $conf = []; - $conf[] = ""; + // When all is converted to XML Entities, + // all this can be reduced to: + // $ent1 = dtd_pe_body( __DIR__ . '/temp/text-entities.ent' ); + // $ent2 = dtd_pe_body( __DIR__ . '/temp/file-entities.ent' ); - if ( $lang != 'en' ) - { - $trans1 = realpain( __DIR__ . "/../$lang/language-defs.ent" ); - $trans2 = realpain( __DIR__ . "/../$lang/language-snippets.ent" ); - $trans3 = realpain( __DIR__ . "/../$lang/extensions.ent" ); + $baseEnt1 = dtd_pe_body( __DIR__ . '/temp/entities.ent' ); + $baseEnt2 = dtd_pe_body( __DIR__ . '/entities/global.ent' ); + $baseEnt3 = dtd_pe_body( __DIR__ . '/temp/file-entities.ent' ); - $conf[] = ""; - $conf[] = ""; - $conf[] = ""; - } + $langOne1 = dtd_pe_body( __DIR__ . '/../en/language-defs.ent' ); + $langOne2 = dtd_pe_body( __DIR__ . '/../en/language-snippets.ent' ); + $langOne3 = dtd_pe_body( __DIR__ . "/../en/extensions.ent" ); - if ( $ac['CHMENABLED'] == 'yes' ) + if ( $lang == 'en ' ) + { + $langTwo1 = dtd_pe_body(); + $langTwo2 = dtd_pe_body(); + $langTwo3 = dtd_pe_body(); + } + else { - $chmpath = realpain( __DIR__ . "/chm/manual.chm.xml" ); - $conf[] = ""; + $langTwo1 = dtd_pe_body( __DIR__ . '/../$lang/language-defs.ent' ); + $langTwo2 = dtd_pe_body( __DIR__ . '/../$lang/language-snippets.ent' ); + $langTwo3 = dtd_pe_body( __DIR__ . '/../$lang/extensions.ent' ); } + + if ( $ac['CHMENABLED'] == 'yes' ) + $chmpath = dtd_pe_body( __DIR__ . "/chm/manual.chm.xml" ); else - $conf[] = ""; + $chmpath = dtd_pe_body(); + + $conf = []; + $conf[] = ""; + $conf[] = ""; + + $conf[] = ""; + $conf[] = ""; + $conf[] = ""; - file_put_contents( __DIR__ . "/temp/manual.inc" , implode( "\n" , $conf ) ); + $conf[] = ""; + $conf[] = ""; + $conf[] = ""; + + $conf[] = ""; + $conf[] = ""; + $conf[] = ""; + + + + file_put_contents( __DIR__ . "/../conf.ent" , implode( "\n" , $conf ) ); } function dtd_file_entities() @@ -652,11 +688,16 @@ function dtd_text_entities() } checkvalue($ac["GENERATE"]); -function dom_load( DOMDocument $dom , string $filename , string $baseURI = "" ) : bool +function dom_load( DOMDocument $dom , string $filename , bool $firstLoad ) : bool { $filename = realpath( $filename ); $options = LIBXML_NOENT | LIBXML_COMPACT | LIBXML_BIGLINES | LIBXML_PARSEHUGE; - return $dom->load( $filename , $options ); + $ret = $dom->load( $filename , $options ); + + if ( $ret && $firstLoad ) + dom_saveload( $dom ); // correct file/line/column on error messages + + return $ret; } function dom_saveload( DOMDocument $dom , string $filename = "" ) : string @@ -666,7 +707,7 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string libxml_clear_errors(); $dom->save( $filename ); - dom_load( $dom , $filename ); + dom_load( $dom , $filename , false ); return $filename; } @@ -674,9 +715,8 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string echo "Creating monolithic temp/manual.xml... "; $dom = new DOMDocument(); -if ( dom_load( $dom , "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}" ) ) +if ( dom_load( $dom , __DIR__ . '/../en/manual.xml' , true ) ) { - dom_saveload( $dom ); // correct file/line/column on error messages echo " done.\n"; } else From e1b3e115799ac50eb15767c0ad1eba5f07513ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 20 Jul 2026 23:50:42 -0300 Subject: [PATCH 2/5] Expose errors at XML assemble. --- configure.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/configure.php b/configure.php index efcb919415..5a07e760d4 100755 --- a/configure.php +++ b/configure.php @@ -576,13 +576,13 @@ function dtd_pe_body( string $filename = '' ) // $ent1 = dtd_pe_body( __DIR__ . '/temp/text-entities.ent' ); // $ent2 = dtd_pe_body( __DIR__ . '/temp/file-entities.ent' ); - $baseEnt1 = dtd_pe_body( __DIR__ . '/temp/entities.ent' ); - $baseEnt2 = dtd_pe_body( __DIR__ . '/entities/global.ent' ); - $baseEnt3 = dtd_pe_body( __DIR__ . '/temp/file-entities.ent' ); + $baseEnt1 = dtd_pe_body( __DIR__ . '/entities/global.ent' ); + $baseEnt2 = dtd_pe_body( __DIR__ . '/temp/file-entities.ent' ); + $baseEnt3 = dtd_pe_body( __DIR__ . '/temp/entities.ent' ); $langOne1 = dtd_pe_body( __DIR__ . '/../en/language-defs.ent' ); $langOne2 = dtd_pe_body( __DIR__ . '/../en/language-snippets.ent' ); - $langOne3 = dtd_pe_body( __DIR__ . "/../en/extensions.ent" ); + $langOne3 = dtd_pe_body( __DIR__ . '/../en/extensions.ent' ); if ( $lang == 'en ' ) { @@ -592,9 +592,9 @@ function dtd_pe_body( string $filename = '' ) } else { - $langTwo1 = dtd_pe_body( __DIR__ . '/../$lang/language-defs.ent' ); - $langTwo2 = dtd_pe_body( __DIR__ . '/../$lang/language-snippets.ent' ); - $langTwo3 = dtd_pe_body( __DIR__ . '/../$lang/extensions.ent' ); + $langTwo1 = dtd_pe_body( __DIR__ . "/../$lang/language-defs.ent" ); + $langTwo2 = dtd_pe_body( __DIR__ . "/../$lang/language-snippets.ent" ); + $langTwo3 = dtd_pe_body( __DIR__ . "/../$lang/extensions.ent" ); } if ( $ac['CHMENABLED'] == 'yes' ) @@ -606,9 +606,9 @@ function dtd_pe_body( string $filename = '' ) $conf[] = ""; $conf[] = ""; - $conf[] = ""; - $conf[] = ""; - $conf[] = ""; + $conf[] = ""; + $conf[] = ""; + $conf[] = ""; $conf[] = ""; $conf[] = ""; @@ -618,8 +618,6 @@ function dtd_pe_body( string $filename = '' ) $conf[] = ""; $conf[] = ""; - - file_put_contents( __DIR__ . "/../conf.ent" , implode( "\n" , $conf ) ); } @@ -695,7 +693,10 @@ function dom_load( DOMDocument $dom , string $filename , bool $firstLoad ) : boo $ret = $dom->load( $filename , $options ); if ( $ret && $firstLoad ) + { + print_xml_errors(); dom_saveload( $dom ); // correct file/line/column on error messages + } return $ret; } From 36e945e1636d69d2c0edee72beb34266889566c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Tue, 21 Jul 2026 00:30:16 -0300 Subject: [PATCH 3/5] Omit non-fixable warnings on first load. --- configure.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/configure.php b/configure.php index 5a07e760d4..f9b434a0b2 100755 --- a/configure.php +++ b/configure.php @@ -190,6 +190,22 @@ function find_file($file_array) // {{{ return ''; } // }}} +function print_dom_errors() +{ + $errors = libxml_get_errors(); + foreach( $errors as $error ) + { + $file = $error->file; + $line = $error->line; + $clmn = $error->column; + $prefix = $error->level === LIBXML_ERR_FATAL ? "FATAL" : "error"; + $message = rtrim( $error->message ); + + if ( $file != '' ) + print "[$prefix $file {$line}:{$clmn}] {$message}\n"; + } +} + function print_xml_errors() { global $ac; @@ -690,15 +706,7 @@ function dom_load( DOMDocument $dom , string $filename , bool $firstLoad ) : boo { $filename = realpath( $filename ); $options = LIBXML_NOENT | LIBXML_COMPACT | LIBXML_BIGLINES | LIBXML_PARSEHUGE; - $ret = $dom->load( $filename , $options ); - - if ( $ret && $firstLoad ) - { - print_xml_errors(); - dom_saveload( $dom ); // correct file/line/column on error messages - } - - return $ret; + return $dom->load( $filename , $options ); } function dom_saveload( DOMDocument $dom , string $filename = "" ) : string @@ -719,6 +727,8 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string if ( dom_load( $dom , __DIR__ . '/../en/manual.xml' , true ) ) { echo " done.\n"; + print_dom_errors(); + dom_saveload( $dom ); // correct file/line/column on error messages } else { From 5d298466eee2d1b3497e5be60c823c01e704cbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Tue, 21 Jul 2026 12:35:56 -0300 Subject: [PATCH 4/5] Prepare for file deletions. --- configure.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/configure.php b/configure.php index f9b434a0b2..6945e1464a 100755 --- a/configure.php +++ b/configure.php @@ -570,18 +570,20 @@ function git_status() // DTD entity layer before first XML loading -dtd_conf_entities(); dtd_file_entities(); dtd_text_entities(); +dtd_conf_entities(); function dtd_conf_entities() { function dtd_pe_body( string $filename = '' ) { - if ( $filename == '' ) - return "''"; - $filename = realpain( $filename ); - return "SYSTEM '$filename'"; + if ( file_exists( $filename ) ) + { + $filename = realpain( $filename ); + return "SYSTEM '$filename'"; + } + return "''"; } global $ac; From 45f12b1572734a7f8db3b2803e726d17d75bd1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Tue, 21 Jul 2026 20:06:02 -0300 Subject: [PATCH 5/5] Move DOCTYPE configuration into doc-en/temp/. --- configure.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.php b/configure.php index 6945e1464a..4bf447c3bd 100755 --- a/configure.php +++ b/configure.php @@ -636,7 +636,9 @@ function dtd_pe_body( string $filename = '' ) $conf[] = ""; $conf[] = ""; - file_put_contents( __DIR__ . "/../conf.ent" , implode( "\n" , $conf ) ); + $outdir = __DIR__ . '/../en/temp'; + realpain( $outdir , mkdir: true ); + file_put_contents( "{$outdir}/conf.dtd" , implode( "\n" , $conf ) ); } function dtd_file_entities()