From: Ian Jackson Date: Fri, 9 Dec 2016 19:08:14 +0000 (+0000) Subject: sg-check-tested: Lift work into new `search' sub, and indirect output X-Git-Tag: openstack-v11~175 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=fd2fbb9171f12d5f45e952e2915f3e00bcaacc1a;p=people%2Faperard%2Fosstest.git sg-check-tested: Lift work into new `search' sub, and indirect output * Replace open-coded prints to stdout with calls to new `ouput' sub * Move main body into new `search' sub * Exit from `search' with `return' rather than `exit 0' Overall, no functional change. Signed-off-by: Ian Jackson --- diff --git a/sg-check-tested b/sg-check-tested index 43f2854a..8f2a2640 100755 --- a/sg-check-tested +++ b/sg-check-tested @@ -149,57 +149,65 @@ sub prepare_execute ($@) { return $q; } -my $q = prepare_execute($qtxt, @conds_vars); - sub massage ($) { local ($_) = @_; s/^\d+\://; $_; } -FLIGHT: -while (my $row= $q->fetchrow_hashref()) { - my $flight= $row->{flight}; - if (!defined $prrev) { - print DEBUG "==========YES\n"; - print $flight,"\n" or die $!; - exit 0; - } else { - my $valsq; - if ($prrev eq 'osstest') { - $valsq= prepare_execute(<fetchrow_hashref()) { + my $flight= $row->{flight}; + if (!defined $prrev) { + print DEBUG "==========YES\n"; + output $flight,"\n"; + return; } else { - $valsq= prepare_execute(<fetchrow_hashref(); - next unless defined $row1->{val} && length $row1->{val}; - my $val1 = massage($row1->{val}); - print DEBUG "got $val1\n"; - while (my $row2 = $valsq->fetchrow_hashref()) { - my $val2 = massage($row2->{val}); - next if $val2 eq $val1; - print DEBUG "also $val2\n"; - next FLIGHT; - } - if (defined $ancestorof) { - if (!$ancestors{$val1}) { - print DEBUG "not an ancestor of $ancestorof\n"; + } else { + $valsq= prepare_execute(<fetchrow_hashref(); + next unless defined $row1->{val} && length $row1->{val}; + my $val1 = massage($row1->{val}); + print DEBUG "got $val1\n"; + while (my $row2 = $valsq->fetchrow_hashref()) { + my $val2 = massage($row2->{val}); + next if $val2 eq $val1; + print DEBUG "also $val2\n"; next FLIGHT; } + if (defined $ancestorof) { + if (!$ancestors{$val1}) { + print DEBUG "not an ancestor of $ancestorof\n"; + next FLIGHT; + } + } + output "$val1\n"; + exit 0; } - print "$val1\n"; - exit 0; } + print DEBUG "==========NO\n"; } -print DEBUG "==========NO\n"; +search(); + exit 0;