| 1 | package Makefile::Update::Bakefile0; | ||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Update bakefile-0.x files list. | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 1 | our @EXPORT = qw(update_bakefile_0); | |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 1 | our $VERSION = '0.4'; # VERSION | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | sub update_bakefile_0 | ||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
update_bakefile_0: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 16 | 1 | my ($in, $out, $vars) = @_; | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | # Variable whose contents is being currently replaced. | ||||||||||||||||||||||||||||||||
| 19 | 1 | my $var; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | # Hash with files defined for the specified variable as keys and 0 or 1 | ||||||||||||||||||||||||||||||||
| 22 | # depending on whether we have seen them in the input file as values. | ||||||||||||||||||||||||||||||||
| 23 | my %files; | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | # Set to 1 if we made any changes. | ||||||||||||||||||||||||||||||||
| 26 | 1 | my $changed = 0; | |||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | while (<$in>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 28 | 21 | chomp; | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 21 | ▶ | if (/<set var="(\w+)" hints="files">/ && exists $vars->{$1}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
/<set var="(\w+)" hints="files">/ and exists $vars->{$1}
MC/DC50%1/2
/<set var="(\w+)" hints="files">/ and exists $vars->{$1}
/<set var="(\w+)" hints="files">/
exists $vars->{$1}
Truth table66%2/3
A and B
A= /<set var="(\w+)" hints="files">/B= exists $vars->{$1}
| |||||||||||||||||||||||||||||||||
| 31 | 2 | $var = $1; | |||||||||||||||||||||||||||||||
| 32 | 2 | %files = map { $_ => 0 } @{$vars->{$var}}; | |||||||||||||||||||||||||||||||
| 33 | } elsif (defined $var) { | ||||||||||||||||||||||||||||||||
| 34 | 9 | local $_ = $_; | |||||||||||||||||||||||||||||||
| 35 | 9 | s/<!-- .* -->//; | |||||||||||||||||||||||||||||||
| 36 | 9 | s/^\s+//; | |||||||||||||||||||||||||||||||
| 37 | 9 | s/\s+$//; | |||||||||||||||||||||||||||||||
| 38 | 9 | s{<if [^>]+>}{}; | |||||||||||||||||||||||||||||||
| 39 | 9 | s{</if>}{}; | |||||||||||||||||||||||||||||||
| 40 | 9 | ▶ | if (m{</set>}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 41 | # Check if we have any new files. | ||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||
| 43 | # TODO Insert them in alphabetical order. | ||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | while (my ($file, $seen) = each(%files)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | 7 | ▶ | if (!$seen) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | # This file was wasn't present in the input, add it. | ||||||||||||||||||||||||||||||||
| 47 | # TODO Use proper indentation. | ||||||||||||||||||||||||||||||||
| 48 | 2 | print $out " $file\n"; | |||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 2 | $changed = 1; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 2 | undef $var; | |||||||||||||||||||||||||||||||
| 55 | } elsif ($_) { | ||||||||||||||||||||||||||||||||
| 56 | 6 | ▶ | if (not exists $files{$_}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 57 | # This file was removed. | ||||||||||||||||||||||||||||||||
| 58 | 1 | $changed = 1; | |||||||||||||||||||||||||||||||
| 59 | 1 | next; | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | if ($files{$_}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 0 | warn qq{Duplicate file "$_" in the definition of the } . | |||||||||||||||||||||||||||||||
| 64 | qq{variable "$var" at line $.\n} | ||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||
| 66 | 5 | $files{$_} = 1; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 20 | print $out "$_\n"; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | $changed | ||||||||||||||||||||||||||||||||
| 75 | 1 | } | |||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | __END__ | ||||||||||||||||||||||||||||||||