2 # Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
5 # xrs - detect unsorted cross references in section SEE ALSO
7 # Cross references in the SEE ALSO section should
8 # be sorted by section number, and then placed in alphabetical
9 # order and comma separated. For example:
11 # ls(1), ps(1), group(5), passwd(5).
13 # The last entry may be finished with a dot `.'
15 # or a source example:.
22 # usage: xrs manpages ...
24 # $FreeBSD: src/share/man/man0/xrs.pl,v 1.5 1999/08/28 00:19:39 peter Exp $
25 # $DragonFly: src/share/man/man0/Attic/xrs.pl,v 1.2 2003/06/17 04:36:58 dillon Exp $
29 local(@c) = split($",$a);
30 local(@d) = split($",$b);
32 local($ret) = ($c[2] <=> $d[2]);
35 return $c[1] cmp $d[1];
38 sub usage { die "usage: xrs manpages ...\n"; }
43 return 1 if ($#a != $#b);
45 for($i = 0; $i <= $#a; $i++) {
50 for ($i = 0; $i < $#a; $i++) {
51 return 1 if $a[$i] !~ /\s,\s*$/;
54 return 1 if $a[$#a] =~ /\s,\s*$/;
55 return 1 if $a[$#a] =~ /^.Xr\s+\S+\s+\S+\s+[^.\s]/;
59 &usage if $#ARGV >= 0 && $ARGV[0] =~ /^-\?|h/;
62 if (/^\.Sh\s/ && /"?SEE\s+ALSO"?/) {
66 last if $file ne $ARGV;
68 next if /^\.\\"\s/; # " ignore comments
69 # next if m%^/[^/]+/%; # ignore absolute path names
70 if (!/^\.(Xr|Fn)\s/) {
71 if (!/^\.(Sh|Rs|\\"|Pp|br)\s*/ && !/^\s*$/) {
72 warn "Oops: $ARGV $_";
80 if (&compare(*a,*b)) {