This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 17 Mar 2003 04:59:15 +0000 (04:59 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Mon, 17 Mar 2003 04:59:15 +0000 (04:59 +0000)
[ 18994]
Fix for [perl #21479] Term::ReadLine(::Stub) doesn't set UTF-8 flag.
Should work both for PERL_UNICODE/-C and use encoding 'foo';

[ 18995]
Signedness nits.

[ 18996]
Turn on UTF-8 flag only if the $str is valid utf8
(pointed out by Dan Kogai).

[ 18997]
IRIX ls -l marks sockets with 'S'.

[ 18998]
This seems to fix (well, dodge) the problems in FreeBSD for
Enache Adrian; in _theory_ this patch could be good for NetBSD,
too, but Alian gets a core dump already at subtest #9 (anyone
with a real NetBSD, Alian's is a VMware one, which has in the
past caused similar odd crashes).  OpenBSD threaded build result
still unknown.

[ 18999]
Stay within know facts: what platforms the skippage helps,
and in which it is not needed.

[ 19000]
Subject: [Patch] Maintperl versioning for Cygwin
From: "Gerrit P. Haase" <gp@familiehaase.de>
Date: Sun, 16 Mar 2003 22:24:19 +0100
Message-ID: <152690440450.20030316222419@familiehaase.de>

[ 19001]
getservbyname_r() kaputt in OpenBSD (might get fixed
for 3.3, but only might)

[ 19002]
Subject: [perl #19898] [PATCH] forking to Perl children with IPC::Open3
From: Adam Spiers (via RT) <perlbug-followup@perl.org>
Date: 10 Jan 2003 10:59:44 -0000
Message-Id: <rt-19898-47213.12.0892150698178@bugs6.perl.org>

[ 19003]
Subject: [perl #20724] Patch for dprofpp
From: Nicholas "Oxhøj" (via RT) <perlbug-followup@perl.org>
Date: 5 Feb 2003 08:41:17 -0000
Message-Id: <rt-20724-50329.7.50247680562964@bugs6.perl.org>

[ 19004]
Subject: [patch] utils/h2xs.PL (get rid of \t and '')
From: Stas Bekman <stas@stason.org>
Date: Fri, 14 Feb 2003 11:59:53 +1100
Message-ID: <3E4C3F89.6050005@stason.org>

[ 19005]
Subject: Patch for Data::Dumper 2.12 to Allow Custom Hash Key/Value Separator
From: chocolateboy <chocolateboy@chocolatey.com>
Date: Sat, 22 Feb 2003 12:17:28 +0000
Message-ID: <3E576A58.8010901@chocolatey.com>
p4raw-link: @19005 on //depot/perl: 30b4f38607fd824e698ead42ae0a9819f52d0a51
p4raw-link: @19004 on //depot/perl: 1dd73f2742b0eabfe6ac8450e3f71bc08cb138db
p4raw-link: @19003 on //depot/perl: 1d9525ac4548fadba8931dabed738577ec3119a6
p4raw-link: @19002 on //depot/perl: a2a6353196ca82b2a5520663fc0004fbc2170da6
p4raw-link: @19001 on //depot/perl: 36e43f01026d4e626675945fbb0471760b81782c
p4raw-link: @19000 on //depot/maint-5.8/perl: 227554bd5671f5fec3940cde7172eee1368c3db3
p4raw-link: @18999 on //depot/perl: bc4938c65d770a20856c44a0d21026bcc6f41d7b
p4raw-link: @18998 on //depot/perl: 178c78622b1504e891c12d3afed50554a19b8fbe
p4raw-link: @18997 on //depot/perl: 085a16fc645d01e9c317a227fb12575af270d8fb
p4raw-link: @18996 on //depot/perl: 11412ee612ee855f6157e78034024e8f5e3ba052
p4raw-link: @18995 on //depot/perl: 5e43f4674257b58e1586fd5e88cdab2ae2f833ee
p4raw-link: @18994 on //depot/perl: 2499d3299d5b988dc734ee240003b6eb71752236

p4raw-id: //depot/maint-5.8/perl@19008
p4raw-branched: from //depot/perl@19006 'branch in'
ext/Data/Dumper/t/pair.t
p4raw-integrated: from //depot/perl@19006 'copy in' lib/IPC/Open3.pm
(@11034..) utils/h2xs.PL (@16843..) utils/dprofpp.PL (@17897..)
lib/Term/ReadLine.pm (@18137..) ext/POSIX/t/posix.t (@18299..)
ext/Data/Dumper/Dumper.pm (@18513..) hints/openbsd.sh
(@18647..) ext/Data/Dumper/Dumper.xs (@18709..) t/op/stat.t
(@18951..) 'merge in' MANIFEST (@18952..) regcomp.c (@18990..)

12 files changed:
MANIFEST
ext/Data/Dumper/Dumper.pm
ext/Data/Dumper/Dumper.xs
ext/Data/Dumper/t/pair.t [new file with mode: 0755]
ext/POSIX/t/posix.t
hints/openbsd.sh
lib/IPC/Open3.pm
lib/Term/ReadLine.pm
regcomp.c
t/op/stat.t
utils/dprofpp.PL
utils/h2xs.PL

index a4b730a..d961847 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -129,6 +129,7 @@ ext/Data/Dumper/Dumper.pm   Data pretty printer, module
 ext/Data/Dumper/Dumper.xs      Data pretty printer, externals
 ext/Data/Dumper/Makefile.PL    Data pretty printer, makefile writer
 ext/Data/Dumper/t/dumper.t     See if Data::Dumper works
+ext/Data/Dumper/t/pair.t       See if Data::Dumper pair separator works
 ext/Data/Dumper/t/overload.t   See if Data::Dumper works for overloaded data
 ext/Data/Dumper/Todo           Data pretty printer, futures
 ext/DB_File/Changes    Berkeley DB extension change log
index 8e5320e..9034544 100644 (file)
@@ -40,6 +40,7 @@ $Quotekeys = 1 unless defined $Quotekeys;
 $Bless = "bless" unless defined $Bless;
 #$Expdepth = 0 unless defined $Expdepth;
 $Maxdepth = 0 unless defined $Maxdepth;
+$Pair = ' => ' unless defined $Pair;
 $Useperl = 0 unless defined $Useperl;
 $Sortkeys = 0 unless defined $Sortkeys;
 $Deparse = 0 unless defined $Deparse;
@@ -64,6 +65,7 @@ sub new {
             xpad       => "",          # padding-per-level
             apad       => "",          # added padding for hash keys n such
             sep        => "",          # list separator
+            pair       => $Pair,       # hash key/value separator: defaults to ' => '
             seen       => {},          # local (nested) refs (id => [name, val])
             todump     => $v,          # values to dump []
             names      => $n,          # optional names for values []
@@ -332,10 +334,11 @@ sub _dump {
       $out .= ($name =~ /^\@/) ? ')' : ']';
     }
     elsif ($realtype eq 'HASH') {
-      my($k, $v, $pad, $lpad, $mname);
+      my($k, $v, $pad, $lpad, $mname, $pair);
       $out .= ($name =~ /^\%/) ? '(' : '{';
       $pad = $s->{sep} . $s->{pad} . $s->{apad};
       $lpad = $s->{apad};
+      $pair = $s->{pair};
       ($name =~ /^\%(.*)$/) ? ($mname = "\$" . $1) :
        # omit -> if $foo->[0]->{bar}, but not ${$foo->[0]}->{bar}
        ($name =~ /^\\?[\%\@\*\$][^{].*[]}]$/) ? ($mname = $name) :
@@ -361,7 +364,7 @@ sub _dump {
        my $nk = $s->_dump($k, "");
        $nk = $1 if !$s->{quotekeys} and $nk =~ /^[\"\']([A-Za-z_]\w*)[\"\']$/;
        $sname = $mname . '{' . $nk . '}';
-       $out .= $pad . $ipad . $nk . " => ";
+       $out .= $pad . $ipad . $nk . $pair;
 
        # temporarily alter apad
        $s->{apad} .= (" " x (length($nk) + 4)) if $s->{indent} >= 2;
@@ -517,6 +520,11 @@ sub Indent {
   }
 }
 
+sub Pair {
+    my($s, $v) = @_;
+    defined($v) ? (($s->{pair} = $v), return $s) : $s->{pair};
+}
+
 sub Pad {
   my($s, $v) = @_;
   defined($v) ? (($s->{pad} = $v), return $s) : $s->{pad};
@@ -914,6 +922,19 @@ Default is C<bless>.
 
 =item *
 
+$Data::Dumper::Pair  I<or>  $I<OBJ>->Pair(I<[NEWVAL]>)
+
+Can be set to a string that specifies the separator between hash keys
+and values. To dump nested hash, array and scalar values to JavaScript,
+use: C<$Data::Dumper::Pair = ' : ';>. Implementing C<bless> in JavaScript
+is left as an exercise for the reader.
+A function with the specified name exists, and accepts the same arguments
+as the builtin.
+
+Default is: C< =E<gt> >.
+
+=item *
+
 $Data::Dumper::Maxdepth  I<or>  $I<OBJ>->Maxdepth(I<[NEWVAL]>)
 
 Can be set to a positive integer that specifies the depth beyond which
@@ -1019,6 +1040,9 @@ distribution for more examples.)
     $Data::Dumper::Useqq = 1;          # print strings in double quotes
     print Dumper($boo);
 
+    $Data::Dumper::Pair = " : ";       # specify hash key/value separator
+    print Dumper($boo);
+
 
     ########
     # recursive structures
index c0ab07c..743781b 100644 (file)
@@ -29,7 +29,7 @@ static I32 esc_q_utf8 (pTHX_ SV *sv, char *src, STRLEN slen);
 static SV *sv_x (pTHX_ SV *sv, char *str, STRLEN len, I32 n);
 static I32 DD_dump (pTHX_ SV *val, char *name, STRLEN namelen, SV *retval,
                    HV *seenhv, AV *postav, I32 *levelp, I32 indent,
-                   SV *pad, SV *xpad, SV *apad, SV *sep,
+                   SV *pad, SV *xpad, SV *apad, SV *sep, SV *pair,
                    SV *freezer, SV *toaster,
                    I32 purity, I32 deepcopy, I32 quotekeys, SV *bless,
                    I32 maxdepth, SV *sortkeys);
@@ -224,7 +224,7 @@ sv_x(pTHX_ SV *sv, register char *str, STRLEN len, I32 n)
 static I32
 DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
        AV *postav, I32 *levelp, I32 indent, SV *pad, SV *xpad,
-       SV *apad, SV *sep, SV *freezer, SV *toaster, I32 purity,
+       SV *apad, SV *sep, SV *pair, SV *freezer, SV *toaster, I32 purity,
        I32 deepcopy, I32 quotekeys, SV *bless, I32 maxdepth, SV *sortkeys)
 {
     char tmpbuf[128];
@@ -397,7 +397,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            if (realpack) {                                  /* blessed */
                sv_catpvn(retval, "do{\\(my $o = ", 13);
                DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
-                       postav, levelp, indent, pad, xpad, apad, sep,
+                       postav, levelp, indent, pad, xpad, apad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
                sv_catpvn(retval, ")}", 2);
@@ -405,7 +405,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            else {
                sv_catpvn(retval, "\\", 1);
                DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
-                       postav, levelp, indent, pad, xpad, apad, sep,
+                       postav, levelp, indent, pad, xpad, apad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
            }
@@ -417,7 +417,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            sv_catpvn(namesv, "}", 1);
            sv_catpvn(retval, "\\", 1);
            DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
-                   postav, levelp,     indent, pad, xpad, apad, sep,
+                   postav, levelp,     indent, pad, xpad, apad, sep, pair,
                    freezer, toaster, purity, deepcopy, quotekeys, bless,
                    maxdepth, sortkeys);
            SvREFCNT_dec(namesv);
@@ -486,7 +486,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                sv_catsv(retval, totpad);
                sv_catsv(retval, ipad);
                DD_dump(aTHX_ elem, iname, ilen, retval, seenhv, postav,
-                       levelp, indent, pad, xpad, apad, sep,
+                       levelp, indent, pad, xpad, apad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
                if (ix < ixmax)
@@ -640,7 +640,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                    There should also be less tests for the (probably currently)
                    more common doesn't need quoting case.
                    The code is also smaller (22044 vs 22260) because I've been
-                   able to pull the comon logic out to both sides.  */
+                   able to pull the common logic out to both sides.  */
                 if (quotekeys || needs_quote(key)) {
                     if (do_utf8) {
                         STRLEN ocur = SvCUR(retval);
@@ -671,7 +671,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                 sv_catpvn(sname, nkey, nlen);
                 sv_catpvn(sname, "}", 1);
 
-               sv_catpvn(retval, " => ", 4);
+               sv_catsv(retval, pair);
                if (indent >= 2) {
                    char *extra;
                    I32 elen = 0;
@@ -687,7 +687,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                    newapad = apad;
 
                DD_dump(aTHX_ hval, SvPVX(sname), SvCUR(sname), retval, seenhv,
-                       postav, levelp, indent, pad, xpad, newapad, sep,
+                       postav, levelp, indent, pad, xpad, newapad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
                SvREFCNT_dec(sname);
@@ -849,7 +849,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                        
                        DD_dump(aTHX_ e, SvPVX(nname), SvCUR(nname), postentry,
                                seenhv, postav, &nlevel, indent, pad, xpad,
-                               newapad, sep, freezer, toaster, purity,
+                               newapad, sep, pair, freezer, toaster, purity,
                                deepcopy, quotekeys, bless, maxdepth, 
                                sortkeys);
                        SvREFCNT_dec(e);
@@ -914,7 +914,7 @@ Data_Dumper_Dumpxs(href, ...)
            I32 level = 0;
            I32 indent, terse, i, imax, postlen;
            SV **svp;
-           SV *val, *name, *pad, *xpad, *apad, *sep, *varname;
+           SV *val, *name, *pad, *xpad, *apad, *sep, *pair, *varname;
            SV *freezer, *toaster, *bless, *sortkeys;
            I32 purity, deepcopy, quotekeys, maxdepth = 0;
            char tmpbuf[1024];
@@ -947,7 +947,7 @@ Data_Dumper_Dumpxs(href, ...)
 
            todumpav = namesav = Nullav;
            seenhv = Nullhv;
-           val = pad = xpad = apad = sep = varname
+           val = pad = xpad = apad = sep = pair = varname
                = freezer = toaster = bless = &PL_sv_undef;
            name = sv_newmortal();
            indent = 2;
@@ -983,6 +983,8 @@ Data_Dumper_Dumpxs(href, ...)
                    apad = *svp;
                if ((svp = hv_fetch(hv, "sep", 3, FALSE)))
                    sep = *svp;
+               if ((svp = hv_fetch(hv, "pair", 4, FALSE)))
+                   pair = *svp;
                if ((svp = hv_fetch(hv, "varname", 7, FALSE)))
                    varname = *svp;
                if ((svp = hv_fetch(hv, "freezer", 7, FALSE)))
@@ -1071,7 +1073,7 @@ Data_Dumper_Dumpxs(href, ...)
                        newapad = apad;
                
                    DD_dump(aTHX_ val, SvPVX(name), SvCUR(name), valstr, seenhv,
-                           postav, &level, indent, pad, xpad, newapad, sep,
+                           postav, &level, indent, pad, xpad, newapad, sep, pair,
                            freezer, toaster, purity, deepcopy, quotekeys,
                            bless, maxdepth, sortkeys);
                
diff --git a/ext/Data/Dumper/t/pair.t b/ext/Data/Dumper/t/pair.t
new file mode 100755 (executable)
index 0000000..569175d
--- /dev/null
@@ -0,0 +1,61 @@
+#!./perl -w
+#
+# test for $Data::Dumper::Pair AKA Data::Dumper->new([ ... ])->Pair('...')
+#
+
+BEGIN {
+    chdir 't' if -d 't';
+    unshift @INC, '../lib';
+    require Config; import Config;
+    if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
+      print "1..0 # Skip: Data::Dumper was not built\n";
+      exit 0;
+    }
+}
+
+use strict;
+use vars qw($want_colon $want_comma);
+use Test::More tests => 9;
+
+no warnings qw(once);
+
+require_ok 'Data::Dumper';
+
+my $HASH = { alpha => 'beta', gamma => 'vlissides' };
+my $WANT = q({'alpha' => 'beta','gamma' => 'vlissides'});
+
+$Data::Dumper::Useperl = 1;
+$Data::Dumper::Indent = 0;
+$Data::Dumper::Terse = 1;
+$Data::Dumper::Sortkeys = 1;
+
+$want_colon = $want_comma = $WANT;
+$want_colon =~ s/=>/:/g;
+$want_comma =~ s/ => /,/g;
+
+####################### XS Tests #####################
+
+SKIP: {
+    skip 'XS extension not loaded', 3 unless (defined &Data::Dumper::Dumpxs);
+    is (Data::Dumper::DumperX($HASH), $WANT, 
+       'XS: Default hash key/value separator: " => "');
+    local $Data::Dumper::Pair = ' : ';
+    is (Data::Dumper::DumperX($HASH), $want_colon, 'XS: $Data::Dumper::Pair = " : "');
+    my $dd = Data::Dumper->new([ $HASH ])->Pair(',');
+    is ($dd->Dumpxs(), $want_comma, 
+       'XS: Data::Dumper->new([ $HASH ])->Pair(",")->Dumpxs()');
+};
+
+###################### Perl Tests ####################
+
+{
+    is ($Data::Dumper::Pair, ' => ', 'Perl: $Data::Dumper::Pair eq " => "');
+    is (Data::Dumper::Dumper($HASH), $WANT, 
+       'Perl: Default hash key/value separator: " => "');
+    local $Data::Dumper::Pair = ' : ';
+    is (Data::Dumper::Dumper($HASH), $want_colon, 'Perl: $Data::Dumper::Pair = " : "');
+    my $dd = Data::Dumper->new([ $HASH ])->Pair(',');
+    is ($dd->Pair(), ',', 
+       'Perl: Data::Dumper->new([ $HASH ])->Pair(",")->Pair() eq ","');
+    is ($dd->Dump(), $want_comma, 'Perl: Data::Dumper->new([ $HASH ])->Pair(",")->Dump()');
+}
index 6ce418c..ea50ea3 100644 (file)
@@ -80,8 +80,10 @@ SKIP: {
 
         printf "%s 11 -   masked SIGINT received %s\n",
           $sigint_called ? "ok" : "not ok",
-          $^O eq 'darwin' ? "# TODO Darwin seems to loose blocked signals" 
-                          : '';
+          # At least OpenBSD/i386 3.3 is okay, as is NetBSD 1.5.
+          $^O =~ /^(?:darwin|freebsd)$/ ?
+             "# TODO $^O seems to loose blocked signals" 
+             : '';
 
        print "ok 12 - signal masks successful\n";
        
index 54626fb..5d47e0a 100644 (file)
@@ -112,6 +112,11 @@ $define|true|[yY]*)
                libswanted="$*"
        ;;
        esac
+       case "$osvers" in
+       [012].*|3.[0-3])
+               # Broken at least up to OpenBSD 3.2, we'll see about 3.3.
+               d_getservbyname_r=$undef ;;
+       esac
 esac
 EOCBU
 
index b59b09c..fd47e8e 100644 (file)
@@ -9,7 +9,7 @@ require Exporter;
 use Carp;
 use Symbol qw(gensym qualify);
 
-$VERSION       = 1.0104;
+$VERSION       = 1.0105;
 @ISA           = qw(Exporter);
 @EXPORT                = qw(open3);
 
@@ -52,6 +52,11 @@ failure: it just raises an exception matching C</^open3:/>.  However,
 C<exec> failures in the child are not detected.  You'll have to 
 trap SIGPIPE yourself.
 
+Note if you specify C<-> as the command, in an analogous fashion to
+C<open(FOO, "-|")> the child process will just be the forked Perl
+process rather than an external command.  This feature isn't yet
+supported on Win32 platforms.
+
 open3() does not wait for and reap the child process after it exits.  
 Except for short programs where it's acceptable to let the operating system
 take care of this, you need to do this yourself.  This is normally as 
@@ -88,6 +93,7 @@ The order of arguments differs from that of open2().
 # ported to Win32 by Ron Schmidt, Merrill Lynch almost ended my career
 # fixed for autovivving FHs, tchrist again
 # allow fd numbers to be used, by Frank Tobin
+# allow '-' as command (c.f. open "-|"), by Adam Spiers <perl@adamspiers.org>
 #
 # $Id: open3.pl,v 1.1 1993/11/23 06:26:15 marc Exp $
 #
@@ -226,6 +232,11 @@ sub _open3 {
        } else {
            xopen \*STDERR, ">&STDOUT" if fileno(STDERR) != fileno(STDOUT);
        }
+       if ($cmd[0] eq '-') {
+           croak "Arguments don't make sense when the command is '-'"
+             if @cmd > 1;
+           return 0;
+       }
        local($")=(" ");
        exec @cmd # XXX: wrong process to croak from
            or croak "$Me: exec of @cmd failed";
index 238e9fd..8cb6ab3 100644 (file)
@@ -184,6 +184,8 @@ $DB::emacs = $DB::emacs;    # To peacify -w
 our @rl_term_set;
 *rl_term_set = \@Term::ReadLine::TermCap::rl_term_set;
 
+sub PERL_UNICODE_STDIN () { 0x0001 }
+
 sub ReadLine {'Term::ReadLine::Stub'}
 sub readline {
   my $self = shift;
@@ -196,6 +198,9 @@ sub readline {
   #$str = scalar <$in>;
   $str = $self->get_line;
   $str =~ s/^\s*\Q$prompt\E// if ($^O eq 'MacOS');
+  utf8::upgrade($str)
+      if (${^UNICODE} & PERL_UNICODE_STDIN || defined ${^ENCODING}) &&
+         utf8::valid($str);
   print $out $rl_term_set[3]; 
   # bug in 5.000: chomping empty string creats length -1:
   chomp $str if defined $str;
@@ -285,7 +290,7 @@ sub Features { \%features }
 
 package Term::ReadLine;                # So late to allow the above code be defined?
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 
 my ($which) = exists $ENV{PERL_RL} ? split /\s+/, $ENV{PERL_RL} : undef;
 if ($which) {
index 8c9dfa8..d696e4f 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -925,8 +925,8 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                    MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ?
                        mg_find(sv, PERL_MAGIC_utf8) : NULL;
                    if (mg && mg->mg_len >= 0)
-                       mg->mg_len += utf8_length(STRING(scan),
-                                                 STRING(scan)+STR_LEN(scan));
+                       mg->mg_len += utf8_length((U8*)STRING(scan),
+                                                 (U8*)STRING(scan)+STR_LEN(scan));
                }
                if (UTF)
                    SvUTF8_on(data->last_found);
index df478b0..89046c3 100755 (executable)
@@ -242,6 +242,11 @@ SKIP: {
     $DEV =~ s{^.+?\s\..+?$}{}m;
     @DEV =  grep { ! m{^\..+$} } @DEV;
 
+    # Irix ls -l marks sockets with 'S' while 's' is a 'XENIX semaphore'.
+    if ($^O eq 'irix') {
+        $DEV =~ s{^S(.+?)}{s$1}mg;
+    }
+
     my $try = sub {
        my @c1 = eval qq[\$DEV =~ /^$_[0].*/mg];
        my @c2 = eval qq[grep { $_[1] "/dev/\$_" } \@DEV];
index aff0f9b..dfe9d3d 100644 (file)
@@ -535,16 +535,16 @@ sub settime {
   $hz ||= 1;
   
   if( $opt_r ){
-    $$runtime = ($rrun_rtime - $overhead - $over_rtime * $total_marks/$over_tests/2)/$hz;
+    $$runtime = ($rrun_rtime - $overhead)/$hz;
   }
   elsif( $opt_s ){
-    $$runtime = ($rrun_stime - $overhead - $over_stime * $total_marks/$over_tests/2)/$hz;
+    $$runtime = ($rrun_stime - $overhead)/$hz;
   }
   elsif( $opt_u ){
-    $$runtime = ($rrun_utime - $overhead - $over_utime * $total_marks/$over_tests/2)/$hz;
+    $$runtime = ($rrun_utime - $overhead)/$hz;
   }
   else{
-    $$runtime = ($rrun_ustime - $overhead - ($over_utime + $over_stime) * $total_marks/$over_tests/2)/$hz;
+    $$runtime = ($rrun_ustime - $overhead)/$hz;
   }
   $$runtime = 0 unless $$runtime > 0;
 }
@@ -575,10 +575,9 @@ sub display_tree {
   exclusives_in_tree($deep_times);
   
   my $kid;
-  local *kids = $deep_times->{kids}; # %kids
 
   my $time;
-  if (%kids) {
+  if (%{$deep_times->{kids}}) {
     $time = sprintf '%.*fs = (%.*f + %.*f)', 
       $time_precision, $deep_times->{incl_time}/$hz,
         $time_precision, $deep_times->{excl_time}/$hz,
@@ -589,7 +588,7 @@ sub display_tree {
   print ' ' x (2*$level), "$name x $deep_times->{count}  \t${time}s\n"
     if $deep_times->{count};
 
-  for $kid (sort kids_by_incl keys %kids) {
+  for $kid (sort kids_by_incl %{$deep_times->{kids}}) {
     display_tree( $deep_times->{kids}{$kid}, $kid, $level + 1 );
   }  
 }
@@ -626,15 +625,16 @@ sub display {
 
 sub move_keys {
   my ($source, $dest) = @_;
-  my $kid;
-  
-  for $kid (keys %$source) {
-    if (exists $dest->{$kid}) {
-      $dest->{count} += $source->{count};
-      $dest->{incl_time} += $source->{incl_time};
-      move_keys($source->{kids},$dest->{kids});
+
+  for my $kid_name (keys %$source) {
+    my $source_kid = delete $source->{$kid_name};
+
+    if (my $dest_kid = $dest->{$kid_name}) {
+      $dest_kid->{count} += $source_kid->{count};
+      $dest_kid->{incl_time} += $source_kid->{incl_time};
+      move_keys($source_kid->{kids},$dest_kid->{kids});
     } else {
-      $dest->{$kid} = delete $source->{$kid};
+      $dest->{$kid_name} = $source_kid;
     }
   }
 }
@@ -645,11 +645,11 @@ sub add_to_tree {
     $name = $curdeep_times->[-1]{name};
   }
   die "Shorted?!" unless @$curdeep_times >= 2;
-  $curdeep_times->[-2]{kids}{$name} = { count => 0 , kids => {}, 
-                                       incl_time => 0,
-                                     } 
-    unless exists $curdeep_times->[-2]{kids}{$name};
-  my $entry = $curdeep_times->[-2]{kids}{$name};
+  my $entry = $curdeep_times->[-2]{kids}{$name} ||= {
+    count => 0,
+    kids => {}, 
+    incl_time => 0,
+  };
   # Now transfer to the new node (could not do earlier, since name can change)
   $entry->{count}++;
   $entry->{incl_time} += $t - $curdeep_times->[-1]{enter_stamp};
@@ -666,6 +666,7 @@ sub parsestack {
        my( $x, $z, $c, $id, $pack );
        my @stack = ();
        my @tstack = ();
+       my %outer;
        my $tab = 3;
        my $in = 0;
 
@@ -674,7 +675,6 @@ sub parsestack {
        my $l_name = '';
        my $repcnt = 0;
        my $repstr = '';
-       my $dprof_t = 0;
        my $dprof_stamp;
        my %cv_hash;
        my $in_level = not defined $opt_g; # Level deep in report grouping
@@ -720,22 +720,22 @@ sub parsestack {
                  $name = defined $syst ? $syst : $cv_hash{$usert};
                }
 
-               next unless $in_level or $name eq $opt_g or $dir eq '*';
+               next unless $in_level or $name eq $opt_g;
                if ( $dir eq '-' or $dir eq '*' ) {
                        my $ename = $dir eq '*' ? $stack[-1][0]  : $name;
                        $overhead += $over_per_call;
                        if ($name eq "Devel::DProf::write") {
-                         $dprof_t += $t - $dprof_stamp;
+                         $overhead += $t - $dprof_stamp;
                          next;
                        } elsif (defined $opt_g and $ename eq $opt_g) {
                          $in_level--;
                        }
                        add_to_tree($curdeep_times, $ename,
-                                   $t - $dprof_t - $overhead) if $opt_S;
+                                   $t - $overhead) if $opt_S;
                        exitstamp( \@stack, \@tstack, 
-                                  $t - $dprof_t - $overhead, 
+                                  $t - $overhead, 
                                   $times, $ctimes, $ename, \$in, $tab, 
-                                  $curdeep_times );
+                                  $curdeep_times, \%outer );
                } 
                next unless $in_level or $name eq $opt_g;
                if( $dir eq '+' or $dir eq '*' ){
@@ -774,11 +774,12 @@ sub parsestack {
                                push( @$idkeys, $name );
                        }
                        $calls->{$name}++;
+                        $outer{$name}++;
                        push @$curdeep_times, { kids => {}, 
                                                name => $name, 
-                                               enter_stamp => $t - $dprof_t - $overhead,
+                                               enter_stamp => $t - $overhead,
                                              } if $opt_S;
-                       $x = [ $name, $t - $dprof_t - $overhead ];
+                       $x = [ $name, $t - $overhead ];
                        push( @stack, $x );
 
                        # my children will put their time here
@@ -792,6 +793,11 @@ sub parsestack {
                print ' ' x $l_in, "$l_name$repstr\n";
        }
 
+        while (my ($key, $count) = each %outer) {
+            next unless $count;
+            warn "$key has $count unstacked calls in outer\n";
+        }
+
        if( @stack ){
                if( ! $opt_F ){
                        warn "Garbled profile is missing some exit time stamps:\n";
@@ -807,11 +813,11 @@ sub parsestack {
                        foreach $x ( reverse @stack ){
                                $name = $x->[0];
                                exitstamp( \@stack, \@tstack, 
-                                          $t - $dprof_t - $overhead, $times, 
+                                          $t - $overhead, $times, 
                                           $ctimes, $name, \$in, $tab, 
-                                          $curdeep_times );
+                                          $curdeep_times, \%outer );
                                add_to_tree($curdeep_times, $name,
-                                           $t - $dprof_t - $overhead)
+                                           $t - $overhead)
                                  if $opt_S;
                        }
                }
@@ -823,7 +829,7 @@ sub parsestack {
 }
 
 sub exitstamp {
-       my($stack, $tstack, $t, $times, $ctimes, $name, $in, $tab, $deep) = @_;
+       my($stack, $tstack, $t, $times, $ctimes, $name, $in, $tab, $deep, $outer) = @_;
        my( $x, $c, $z );
 
        $x = pop( @$stack );
@@ -852,8 +858,9 @@ sub exitstamp {
        $c = pop( @$tstack );
        # total time this func has been active
        $z = $t - $x->[1];
-       $ctimes->{$name} += $z;
-       $times->{$name} += ($z > $c)? $z - $c: 0;
+       $ctimes->{$name} += $z
+            unless --$outer->{$name};
+       $times->{$name} += $z - $c;
        # pass my time to my parent
        if( @$tstack ){
                $c = pop( @$tstack );
@@ -922,7 +929,7 @@ sub rby_avgcpu { $persecs->{$a} <=> $persecs->{$b} }
 
 format CSTAT_top =
 Total Elapsed Time = @>>>>>>> Seconds
-(($rrun_rtime - $overhead - $over_rtime * $total_marks/$over_tests/2) / $hz)
+(($rrun_rtime - $overhead) / $hz)
   @>>>>>>>>>> Time = @>>>>>>> Seconds
 $whichtime, $runtime
 @<<<<<<<< Times
index df89626..f9a09a1 100644 (file)
@@ -1842,12 +1842,12 @@ use ExtUtils::MakeMaker;
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
 WriteMakefile(
-    'NAME'             => '$module',
-    'VERSION_FROM'     => '$modfname.pm', # finds \$VERSION
-    'PREREQ_PM'                => {$prereq_pm}, # e.g., Module::Name => 1.1
-    (\$] >= 5.005 ?    ## Add these new keywords supported since 5.005
-      (ABSTRACT_FROM => '$modfname.pm', # retrieve abstract from module
-       AUTHOR     => '$author <$email>') : ()),
+    NAME              => '$module',
+    VERSION_FROM      => '$modfname.pm', # finds \$VERSION
+    PREREQ_PM         => {$prereq_pm}, # e.g., Module::Name => 1.1
+    (\$] >= 5.005 ?     ## Add these new keywords supported since 5.005
+      (ABSTRACT_FROM  => '$modfname.pm', # retrieve abstract from module
+       AUTHOR         => '$author <$email>') : ()),
 END
 if (!$opt_X) { # print C stuff, unless XS is disabled
   $opt_F = '' unless defined $opt_F;
@@ -1858,9 +1858,9 @@ if (!$opt_X) { # print C stuff, unless XS is disabled
 EOC
 
   print PL <<END;
-    'LIBS'             => ['$extralibs'], # e.g., '-lm'
-    'DEFINE'           => '$opt_F', # e.g., '-DHAVE_SOMETHING'
-$Icomment    'INC'             => '$I', # e.g., '${Ihelp}-I/usr/include/other'
+    LIBS              => ['$extralibs'], # e.g., '-lm'
+    DEFINE            => '$opt_F', # e.g., '-DHAVE_SOMETHING'
+$Icomment    INC               => '$I', # e.g., '${Ihelp}-I/usr/include/other'
 END
 
   my $C = grep {$_ ne "$modfname.c"}
@@ -1871,7 +1871,7 @@ END
 EOC
 
   print PL <<END;
-$Ccomment    $Cpre\'OBJECT'            => '\$(O_FILES)', # link all the C files too
+$Ccomment    ${Cpre}OBJECT            => '\$(O_FILES)', # link all the C files too
 END
 } # ' # Grr
 print PL ");\n";