From 7c6af3816ca2bd01583b94c8171907744993516c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Thu, 7 Nov 2024 12:25:56 -0300 Subject: [PATCH] qaxml.t.php: tests for spurious ws in some tags. --- scripts/translation/qaxml.w.php | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 scripts/translation/qaxml.w.php diff --git a/scripts/translation/qaxml.w.php b/scripts/translation/qaxml.w.php new file mode 100644 index 000000000..2a18f8f2e --- /dev/null +++ b/scripts/translation/qaxml.w.php @@ -0,0 +1,67 @@ + | + * +----------------------------------------------------------------------+ + * | Description: Checks for ws that may cause render trouble. | + * +----------------------------------------------------------------------+ + */ + +require_once __DIR__ . '/lib/all.php'; + +$qalist = QaFileInfo::cacheLoad(); +$outarg = new OutputIgnoreArgv( $argv ); + +foreach ( $qalist as $qafile ) +{ + $source = $qafile->sourceDir . '/' . $qafile->file; + $target = $qafile->targetDir . '/' . $qafile->file; + + whitespaceCheckFile( $source ); + whitespaceCheckFile( $target ); +} + +function whitespaceCheckFile( string $filename ) +{ + if ( file_exists( $filename ) == false ) + return; + + global $outarg; + $output = new OutputIgnoreBuffer( $outarg , "qaxml.w: {$filename}\n\n" , $filename ); + + $xml = XmlUtil::loadFile( $filename ); + $tags = XmlUtil::listNodeType( $xml , XML_ELEMENT_NODE ); + + foreach( $tags as $node ) + { + switch ( $node->nodeName ) + { + case "classname": + case "constant": + case "function": + case "methodname": + case "varname": + $text = $node->nodeValue; + $trim = trim( $text ); + if ( $text != $trim ) + { + $output->addLine(); + $output->add( " {$node->nodeName} {$trim}\n" ); + } + break; + } + } + + $output->print(); +} +