From 2af12ee4acfbb45c396c4946638d04e318fb0e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Fri, 13 Dec 2024 14:49:36 -0300 Subject: [PATCH 1/6] Windows related fixes --- languages.php | 1 + scripts/file-entities.php | 101 ++++++++++++-------------------------- 2 files changed, 33 insertions(+), 69 deletions(-) diff --git a/languages.php b/languages.php index a387858a9..680261482 100644 --- a/languages.php +++ b/languages.php @@ -101,6 +101,7 @@ function __construct , public string $path = "" ) { $this->path = realpath( __DIR__ . '/..' ) . "/{$code}"; + $this->path = str_replace( "\\" , '/' , $this->path ); } } diff --git a/scripts/file-entities.php b/scripts/file-entities.php index 35bc9aed1..a3527e89b 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -17,11 +17,11 @@ # Description -This script creates various "file entities", that is, antities and files -that define DTD , named and composed of: +This script creates various "file entities", that is, DTD entities that +points to files and file listings, named and composed of: - dir.dir.file : pulls in a dir/dir/file.xml file -- dir.dif.entities.dir : pulls in a entity list for dir/dir/dir/*.xml +- dir.dif.entities.dir : pulls in all files of dir/dir/dir/*.xml In the original file-entities.php.in, the files are created at: @@ -44,7 +44,8 @@ so it would be possible to detect accidental overwriting of structural entities, the "list of entities" moved to/as normal entity text. PS: This will NOT work, with libxml recusing to load .manuxal.xml.in because of an -"Detected an entity reference loop", that does not exist. Sigh. +"Detected an entity reference loop", that does not exist. Sigh. PPS: May +be possible with LIBXML_PARSEHUGE after all. */ @@ -60,7 +61,7 @@ // Usage -$root = realpath( __DIR__ . "/../.." ); +$root = realpain( __DIR__ . "/../.." ); $lang = ""; $chmonly = false; $debug = false; @@ -93,16 +94,15 @@ if ( $lang != "" ) generate_file_entities( $root , $lang ); -pushEntity( "global.function-index", path: realpath( __DIR__ . "/.." ) . "/funcindex.xml" ); +// TODO BACKPORT: Fixed relative path, move this directly into manual.xml.in +pushEntity( "global.function-index", path: realpain( __DIR__ . "/.." ) . "/funcindex.xml" ); if ( ! $chmonly ) foreach( $entities as $ent ) if ( str_starts_with( $ent->name , "chmonly." ) ) $ent->path = ''; -$outfile = __DIR__ . "/../temp/file-entities.ent"; -touch( $outfile ); -$outfile = realpath( $outfile ); +$outfile = realpain( __DIR__ . "/../temp/file-entities.ent" , touch: true ); $file = fopen( $outfile , "w" ); if ( ! $file ) @@ -149,48 +149,12 @@ function pushEntity( string $name , string $text = '' , string $path = '' ) echo "Something went wrong on file-entities.php.\n"; exit(-1); } - - if ( DIRECTORY_SEPARATOR == '/' ) - return; - - // While https://github.com/php/doc-en/pull/4288 is not - // replicated on on all languages, let's sleeping dogs lies - - $marks = ['!','@','#']; - $parts = explode( '.' , $name ); - foreach( $parts as & $part ) - if ( strtolower( $part ) == 'pdo' ) - $part = array_shift( $marks ); - - $mixin = implode( '.' , $parts ); - $l1 = ['pdo','PDO']; - $l2 = ['pdo','PDO']; - $l3 = ['pdo','PDO']; - - if ( str_contains( $mixin , '!' ) ) - { - //echo "\n\n$mixin\n"; - foreach( $l1 as $s1 ) - foreach( $l2 as $s2 ) - foreach( $l3 as $s3 ) - { - $tmp = $mixin; - $tmp = str_replace( '!' , $s1 , $tmp ); - $tmp = str_replace( '@' , $s2 , $tmp ); - $tmp = str_replace( '#' , $s3 , $tmp ); - //echo "$tmp\n"; - - $ent = new Entity( $tmp , $text , $path ); - $entities[ $tmp ] = $ent; - } - //echo "\n"; - } } function generate_file_entities( string $root , string $lang ) { $path = "$root/$lang"; - $test = realpath( $path ); + $test = realpain( $path ); if ( $test === false || is_dir( $path ) == false ) { echo "Language directory not found: $path\n."; @@ -242,7 +206,7 @@ function file_entities_recurse( string $langroot , array $dirs ) function generate_list_entities( string $root , string $lang ) { $path = "$root/$lang"; - $test = realpath( $path ); + $test = realpain( $path ); if ( $test === false || is_dir( $path ) == false ) { echo "Language directory not found: $path\n."; @@ -292,26 +256,6 @@ function list_entities_recurse( string $root , array $dirs ) } ksort( $list ); - // The entity file names collected on - // - // doc-lang/reference/apache/functions - // - // generate an entity named - // - // reference.apache.ENTITIES.functions - // - // that is saved on parent directory, with filename - // - // doc-lang/reference/apache/ENTITIES.functions.xml - // - // new style has the files saved as - // - // doc-base/temp/file-entities.reference.apache.functions.ent - // - // and in a far future, may only outputs: (see doc-base PR 183) - // - // doc-base/temp/file-entities.xml - $copy = $dirs; $last = array_pop( $copy ); $copy[] = "entities"; @@ -322,7 +266,7 @@ function list_entities_recurse( string $root , array $dirs ) if ( $text != "" ) { - // pushEntity( $name , text: $text ); // See TODO item 2 + // pushEntity( $name , text: $text ); // See TODO item 2 // LIBXML_PARSEHUGE if ( BACKPORT ) $path = "$dir/../entities.$last.xml"; @@ -330,7 +274,7 @@ function list_entities_recurse( string $root , array $dirs ) $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent"; file_put_contents( $path , $text ); - $path = realpath( $path ); + $path = realpain( $path ); pushEntity( $name , path: $path ); } @@ -365,3 +309,22 @@ function writeEntity( $file , Entity $ent ) fwrite( $file , $line ); } + +function realpain( string $path , bool $touch = 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 ( $touch && ! file_exists( $path ) ) + touch( $path ); + + $res = realpath( $path ); + if ( is_string( $res ) ) + $path = $res; + + return $path; +} \ No newline at end of file From fcca30f0318380463a4c00fe6f2c81a589d63d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Fri, 13 Dec 2024 16:05:30 -0300 Subject: [PATCH 2/6] Show ahead/behind from current branch only --- configure.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.php b/configure.php index 3519a63a0..f1058081f 100755 --- a/configure.php +++ b/configure.php @@ -649,11 +649,11 @@ function getFileModificationHistory(): array { { $path = escapeshellarg( $path ); $branch = trim( `git -C $path rev-parse --abbrev-ref HEAD` ); - $branch = $branch == "master" ? "" : " (branch $branch)"; + $suffix = $branch == "master" ? "" : " (branch $branch)"; $output .= str_pad( "$name:" , 10 ); - $output .= rtrim( `git -C $path rev-parse HEAD` ?? "" ) . "$branch\n"; + $output .= rtrim( `git -C $path rev-parse HEAD` ?? "" ) . "$suffix "; + $output .= rtrim( `git -C $path for-each-ref --format="%(push:track)" refs/heads/$branch` ?? "" ) . "\n"; $output .= rtrim( `git -C $path status -s` ?? "" ) . "\n"; - $output .= rtrim( `git -C $path for-each-ref --format="%(push:track)" refs/heads` ?? "" ) . "\n"; } while( str_contains( $output , "\n\n" ) ) $output = str_replace( "\n\n" , "\n" , $output ); From 9b30eafcad291de52ce2447a5d69a4c83c01a075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 16 Dec 2024 08:56:32 -0300 Subject: [PATCH 3/6] Review changes --- scripts/file-entities.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/file-entities.php b/scripts/file-entities.php index a3527e89b..bf0ffba41 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -327,4 +327,5 @@ function realpain( string $path , bool $touch = false ) : string $path = $res; return $path; -} \ No newline at end of file +} + From fc3f6f999224a6e9076ff7d1316396fb8f97e95b Mon Sep 17 00:00:00 2001 From: alfsb Date: Fri, 20 Dec 2024 13:54:56 -0300 Subject: [PATCH 4/6] Update scripts/file-entities.php Co-authored-by: Christoph M. Becker --- scripts/file-entities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/file-entities.php b/scripts/file-entities.php index bf0ffba41..4b2a7b33d 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -323,7 +323,7 @@ function realpain( string $path , bool $touch = false ) : string touch( $path ); $res = realpath( $path ); - if ( is_string( $res ) ) + if ($res !== false) $path = $res; return $path; From b4ef2edf5a1024981fe2a571cca4622269f53109 Mon Sep 17 00:00:00 2001 From: alfsb Date: Fri, 20 Dec 2024 13:55:09 -0300 Subject: [PATCH 5/6] Update scripts/file-entities.php Co-authored-by: Christoph M. Becker --- scripts/file-entities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/file-entities.php b/scripts/file-entities.php index 4b2a7b33d..7bdda6360 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -18,7 +18,7 @@ # Description This script creates various "file entities", that is, DTD entities that -points to files and file listings, named and composed of: +point to files and file listings, named and composed of: - dir.dir.file : pulls in a dir/dir/file.xml file - dir.dif.entities.dir : pulls in all files of dir/dir/dir/*.xml From 3b7ed33ae7c925900a19c6879da3fd3a127eb7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 30 Dec 2024 12:35:46 -0300 Subject: [PATCH 6/6] Review --- scripts/file-entities.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/file-entities.php b/scripts/file-entities.php index 7bdda6360..8b0d697a3 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -314,11 +314,10 @@ function realpain( string $path , bool $touch = false ) : string { // pain is real - // care for external XML tools (realpath everywhere) + // 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 ( $touch && ! file_exists( $path ) ) touch( $path ); @@ -328,4 +327,3 @@ function realpain( string $path , bool $touch = false ) : string return $path; } -