Skip to content

Commit c07e753

Browse files
author
André L F S Bacci
committed
Replace all @ placeholders
1 parent 5086c69 commit c07e753

File tree

2 files changed

+86
-33
lines changed

2 files changed

+86
-33
lines changed

configure.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727

2828
echo "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+
3041
const RNG_SCHEMA_DIR = __DIR__ . DIRECTORY_SEPARATOR . 'docbook' . DIRECTORY_SEPARATOR . 'docbook-v5.2-os' . DIRECTORY_SEPARATOR . 'rng' . DIRECTORY_SEPARATOR;
3142
const RNG_SCHEMA_FILE = RNG_SCHEMA_DIR . 'docbook.rng';
3243
const RNG_SCHEMA_XINCLUDE_FILE = RNG_SCHEMA_DIR . 'docbookxi.rng';
@@ -81,6 +92,29 @@ function usage() // {{{
8192
HELPCHUNK;
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+
84118
function errbox($msg) {
85119
$len = strlen($msg)+4;
86120
$line = "+" . str_repeat("-", $len) . "+";
@@ -654,6 +688,36 @@ function getFileModificationHistory(): array {
654688
echo "\n" , trim( $output ) . "\n\n";
655689

656690

691+
xml_configure();
692+
function xml_configure()
693+
{
694+
global $ac;
695+
$lang = $ac["LANG"];
696+
$base = basename( __DIR__ );
697+
$conf = [];
698+
699+
$conf[] = "<!ENTITY LANG '$lang'>";
700+
701+
if ( $lang == 'en' )
702+
{
703+
realpain( __DIR__ . "/temp/empty" , mkdir: true );
704+
realpain( __DIR__ . "/temp/empty/language-defs.ent" , touch: true );
705+
realpain( __DIR__ . "/temp/empty/language-snippets.ent" , touch: true );
706+
realpain( __DIR__ . "/temp/empty/extensions.ent" , touch: true );
707+
$conf[] = "<!ENTITY % LANGDIR '$base/empty'>";
708+
}
709+
else
710+
$conf[] = "<!ENTITY % LANGDIR '$lang'>";
711+
712+
if ( $ac['CHMENABLED'] == 'yes' )
713+
$conf[] = "<!ENTITY manual.chmonly SYSTEM './chm/manual.chm.xml'>";
714+
else
715+
$conf[] = "<!ENTITY manual.chmonly ''>";
716+
717+
file_put_contents( __DIR__ . "/temp/manual.conf" , implode( "\n" , $conf ) );
718+
}
719+
720+
657721
if ($ac['SEGFAULT_ERROR'] === 'yes') {
658722
libxml_use_internal_errors(true);
659723
}

manual.xml

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
<?xml version='1.0' encoding='@ENCODING@' ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<!DOCTYPE PHPDOC [
3-
<!-- Add translated specific definitions and snippets -->
4-
@TRANSLATION_ONLY_INCL_BEGIN@
5-
<!ENTITY % language-defs SYSTEM "../@LANGDIR@/language-defs.ent">
6-
<!ENTITY % language-snippets SYSTEM "../@LANGDIR@/language-snippets.ent">
7-
<!ENTITY % extensions SYSTEM "../@LANGDIR@/extensions.ent">
8-
9-
%language-defs;
10-
%extensions;
11-
%language-snippets;
12-
@TRANSLATION_ONLY_INCL_END@
13-
14-
<!-- Fallback to English definitions and snippets (in case of missing translation) -->
15-
<!ENTITY % language-defs.default SYSTEM "../@EN_DIR@/language-defs.ent">
16-
<!ENTITY % language-snippets.default SYSTEM "../@EN_DIR@/language-snippets.ent">
17-
<!ENTITY % extensions.default SYSTEM "../@EN_DIR@/extensions.ent">
183

4+
<!-- Parameter entities used to configure manual.xml -->
5+
<!ENTITY % configure SYSTEM "./temp/manual.conf">
6+
%configure;
7+
8+
<!-- Translation layer, if any -->
9+
<!ENTITY % translation-defs SYSTEM "../%LANGDIR;/language-defs.ent">
10+
<!ENTITY % translation-snippets SYSTEM "../%LANGDIR;/language-snippets.ent">
11+
<!ENTITY % translation-extensions SYSTEM "../%LANGDIR;/extensions.ent">
12+
%translation-defs;
13+
%translation-snippets;
14+
%translation-extensions;
15+
16+
<!-- English manual (also works as fallback layer for incomplete translations) -->
17+
<!ENTITY % language-defs.default SYSTEM "../en/language-defs.ent">
18+
<!ENTITY % language-snippets.default SYSTEM "../en/language-snippets.ent">
19+
<!ENTITY % extensions.default SYSTEM "../en/extensions.ent">
1920
%language-defs.default;
2021
%extensions.default;
2122
%language-snippets.default;
2223

23-
<!-- All global entities for the XML files -->
24-
<!ENTITY % global.entities SYSTEM "./entities/global.ent">
25-
26-
<!-- These are language independent -->
27-
<!ENTITY % frontpage.entities SYSTEM "../@EN_DIR@/contributors.ent">
24+
<!-- Language independent entities, and language dependent file entities -->
25+
<!ENTITY % global.entities SYSTEM "./entities/global.ent">
26+
<!ENTITY % frontpage.entities SYSTEM "../en/contributors.ent">
2827
<!ENTITY % file.entities SYSTEM "./temp/file-entities.ent">
29-
30-
<!-- Include all external DTD parts defined previously -->
3128
%global.entities;
3229
%file.entities;
3330
%frontpage.entities;
3431
]>
3532

36-
<set xmlns="http://docbook.org/ns/docbook" version="5.2" xml:id="index" xml:lang="@LANG@" xmlns:xlink="http://www.w3.org/1999/xlink">
33+
<set xmlns="http://docbook.org/ns/docbook" version="5.2" xml:id="index" xml:lang="&LANG;" xmlns:xlink="http://www.w3.org/1999/xlink">
3734
<title>&PHPManual;</title>
3835
&bookinfo;
3936

@@ -465,15 +462,7 @@
465462
</appendix>
466463
</book>
467464

468-
@CHMONLY_INCL_BEGIN@
469-
<book xml:id="chmonly">
470-
<title>&CHMEdition;</title>
471-
&chmonly.aboutchm;
472-
&chmonly.usingchm;
473-
&chmonly.search;
474-
&chmonly.integration;
475-
</book>
476-
@CHMONLY_INCL_END@
465+
&manual.chmonly;
477466

478467
</set>
479468

0 commit comments

Comments
 (0)