From a0480bfd994d657b7d3ffa00c55a1ef036cf6bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 09:49:43 -0300 Subject: [PATCH 1/6] Dont ignore manual.xml anymore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 97fc8e85c..8e5220c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # Files generated by the configure script .manual.xml .revcheck.json -manual.xml version.xml sources.xml # File use to generate entities by configure script From b0a734c6ed32cfb099e69f41d824d74d2f68c2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 09:57:05 -0300 Subject: [PATCH 2/6] Dont copy manual.xml.in anymore --- configure.php | 20 +------------------- manual.xml.in => manual.xml | 0 2 files changed, 1 insertion(+), 19 deletions(-) rename manual.xml.in => manual.xml (100%) diff --git a/configure.php b/configure.php index 078c66e53..6fb7708d0 100755 --- a/configure.php +++ b/configure.php @@ -251,7 +251,7 @@ function generate_sources_file() // {{{ echo 'Iterating over files for sources info... '; $en_dir = "{$ac['rootdir']}/{$ac['EN_DIR']}"; $source_langs = array( - array('base', $ac['srcdir'], array('manual.xml.in', 'funcindex.xml')), + array('base', $ac['srcdir'], array('manual.xml', 'funcindex.xml')), array('en', $en_dir, find_xml_files($en_dir)), ); if ($ac['LANG'] !== 'en') { @@ -630,12 +630,6 @@ function getFileModificationHistory(): array { } -// We shouldn't be globbing for this. autoconf requires you to tell it which files to use, we should do the same -// Notice how doing it this way results in generating less than half as many files. -$infiles = array( - 'manual.xml.in', -); - // Show local repository status to facilitate debug $repos = array(); @@ -659,18 +653,6 @@ function getFileModificationHistory(): array { $output = str_replace( "\n\n" , "\n" , $output ); echo "\n" , trim( $output ) . "\n\n"; -foreach ($infiles as $in) { - $in = chop("{$ac['basedir']}/{$in}"); - - $out = substr($in, 0, -3); - echo "Generating {$out}... "; - if (generate_output_file($in, $out, $ac)) { - echo "done\n"; - } else { - echo "fail\n"; - errors_are_bad(117); - } -} if ($ac['SEGFAULT_ERROR'] === 'yes') { libxml_use_internal_errors(true); diff --git a/manual.xml.in b/manual.xml similarity index 100% rename from manual.xml.in rename to manual.xml From 5086c69abb1b6b18ca91a573c25a24ec9b35aa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 11:49:52 -0300 Subject: [PATCH 3/6] Replace all @ placeholders --- chm/manual.chm.xml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 chm/manual.chm.xml diff --git a/chm/manual.chm.xml b/chm/manual.chm.xml new file mode 100644 index 000000000..ca60d431b --- /dev/null +++ b/chm/manual.chm.xml @@ -0,0 +1,7 @@ + + &CHMEdition; + &chmonly.aboutchm; + &chmonly.usingchm; + &chmonly.search; + &chmonly.integration; + From c07e7532f0dbd78c0a3d1c1c76e807bc1a2e927e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 11:59:31 -0300 Subject: [PATCH 4/6] Replace all @ placeholders --- configure.php | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ manual.xml | 55 ++++++++++++++++++------------------------- 2 files changed, 86 insertions(+), 33 deletions(-) diff --git a/configure.php b/configure.php index 6fb7708d0..ff0cd38c4 100755 --- a/configure.php +++ b/configure.php @@ -27,6 +27,17 @@ echo "configure.php on PHP " . phpversion() . "\n\n"; +// init_argv() +// init_checks() +// init_clean() +// xml_configure() +// xml_parse() +// xml_xinclude() +// xml_validate() +// phd_sources() +// phd_version() +// php_history() + const RNG_SCHEMA_DIR = __DIR__ . DIRECTORY_SEPARATOR . 'docbook' . DIRECTORY_SEPARATOR . 'docbook-v5.2-os' . DIRECTORY_SEPARATOR . 'rng' . DIRECTORY_SEPARATOR; const RNG_SCHEMA_FILE = RNG_SCHEMA_DIR . 'docbook.rng'; const RNG_SCHEMA_XINCLUDE_FILE = RNG_SCHEMA_DIR . 'docbookxi.rng'; @@ -81,6 +92,29 @@ function usage() // {{{ HELPCHUNK; } // }}} +function realpain( string $path , bool $touch = false , bool $mkdir = false ) : string +{ + // pain is real + + // care for external XML tools (realpath() everywhere) + // care for Windows builds (foward slashes everywhere) + // avoid `cd` and chdir() like the plague + + $path = str_replace( "\\" , '/' , $path ); + + if ( $mkdir && ! file_exists( $path ) ) + mkdir( $path , recursive: true ); + + if ( $touch && ! file_exists( $path ) ) + touch( $path ); + + $res = realpath( $path ); + if ( is_string( $res ) ) + $path = $res; + + return $path; +} + function errbox($msg) { $len = strlen($msg)+4; $line = "+" . str_repeat("-", $len) . "+"; @@ -654,6 +688,36 @@ function getFileModificationHistory(): array { echo "\n" , trim( $output ) . "\n\n"; +xml_configure(); +function xml_configure() +{ + global $ac; + $lang = $ac["LANG"]; + $base = basename( __DIR__ ); + $conf = []; + + $conf[] = ""; + + if ( $lang == 'en' ) + { + realpain( __DIR__ . "/temp/empty" , mkdir: true ); + realpain( __DIR__ . "/temp/empty/language-defs.ent" , touch: true ); + realpain( __DIR__ . "/temp/empty/language-snippets.ent" , touch: true ); + realpain( __DIR__ . "/temp/empty/extensions.ent" , touch: true ); + $conf[] = ""; + } + else + $conf[] = ""; + + if ( $ac['CHMENABLED'] == 'yes' ) + $conf[] = ""; + else + $conf[] = ""; + + file_put_contents( __DIR__ . "/temp/manual.conf" , implode( "\n" , $conf ) ); +} + + if ($ac['SEGFAULT_ERROR'] === 'yes') { libxml_use_internal_errors(true); } diff --git a/manual.xml b/manual.xml index 39213558c..6187f5483 100644 --- a/manual.xml +++ b/manual.xml @@ -1,39 +1,36 @@ - + -@TRANSLATION_ONLY_INCL_BEGIN@ - - - - -%language-defs; -%extensions; -%language-snippets; -@TRANSLATION_ONLY_INCL_END@ - - - - - + + +%configure; + + + + + +%translation-defs; +%translation-snippets; +%translation-extensions; + + + + + %language-defs.default; %extensions.default; %language-snippets.default; - - - - - + + + - - %global.entities; %file.entities; %frontpage.entities; ]> - + &PHPManual; &bookinfo; @@ -465,15 +462,7 @@ - @CHMONLY_INCL_BEGIN@ - - &CHMEdition; - &chmonly.aboutchm; - &chmonly.usingchm; - &chmonly.search; - &chmonly.integration; - - @CHMONLY_INCL_END@ + &manual.chmonly; From 074d04a96e26561a222362039ce3807e90574b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 13:09:23 -0300 Subject: [PATCH 5/6] Parameter entitities does not recurse or replaces in literal --- configure.php | 18 ++++++++++++------ manual.xml | 3 --- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/configure.php b/configure.php index ff0cd38c4..991bd730c 100755 --- a/configure.php +++ b/configure.php @@ -700,14 +700,20 @@ function xml_configure() if ( $lang == 'en' ) { - realpain( __DIR__ . "/temp/empty" , mkdir: true ); - realpain( __DIR__ . "/temp/empty/language-defs.ent" , touch: true ); - realpain( __DIR__ . "/temp/empty/language-snippets.ent" , touch: true ); - realpain( __DIR__ . "/temp/empty/extensions.ent" , touch: true ); - $conf[] = ""; + realpain( __DIR__ . "/temp/empty" , touch: true ); + $trans1 = realpain( __DIR__ . "/temp/empty" ); + $trans2 = realpain( __DIR__ . "/temp/empty" ); + $trans3 = realpain( __DIR__ . "/temp/empty" ); } else - $conf[] = ""; + { + $trans1 = realpain( __DIR__ . "/../$lang/language-defs.ent" ); + $trans2 = realpain( __DIR__ . "/../$lang/language-snippets.ent" ); + $trans3 = realpain( __DIR__ . "/../$lang/extensions.ent" ); + } + $conf[] = ""; + $conf[] = ""; + $conf[] = ""; if ( $ac['CHMENABLED'] == 'yes' ) $conf[] = ""; diff --git a/manual.xml b/manual.xml index 6187f5483..0678298e2 100644 --- a/manual.xml +++ b/manual.xml @@ -6,9 +6,6 @@ %configure; - - - %translation-defs; %translation-snippets; %translation-extensions; From 8f5b45b376cba79257ab25eba0ece644aa6ce8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 15:13:38 -0300 Subject: [PATCH 6/6] Enable CHM --- configure.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.php b/configure.php index 991bd730c..af4d9d5b2 100755 --- a/configure.php +++ b/configure.php @@ -693,7 +693,6 @@ function xml_configure() { global $ac; $lang = $ac["LANG"]; - $base = basename( __DIR__ ); $conf = []; $conf[] = ""; @@ -716,7 +715,10 @@ function xml_configure() $conf[] = ""; if ( $ac['CHMENABLED'] == 'yes' ) - $conf[] = ""; + { + $chmpath = realpain( __DIR__ . "/chm/manual.chm.xml" ); + $conf[] = ""; + } else $conf[] = "";