This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
parts/inc/inctools: Add sort fcn of API lines
authorKarl Williamson <khw@cpan.org>
Tue, 13 Aug 2019 04:37:44 +0000 (22:37 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 27 Sep 2019 22:39:31 +0000 (16:39 -0600)
These lines have the name be the 3rd field with separator '|'

(cherry picked from commit 7f9278b13869baea6e8b01690990c71ff3ce8838)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/parts/inc/inctools

index 7ac26bd..c78246f 100644 (file)
@@ -88,4 +88,14 @@ sub dictionary_order($$)    # Sort caselessly, ignoring punct
          or    $valid_a cmp $valid_b);
 }
 
+sub sort_api_lines  # Sort lines of the form flags|return|name|args...
+                    # by 'name'
+{
+    $a =~ / ^ [^|]* \| [^|]* \| (\w+) /x; # 3rd field '|' is sep
+    my $a_name = $1;
+    $b =~ / ^ [^|]* \| [^|]* \| (\w+) /x;
+    my $b_name = $1;
+    return dictionary_order($a_name, $b_name);
+}
+
 1;