From: Nigel Metheringham Date: Sat, 9 Jun 2012 19:00:28 +0000 (+0100) Subject: perltidy attack on generation scripts X-Git-Tag: exim-4_89_1~50 X-Git-Url: https://git.exim.org/exim-website.git/commitdiff_plain/27ac44720ba0b617160e7c61604dd425184cf5c9 perltidy attack on generation scripts --- diff --git a/script/gen.pl b/script/gen.pl index f3e0486..bb94a7c 100755 --- a/script/gen.pl +++ b/script/gen.pl @@ -21,7 +21,7 @@ my $canonical_url = 'http://www.exim.org/'; my %opt = parse_arguments(); ## Generate the pages -my %cache; # General cache object +my %cache; # General cache object do_doc( 'spec', $_ ) foreach @{ $opt{spec} || [] }; do_doc( 'filter', $_ ) foreach @{ $opt{filter} || [] }; do_web() if exists $opt{web}; @@ -113,10 +113,10 @@ sub do_doc { "${canonical_url}exim-html-current/doc/html/spec_html/" . ( $type eq 'spec' ? 'index' : 'filter' ) . ".html" ); ## Add a url for the latest version of this document - if( $version ne $opt{latest} ){ - $xml->documentElement() - ->appendTextChild( 'current_url', - "../../../../exim-html-current/doc/html/spec_html/" . ( $type eq 'spec' ? 'index' : 'filter' ) . ".html" ); + if ( $version ne $opt{latest} ) { + $xml->documentElement() + ->appendTextChild( 'current_url', + "../../../../exim-html-current/doc/html/spec_html/" . ( $type eq 'spec' ? 'index' : 'filter' ) . ".html" ); } ## Fixup the XML @@ -140,7 +140,7 @@ sub do_doc { ## Generate the chapters my $counter = 0; my @chapters = map { $_->cloneNode(1) } $xml->findnodes('/book/chapter'); - foreach my $chapter ( @chapters ) { + foreach my $chapter (@chapters) { ## Add a N node for the stylesheet to use $chapter->appendTextChild( 'chapter_id', ++$counter ); @@ -153,7 +153,8 @@ sub do_doc { ? 'filter.html' : 'index.html' : sprintf( '%sch%02d.html', $prepend_chapter, $counter - 1 ) ); - $chapter->appendTextChild( 'next_url', sprintf( '%sch%02d.html', $prepend_chapter, $counter + 1 ) ) unless int(@chapters) == $counter; + $chapter->appendTextChild( 'next_url', sprintf( '%sch%02d.html', $prepend_chapter, $counter + 1 ) ) + unless int(@chapters) == $counter; $chapter->appendTextChild( 'canonical_url', sprintf( @@ -161,15 +162,15 @@ sub do_doc { $prepend_chapter, $counter ) ); - if( $version ne $opt{latest} ){ - $chapter->appendTextChild( - 'current_url', - sprintf( - '../../../../exim-html-current/doc/html/spec_html/%sch%02d.html', - $prepend_chapter, $counter - ) - ); - } + if ( $version ne $opt{latest} ) { + $chapter->appendTextChild( + 'current_url', + sprintf( + '../../../../exim-html-current/doc/html/spec_html/%sch%02d.html', + $prepend_chapter, $counter + ) + ); + } } ## Create an XML document from the chapter @@ -354,16 +355,16 @@ sub transform { close $out; } -## Look in the docroot for old versions of the documentation +## Look in the docroot for old versions of the documentation sub old_docs_versions { - if( !exists $cache{old_docs_versions} ){ - my @versions; - foreach( glob("$opt{docroot}/exim-html-*") ){ - push @versions, $1 if /-(\d+(?:\.\d+)?)$/ && $1 < $opt{latest} && -d $_; - } - $cache{old_docs_versions} = [reverse sort {$a<=>$b} @versions]; - } - return @{$cache{old_docs_versions}}; + if ( !exists $cache{old_docs_versions} ) { + my @versions; + foreach ( glob("$opt{docroot}/exim-html-*") ) { + push @versions, $1 if /-(\d+(?:\.\d+)?)$/ && $1 < $opt{latest} && -d $_; + } + $cache{old_docs_versions} = [ reverse sort { $a <=> $b } @versions ]; + } + return @{ $cache{old_docs_versions} }; } ## error_help