From: Shlomi Fish Date: Wed, 14 Nov 2012 11:38:37 +0000 (+0200) Subject: Extract a subroutine. X-Git-Tag: upstream/5.20.0~4305^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db66d27d1fc06a2481f86ac632dc733a286b6d18;p=platform%2Fupstream%2Fperl.git Extract a subroutine. --- diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 9574084..330f7a9 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -5729,6 +5729,49 @@ sub _cmd_L_calc_wanted_flags { return (map { index($arg, $_) >= 0 ? 1 : 0 } qw(a b w)); } + +sub _cmd_L_handle_breakpoints { + my ($handle_db_line) = @_; + + BREAKPOINTS_SCAN: + # Look in all the files with breakpoints... + for my $file ( keys %had_breakpoints ) { + + # Temporary switch to this file. + local *dbline = $main::{ '_<' . $file }; + + # Set up to look through the whole file. + $max = $#dbline; + my $was; # Flag: did we print something + # in this file? + + # For each line in the file ... + for my $i (1 .. $max) { + + # We've got something on this line. + if ( defined $dbline{$i} ) { + + # Print the header if we haven't. + if (not $was++) { + print {$OUT} "$file:\n"; + } + + # Print the line. + print {$OUT} " $i:\t", $dbline[$i]; + + $handle_db_line->($dbline{$i}); + + # Quit if the user hit interrupt. + if ($signal) { + last BREAKPOINTS_SCAN; + } + } ## end if (defined $dbline{$i... + } ## end for my $i (1 .. $max) + } ## end for my $file (keys %had_breakpoints) + + return; +} + sub cmd_L { my $cmd = shift; @@ -5754,42 +5797,7 @@ sub cmd_L { # Breaks and actions are found together, so we look in the same place # for both. if ( $break_wanted or $action_wanted ) { - - BREAKPOINTS_SCAN: - # Look in all the files with breakpoints... - for my $file ( keys %had_breakpoints ) { - - # Temporary switch to this file. - local *dbline = $main::{ '_<' . $file }; - - # Set up to look through the whole file. - $max = $#dbline; - my $was; # Flag: did we print something - # in this file? - - # For each line in the file ... - for my $i (1 .. $max) { - - # We've got something on this line. - if ( defined $dbline{$i} ) { - - # Print the header if we haven't. - if (not $was++) { - print {$OUT} "$file:\n"; - } - - # Print the line. - print {$OUT} " $i:\t", $dbline[$i]; - - $handle_db_line->($dbline{$i}); - - # Quit if the user hit interrupt. - if ($signal) { - last BREAKPOINTS_SCAN; - } - } ## end if (defined $dbline{$i... - } ## end for my $i (1 .. $max) - } ## end for my $file (keys %had_breakpoints) + _cmd_L_handle_breakpoints($handle_db_line); } ## end if ($break_wanted or $action_wanted) # Look for breaks in not-yet-compiled subs: