From owner-p4-projects@FreeBSD.ORG Fri Jan 28 12:56:21 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0622316A4D0; Fri, 28 Jan 2005 12:56:21 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E97116A4CE for ; Fri, 28 Jan 2005 12:56:20 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6BFD743D1F for ; Fri, 28 Jan 2005 12:56:20 +0000 (GMT) (envelope-from des@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j0SCuKZI022010 for ; Fri, 28 Jan 2005 12:56:20 GMT (envelope-from des@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j0SCuK47022007 for perforce@freebsd.org; Fri, 28 Jan 2005 12:56:20 GMT (envelope-from des@freebsd.org) Date: Fri, 28 Jan 2005 12:56:20 GMT Message-Id: <200501281256.j0SCuK47022007@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to des@freebsd.org using -f From: Dag-Erling Smorgrav To: Perforce Change Reviews Subject: PERFORCE change 69865 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2005 12:56:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=69865 Change 69865 by des@des.at.des.thinksec.com on 2005/01/28 12:56:15 Numerous improvements inspired by comments from ru@. Mainly, this fixes a couple of markup bugs, improves reference sorting, and improves handling of function argument names (function pointer arguments were not properly handled). Affected files ... .. //depot/projects/openpam/misc/gendoc.pl#29 edit Differences ... ==== //depot/projects/openpam/misc/gendoc.pl#29 (text+ko) ==== @@ -32,7 +32,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $P4: //depot/projects/openpam/misc/gendoc.pl#28 $ +# $P4: //depot/projects/openpam/misc/gendoc.pl#29 $ # use strict; @@ -156,7 +156,7 @@ $args = "\"$args\""; %xref = ( - "pam 3" => 1 + 3 => { 'pam' => 1 }, ); if ($type eq "int") { @@ -164,14 +164,21 @@ next unless (m/^ \*\s+(!?PAM_[A-Z_]+|=[a-z_]+)\s*$/); push(@errors, $1); } - $xref{"pam_strerror 3"} = 1; + ++$xref{3}->{'pam_strerror'}; } $argnames = $args; + # extract names of regular arguments $argnames =~ s/\"[^\"]+\*?\b(\w+)\"/\"$1\"/g; + # extract names of function pointer arguments + $argnames =~ s/\"([\w\s\*]+)\(\*?(\w+)\)\([^\)]+\)\"/\"$2\"/g; + # escape metacharacters (there shouldn't be any, but...) $argnames =~ s/([\|\[\]\(\)\.\*\+\?])/\\$1/g; + # separate argument names with | $argnames =~ s/\" \"/|/g; + # and surround with () $argnames =~ s/^\"(.*)\"$/($1)/; + # $argnames is now a regexp that matches argument names $inliteral = $inlist = 0; foreach (split("\n", $source)) { s/\s*$//; @@ -197,8 +204,9 @@ } next; } - if (m/^>(\w+)(?:\s+(\d))?$/) { - ++$xref{$2 ? "$1 $2" : "$1 3"}; + if (m/^>(\w+)(\s+\d)?$/) { + my ($page, $sect) = ($1, $2 ? int($2) : 3); + ++$xref{$sect}->{$page}; next; } if (s/^\s+(=?\w+):\s*/.It $1/) { @@ -232,12 +240,12 @@ next; } s/\s*=$func\b\s*/\n.Nm\n/gs; - s/\s*=$argnames\b\s*/\n.Va $1\n/gs; + s/\s*=$argnames\b\s*/\n.Fa $1\n/gs; s/\s*=(struct \w+(?: \*)?)\b\s*/\n.Vt $1\n/gs; s/\s*:([a-z_]+)\b\s*/\n.Va $1\n/gs; s/\s*;([a-z_]+)\b\s*/\n.Dv $1\n/gs; while (s/\s*=([a-z_]+)\b\s*/\n.Xr $1 3\n/s) { - ++$xref{"$1 3"}; + ++$xref{3}->{$1}; } s/\s*\"(?=\w)/\n.Do\n/gs; s/\"(?!\w)\s*/\n.Dc\n/gs; @@ -333,6 +341,23 @@ $func->{'errors'} = [ sort(keys(%errors)) ]; } +sub genxref($) { + my $xref = shift; # References + + my $mdoc = ''; + my @refs = (); + foreach my $sect (sort(keys(%{$xref}))) { + foreach my $page (sort(keys(%{$xref->{$sect}}))) { + push(@refs, "$page $sect"); + } + } + while ($_ = shift(@refs)) { + $mdoc .= ".Xr $_" . + (@refs ? " ,\n" : "\n"); + } + return $mdoc; +} + sub gendoc($) { my $func = shift; # Ref to function hash @@ -391,11 +416,7 @@ "; } } - $mdoc .= ".Sh SEE ALSO\n"; - my @xref = sort(keys(%{$func->{'xref'}})); - while (@xref) { - $mdoc .= ".Xr " . shift(@xref) . (@xref ? " ,\n" : "\n"); - } + $mdoc .= ".Sh SEE ALSO\n" . genxref($func->{'xref'}); $mdoc .= ".Sh STANDARDS\n"; if ($func->{'openpam'}) { $mdoc .= "The @@ -415,7 +436,7 @@ function and this manual page were developed for the .Fx Project by ThinkSec AS and Network Associates Laboratories, the -Security Research Division of Network Associates, Inc. under +Security Research Division of Network Associates, Inc.\& under DARPA/SPAWAR contract N66001-01-C-8035 .Pq Dq CBOSS , as part of the DARPA CHATS research program. @@ -495,7 +516,7 @@ } while () { if (m/^\.Xr (\S+)\s*(\d)\s*$/) { - $xref{$1} = $2; + ++$xref{int($2)}->{$1}; } print FILE $_; } @@ -503,7 +524,7 @@ if ($page eq 'pam') { print FILE ".Sh RETURN VALUES The following return codes are defined by -.Aq Pa security/pam_constants.h : +.In security/pam_constants.h : .Bl -tag -width 18n "; foreach (sort(keys(%PAMERR))) { @@ -513,18 +534,13 @@ } print FILE ".Sh SEE ALSO "; - print FILE ".Xr openpam 3 ,\n" - if ($page eq 'pam'); + if ($page eq 'pam') { + ++$xref{3}->{'openpam'}; + } foreach $func (keys(%FUNCTIONS)) { - $xref{$func} = 3; + ++$xref{3}->{$func}; } - my @refs = sort(keys(%xref)); - while ($_ = shift(@refs)) { - print FILE ".Xr $_ $xref{$_}"; - print FILE " ," - if (@refs); - print FILE "\n"; - } + print FILE genxref(\%xref); print FILE ".Sh STANDARDS .Rs .%T \"X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules\" @@ -534,7 +550,7 @@ The OpenPAM library and this manual page were developed for the .Fx Project by ThinkSec AS and Network Associates Laboratories, the -Security Research Division of Network Associates, Inc. under +Security Research Division of Network Associates, Inc.\& under DARPA/SPAWAR contract N66001-01-C-8035 .Pq Dq CBOSS , as part of the DARPA CHATS research program.