This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Carp: Fix off-by-one error for early Perl versions
authorKarl Williamson <khw@cpan.org>
Thu, 11 Dec 2014 19:37:01 +0000 (12:37 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 6 Feb 2015 22:18:42 +0000 (15:18 -0700)
This error occurred only when running Perl before 5.14, and included DEL
as a printable instead of excluding it.

dist/Carp/lib/Carp.pm

index 9c5e4b8..a03f7e0 100644 (file)
@@ -300,7 +300,7 @@ sub format_arg {
            }
            my $o = ord($c);
            substr $arg, $i, 1, sprintf("\\x{%x}", $o)
-               if $o < 0x20 || $o > 0x7f;
+               if $o < 0x20 || $o > 0x7e;
        }
     } else {
        $arg =~ s/([\"\\\$\@])/\\$1/g;
@@ -318,7 +318,7 @@ sub Regexp::CARP_TRACE {
            my $o = ord(substr($arg, $i, 1));
            my $x = substr($arg, 0, 0);   # work around bug on Perl 5.8.{1,2}
            substr $arg, $i, 1, sprintf("\\x{%x}", $o)
-               if $o < 0x20 || $o > 0x7f;
+               if $o < 0x20 || $o > 0x7e;
        }
     } else {
        $arg =~ s/([^ -~])/sprintf("\\x{%x}",ord($1))/eg;