Extract _dump_trace_calc_saved_single_arg.
authorShlomi Fish <shlomif@shlomifish.org>
Sun, 18 Nov 2012 10:14:12 +0000 (12:14 +0200)
committerTony Cook <tony@develop-help.com>
Wed, 2 Jan 2013 00:22:06 +0000 (11:22 +1100)
lib/perl5db.pl

index d32e1cb..7bf7177 100644 (file)
@@ -6463,45 +6463,49 @@ stack frame. Each has the following keys and values:
 
 =cut
 
-sub _dump_trace_calc_save_args {
-    my ($nothard) = @_;
+sub _dump_trace_calc_saved_single_arg
+{
+    my ($nothard, $arg) = @_;
 
-    my @a;
-    for my $arg (@args) {
-        my $type;
-        if ( not defined $arg ) {    # undefined parameter
-            push @a, "undef";
-        }
+    my $type;
+    if ( not defined $arg ) {    # undefined parameter
+        return "undef";
+    }
 
-        elsif ( $nothard and tied $arg ) {    # tied parameter
-            push @a, "tied";
-        }
-        elsif ( $nothard and $type = ref $arg ) {    # reference
-            push @a, "ref($type)";
-        }
-        else {                                       # can be stringified
-            local $_ =
-            "$arg";    # Safe to stringify now - should not call f().
+    elsif ( $nothard and tied $arg ) {    # tied parameter
+        return "tied";
+    }
+    elsif ( $nothard and $type = ref $arg ) {    # reference
+        return "ref($type)";
+    }
+    else {                                       # can be stringified
+        local $_ =
+        "$arg";    # Safe to stringify now - should not call f().
 
-            # Backslash any single-quotes or backslashes.
-            s/([\'\\])/\\$1/g;
+        # Backslash any single-quotes or backslashes.
+        s/([\'\\])/\\$1/g;
 
-            # Single-quote it unless it's a number or a colon-separated
-            # name.
-            s/(.*)/'$1'/s
-            unless /^(?: -?[\d.]+ | \*[\w:]* )$/x;
+        # Single-quote it unless it's a number or a colon-separated
+        # name.
+        s/(.*)/'$1'/s
+        unless /^(?: -?[\d.]+ | \*[\w:]* )$/x;
 
-            # Turn high-bit characters into meta-whatever.
-            s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
+        # Turn high-bit characters into meta-whatever.
+        s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
 
-            # Turn control characters into ^-whatever.
-            s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
+        # Turn control characters into ^-whatever.
+        s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
 
-            push( @a, $_ );
-        } ## end else [ if (not defined $arg)
-    } ## end for $arg (@args)
+        return $_;
+    }
+}
+
+sub _dump_trace_calc_save_args {
+    my ($nothard) = @_;
 
-    return \@a;
+    return [
+        map { _dump_trace_calc_saved_single_arg($nothard, $_) } @args
+    ];
 }
 
 sub dump_trace {