1 1.1 mrg #!/bin/sh - 2 1.1 mrg # 3 1.4 snj # $NetBSD: tocrc,v 1.4 2004/03/31 02:10:00 snj Exp $ 4 1.2 perry # 5 1.1 mrg # Copyright (c) 1993 6 1.1 mrg # The Regents of the University of California. All rights reserved. 7 1.1 mrg # 8 1.1 mrg # Redistribution and use in source and binary forms, with or without 9 1.1 mrg # modification, are permitted provided that the following conditions 10 1.1 mrg # are met: 11 1.1 mrg # 1. Redistributions of source code must retain the above copyright 12 1.1 mrg # notice, this list of conditions and the following disclaimer. 13 1.1 mrg # 2. Redistributions in binary form must reproduce the above copyright 14 1.1 mrg # notice, this list of conditions and the following disclaimer in the 15 1.1 mrg # documentation and/or other materials provided with the distribution. 16 1.1 mrg # 3. All advertising materials mentioning features or use of this software 17 1.1 mrg # must display the following acknowledgement: 18 1.1 mrg # This product includes software developed by the University of 19 1.1 mrg # California, Berkeley and its contributors. 20 1.1 mrg # 4. Neither the name of the University nor the names of its contributors 21 1.1 mrg # may be used to endorse or promote products derived from this software 22 1.1 mrg # without specific prior written permission. 23 1.1 mrg # 24 1.1 mrg # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 1.1 mrg # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 1.1 mrg # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 1.1 mrg # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 1.1 mrg # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 1.1 mrg # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 1.1 mrg # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 1.1 mrg # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 1.1 mrg # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 1.1 mrg # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 1.1 mrg # SUCH DAMAGE. 35 1.1 mrg # 36 1.1 mrg # @(#)tocrc 8.2 (Berkeley) 5/5/94 37 1.1 mrg # 38 1.1 mrg tmp=/tmp/toc$$ 39 1.1 mrg trap "rm $tmp ; exit" 2 3 15 40 1.1 mrg : tocx files for all sections and everything else 41 1.1 mrg 42 1.1 mrg if [ ! -f tocx8 ]; then 43 1.1 mrg for x in 1 2 3 4 5 6 7 8; do 44 1.1 mrg /usr/libexec/getNAME -t `cat man$x` | 45 1.1 mrg sed \ 46 1.1 mrg -e 's/.s-2//g' \ 47 1.1 mrg -e 's/.s-1//g' \ 48 1.1 mrg -e 's/.s0//g' \ 49 1.1 mrg -e 's/.s+1//g' \ 50 1.1 mrg -e 's/ *.- */: /' \ 51 1.1 mrg -e 's/ *$/./' \ 52 1.1 mrg -e 's/.TH.* //' \ 53 1.1 mrg -e 's/@g@//' \ 54 1.1 mrg -e 's/@G@//' \ 55 1.1 mrg > tocx$x 56 1.1 mrg done 57 1.1 mrg fi 58 1.1 mrg : permuted index and toc files 59 1.1 mrg 60 1.1 mrg cat tocx* cshcmd > /tmp/cattoc 61 1.1 mrg 62 1.4 snj # If this fails, try gptx from GNU coreutils (pkgsrc/sysutils/coreutils) 63 1.1 mrg ptx -r -t -b break -f -w 108 -i ignore /tmp/cattoc ptxx 64 1.1 mrg 65 1.1 mrg for x in 1 2 3 4 5 6 7 8; do 66 1.1 mrg grep '^intro' <tocx$x >$tmp 67 1.1 mrg sed \ 68 1.1 mrg -e '2,${' \ 69 1.1 mrg -e '/^intro/d' \ 70 1.1 mrg -e '}' \ 71 1.1 mrg -e 's/ .*://' \ 72 1.1 mrg -e 's/.$//' \ 73 1.1 mrg -e 's/([^)]*) /" "/' \ 74 1.1 mrg -e 's/.*/.xx "&"/' \ 75 1.1 mrg -e '/""/d' \ 76 1.1 mrg $tmp tocx$x \ 77 1.1 mrg >toc$x 78 1.1 mrg done 79 1.1 mrg exit 80