#!/bin/sh
#
# Extract the Chapter number headings and titles from chapters and
# appendices, and create variables for the chapter number and title
#
# Greg Lehey, 6 April 1996
#
# $Id: getchapternumbers,v 2.7 2011/10/24 03:49:50 grog Exp $
#
length=$1
shift
if [ "$*" = "" ]; then
  echo '*** No chapters ***' >/dev/stderr
  exit 1 
fi
echo .\\\" Chapters
echo .nr CN 0 1
cat $* | ${TOOLS}/stripcond $length | egrep '^\.Chapter *\\' \
    | sed 's:^.*\[n\(.*\)\] *"*\(.*\)"*:.ds n\1 \\n+(CN\
.ds \1 Chapter \\\*\[n\1], \\fI\2\\fR:'
echo .\\\" Appendices
echo .nr AN 64 1
cat $* | ${TOOLS}/stripcond $length | egrep '^\.Appendix' \
    | sed 's:^.*\[n\(.*\)\] *"*\(.*\)"*:.ds n\1 \\N\'\'\\\\n+[AN]\''\
.ds \1 Appendix \\\*\[n\1], \\fI\2\\fR:

'
