[comp.windows.x] Rename X man pages script & add extra man references

stergios@jessica.Stanford.EDU (stergios marinopoulos) (01/10/90)

#! /bin/csh -f

# cxml - Create X Manual Links
#
# create links to X manual pages with long file names, and with all cited
# similar topics.
#
# cxml < X man source directory >
#
# To run, cd to the directory where you want the links created.
# Run this shell script with an argument of where the X man pages are.
# For example:
#
#	(cd /usr/local/man/man3 ; cxml /usr/local/X11R4/man/man3)
#
# BUGS: if an item is cited in more than one man page then only
# 	the first citation is used.  This may cause errors messages
#	from ln, but you may disregard them: I know I do.
#
#	You might have to replace "cut" with an appropriate command
#	on your system.
#
# Enjoy, Stergios Marinopoulos
#
# stergios@jessica.stanford.edu
#
#

if ( $#argv != 1 ) then
	echo usage:  cxml \<X man source directory\>
	exit 1
endif

if ( ! -d $1 ) then
	echo bad man source directory: $1
	exit 1
endif

set sourcedir = $1
set length

foreach file ($sourcedir/*)

echo $file
set suffix = $file:e

set startline = `egrep -n ".SH NAME" $file`
set startline = `echo $startline | cut -d: -f1`
@ startline += 1

set endline = `egrep -n ".SH SYNTAX"\|".SH STRUCTURES" $file`
set endline = `echo $endline | cut -d: -f1`

@ length = $endline - $startline

set names = `tail +${startline} $file | head -${length} | tr -d "," `

	foreach name ($names)
	if ( $name == "\-" || $name == "\" ) break
	echo "         " ${name}
	ln -s $file ${name}.${suffix}
	end
end