This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl5db] Extract a function.
[perl5.git] / lib / perl5db.pl
index ca58b71..6044fb5 100644 (file)
@@ -4688,6 +4688,15 @@ are no magical debugger structures associated with them.
 
 =cut
 
+sub _remove_breakpoint_entry {
+    my ($fn, $i) = @_;
+
+    delete $dbline{$i};
+    _delete_breakpoint_data_ref($fn, $i);
+
+    return;
+}
+
 sub _delete_all_breakpoints {
     print {$OUT} "Deleting all breakpoints...\n";
 
@@ -4699,7 +4708,6 @@ sub _delete_all_breakpoints {
         local *dbline = $main::{ '_<' . $fn };
 
         $max = $#dbline;
-        my $was;
 
         # For all lines in this file ...
         for my $i (1 .. $max) {
@@ -4710,10 +4718,8 @@ sub _delete_all_breakpoints {
                 # ... remove the breakpoint.
                 $dbline{$i} =~ s/\A[^\0]+//;
                 if ( $dbline{$i} =~ s/\A\0?\z// ) {
-
                     # Remove the entry altogether if no action is there.
-                    delete $dbline{$i};
-                    _delete_breakpoint_data_ref($fn, $i);
+                    _remove_breakpoint_entry($fn, $i);
                 }
             } ## end if (defined $dbline{$i...
         } ## end for $i (1 .. $max)
@@ -4735,34 +4741,37 @@ sub _delete_all_breakpoints {
     return;
 }
 
-sub delete_breakpoint {
-    my $i = shift;
+sub _delete_breakpoint_from_line {
+    my ($i) = @_;
 
-    my $fn = $filename;
+    # Woops. This line wasn't breakable at all.
+    die "Line $i not breakable.\n" if $dbline[$i] == 0;
 
-    # If we got a line, delete just that one.
-    if ( defined($i) ) {
+    # Kill the condition, but leave any action.
+    $dbline{$i} =~ s/\A[^\0]*//;
 
-        # Woops. This line wasn't breakable at all.
-        die "Line $i not breakable.\n" if $dbline[$i] == 0;
+    # Remove the entry entirely if there's no action left.
+    if ($dbline{$i} eq '') {
+        _remove_breakpoint_entry($filename, $i);
+    }
 
-        # Kill the condition, but leave any action.
-        $dbline{$i} =~ s/\A[^\0]*//;
+    return;
+}
 
-        # Remove the entry entirely if there's no action left.
-        if ($dbline{$i} eq '') {
-            delete $dbline{$i};
-            _delete_breakpoint_data_ref($fn, $i);
-        }
-    }
+sub delete_breakpoint {
+    my $i = shift;
 
+    # If we got a line, delete just that one.
+    if ( defined($i) ) {
+        _delete_breakpoint_from_line($i);
+    }
     # No line; delete them all.
     else {
         _delete_all_breakpoints();
-    } ## end else [ if (defined($i))
+    }
 
     return;
-} ## end sub delete_breakpoint
+}
 
 =head3 cmd_stop (command)