From 32bbadc6b50551dcc914a0232b154a367cce1f34 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 2 Oct 2012 15:57:13 +0200 Subject: [PATCH] [perl5db] Extract a function in the condition. --- lib/perl5db.pl | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 51ff1f8..ed6002a 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -1799,6 +1799,31 @@ sub _DB__is_finished { } } +sub _DB__read_next_cmd +{ + my ($tid) = @_; + + # We have a terminal, or can get one ... + if (!$term) { + setterm(); + } + + # ... and it belogs to this PID or we get one for this PID ... + if ($term_pid != $$) { + resetterm(1); + } + + # ... and we got a line of command input ... + $cmd = DB::readline( + "$pidprompt $tid DB" + . ( '<' x $level ) + . ( $#hist + 1 ) + . ( '>' x $level ) . " " + ); + + return defined($cmd); +} + sub DB { # lock the debugger and get the thread id for the prompt @@ -2022,30 +2047,7 @@ the new command. This is faster, but perhaps a bit more convoluted. my $selected; CMD: - while ( - do - { - # We have a terminal, or can get one ... - if (!$term) { - setterm(); - } - - # ... and it belogs to this PID or we get one for this PID ... - if ($term_pid != $$) { - resetterm(1); - } - - # ... and we got a line of command input ... - defined( - $cmd = DB::readline( - "$pidprompt $tid DB" - . ( '<' x $level ) - . ( $#hist + 1 ) - . ( '>' x $level ) . " " - ) - ); - } - ) + while (_DB__read_next_cmd($tid)) { share($cmd); -- 2.7.4