This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix B::Xref to handle sub refs
[perl5.git] / lib / sort.pm
index 326724b..99d9f0b 100644 (file)
@@ -1,16 +1,15 @@
 package sort;
 
-our $VERSION = '2.00';
+our $VERSION = '2.03';
 
 # The hints for pp_sort are now stored in $^H{sort}; older versions
 # of perl used the global variable $sort::hints. -- rjh 2005-12-19
 
-$sort::hint_bits = 0x00020000; # HINT_LOCALIZE_HH
-
 $sort::quicksort_bit   = 0x00000001;
 $sort::mergesort_bit   = 0x00000002;
 $sort::sort_bits       = 0x000000FF; # allow 256 different ones
 $sort::stable_bit      = 0x00000100;
+$sort::unstable_bit    = 0x00000200;
 
 use strict;
 
@@ -21,7 +20,6 @@ sub import {
        Carp::croak("sort pragma requires arguments");
     }
     local $_;
-    no warnings 'uninitialized';       # bitops would warn
     $^H{sort} //= 0;
     while ($_ = shift(@_)) {
        if (/^_q(?:uick)?sort$/) {
@@ -32,6 +30,7 @@ sub import {
            $^H{sort} |=  $sort::mergesort_bit;
        } elsif ($_ eq 'stable') {
            $^H{sort} |=  $sort::stable_bit;
+           $^H{sort} &= ~$sort::unstable_bit;
        } elsif ($_ eq 'defaults') {
            $^H{sort} =   0;
        } else {
@@ -39,7 +38,6 @@ sub import {
            Carp::croak("sort: unknown subpragma '$_'");
        }
     }
-    $^H |= $sort::hint_bits;
 }
 
 sub unimport {
@@ -57,6 +55,7 @@ sub unimport {
            $^H{sort} &= ~$sort::sort_bits;
        } elsif ($_ eq 'stable') {
            $^H{sort} &= ~$sort::stable_bit;
+           $^H{sort} |=  $sort::unstable_bit;
        } else {
            require Carp;
            Carp::croak("sort: unknown subpragma '$_'");
@@ -184,14 +183,14 @@ So now this code would be written:
   { use sort qw(defaults _quicksort); # force quicksort
     no sort "stable";      # stability not wanted
     my $current;
-    BEGIN { $current = print sort::current; }
+    BEGIN { $current = sort::current; }
     print "$current\n";
     @a = sort @b;
     # Pragmas go out of scope at the end of the block
   }
   { use sort qw(defaults stable);     # force stability
     my $current;
-    BEGIN { $current = print sort::current; }
+    BEGIN { $current = sort::current; }
     print "$current\n";
     @c = sort @d;
   }