2727
2828echo "configure.php on PHP " . phpversion () . "\n\n" ;
2929
30+ // init_argv()
31+ // init_checks()
32+ // init_clean()
33+ // xml_configure()
34+ // xml_parse()
35+ // xml_xinclude()
36+ // xml_validate()
37+ // phd_sources()
38+ // phd_version()
39+ // php_history()
40+
3041const RNG_SCHEMA_DIR = __DIR__ . DIRECTORY_SEPARATOR . 'docbook ' . DIRECTORY_SEPARATOR . 'docbook-v5.2-os ' . DIRECTORY_SEPARATOR . 'rng ' . DIRECTORY_SEPARATOR ;
3142const RNG_SCHEMA_FILE = RNG_SCHEMA_DIR . 'docbook.rng ' ;
3243const RNG_SCHEMA_XINCLUDE_FILE = RNG_SCHEMA_DIR . 'docbookxi.rng ' ;
@@ -81,6 +92,29 @@ function usage() // {{{
8192HELPCHUNK ;
8293} // }}}
8394
95+ function realpain ( string $ path , bool $ touch = false , bool $ mkdir = false ) : string
96+ {
97+ // pain is real
98+
99+ // care for external XML tools (realpath() everywhere)
100+ // care for Windows builds (foward slashes everywhere)
101+ // avoid `cd` and chdir() like the plague
102+
103+ $ path = str_replace ( "\\" , '/ ' , $ path );
104+
105+ if ( $ mkdir && ! file_exists ( $ path ) )
106+ mkdir ( $ path , recursive: true );
107+
108+ if ( $ touch && ! file_exists ( $ path ) )
109+ touch ( $ path );
110+
111+ $ res = realpath ( $ path );
112+ if ( is_string ( $ res ) )
113+ $ path = $ res ;
114+
115+ return $ path ;
116+ }
117+
84118function errbox ($ msg ) {
85119 $ len = strlen ($ msg )+4 ;
86120 $ line = "+ " . str_repeat ("- " , $ len ) . "+ " ;
@@ -251,7 +285,7 @@ function generate_sources_file() // {{{
251285 echo 'Iterating over files for sources info... ' ;
252286 $ en_dir = "{$ ac ['rootdir ' ]}/ {$ ac ['EN_DIR ' ]}" ;
253287 $ source_langs = array (
254- array ('base ' , $ ac ['srcdir ' ], array ('manual.xml.in ' , 'funcindex.xml ' )),
288+ array ('base ' , $ ac ['srcdir ' ], array ('manual.xml ' , 'funcindex.xml ' )),
255289 array ('en ' , $ en_dir , find_xml_files ($ en_dir )),
256290 );
257291 if ($ ac ['LANG ' ] !== 'en ' ) {
@@ -630,12 +664,6 @@ function getFileModificationHistory(): array {
630664}
631665
632666
633- // We shouldn't be globbing for this. autoconf requires you to tell it which files to use, we should do the same
634- // Notice how doing it this way results in generating less than half as many files.
635- $ infiles = array (
636- 'manual.xml.in ' ,
637- );
638-
639667// Show local repository status to facilitate debug
640668
641669$ repos = array ();
@@ -659,19 +687,45 @@ function getFileModificationHistory(): array {
659687 $ output = str_replace ( "\n\n" , "\n" , $ output );
660688echo "\n" , trim ( $ output ) . "\n\n" ;
661689
662- foreach ($ infiles as $ in ) {
663- $ in = chop ("{$ ac ['basedir ' ]}/ {$ in }" );
664690
665- $ out = substr ($ in , 0 , -3 );
666- echo "Generating {$ out }... " ;
667- if (generate_output_file ($ in , $ out , $ ac )) {
668- echo "done \n" ;
669- } else {
670- echo "fail \n" ;
671- errors_are_bad (117 );
691+ xml_configure ();
692+ function xml_configure ()
693+ {
694+ global $ ac ;
695+ $ lang = $ ac ["LANG " ];
696+ $ conf = [];
697+
698+ $ conf [] = "<!ENTITY LANG ' $ lang'> " ;
699+
700+ if ( $ lang == 'en ' )
701+ {
702+ realpain ( __DIR__ . "/temp/empty " , touch: true );
703+ $ trans1 = realpain ( __DIR__ . "/temp/empty " );
704+ $ trans2 = realpain ( __DIR__ . "/temp/empty " );
705+ $ trans3 = realpain ( __DIR__ . "/temp/empty " );
706+ }
707+ else
708+ {
709+ $ trans1 = realpain ( __DIR__ . "/../ $ lang/language-defs.ent " );
710+ $ trans2 = realpain ( __DIR__ . "/../ $ lang/language-snippets.ent " );
711+ $ trans3 = realpain ( __DIR__ . "/../ $ lang/extensions.ent " );
672712 }
713+ $ conf [] = "<!ENTITY % translation-defs SYSTEM ' $ trans1'> " ;
714+ $ conf [] = "<!ENTITY % translation-snippets SYSTEM ' $ trans2'> " ;
715+ $ conf [] = "<!ENTITY % translation-extensions SYSTEM ' $ trans3'> " ;
716+
717+ if ( $ ac ['CHMENABLED ' ] == 'yes ' )
718+ {
719+ $ chmpath = realpain ( __DIR__ . "/chm/manual.chm.xml " );
720+ $ conf [] = "<!ENTITY manual.chmonly SYSTEM ' $ chmpath'> " ;
721+ }
722+ else
723+ $ conf [] = "<!ENTITY manual.chmonly ''> " ;
724+
725+ file_put_contents ( __DIR__ . "/temp/manual.conf " , implode ( "\n" , $ conf ) );
673726}
674727
728+
675729if ($ ac ['SEGFAULT_ERROR ' ] === 'yes ' ) {
676730 libxml_use_internal_errors (true );
677731}
0 commit comments